Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lesion-wise metrics #50

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compute_metrics/compute_metrics_reloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
'nsd': 'Normalized surface distance (NSD)',
'vol_diff': 'Volume difference',
'rel_vol_error': 'Relative volume error (RVE)',
'lesion_ppv': 'Lesion wise positive predictive value (PPV)',
'lesion_sensitivity': 'Lesion wise sensitivity',
'lesion_f1_score': 'Lesion wise F1 score',
}


Expand Down
37 changes: 29 additions & 8 deletions tests/test_compute_metrics_reloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from compute_metrics.compute_metrics_reloaded import compute_metrics_single_subject
import tempfile

METRICS = ['dsc', 'fbeta', 'nsd', 'vol_diff', 'rel_vol_error']
METRICS = ['dsc', 'fbeta', 'nsd', 'vol_diff', 'rel_vol_error', 'lesion_ppv', 'lesion_sensitivity', 'lesion_f1_score']


class TestComputeMetricsReloaded(unittest.TestCase):
Expand Down Expand Up @@ -59,7 +59,10 @@ def test_empty_ref_and_pred(self):
'fbeta': 1,
'nsd': np.nan,
'rel_vol_error': 0,
'vol_diff': np.nan}}
'vol_diff': np.nan,
'lesion_ppv': 1.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 1.0}}

# Create empty reference
self.create_dummy_nii(self.ref_file, np.zeros((10, 10, 10)))
Expand All @@ -81,7 +84,10 @@ def test_empty_ref(self):
'fbeta': 0,
'nsd': 0.0,
'rel_vol_error': 100,
'vol_diff': np.inf}}
'vol_diff': np.inf,
'lesion_ppv': 0.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 0.0}}

# Create empty reference
self.create_dummy_nii(self.ref_file, np.zeros((10, 10, 10)))
Expand All @@ -105,7 +111,10 @@ def test_empty_pred(self):
'fbeta': 0,
'nsd': 0.0,
'rel_vol_error': -100.0,
'vol_diff': 1.0}}
'vol_diff': 1.0,
'lesion_ppv': 0.0,
'lesion_sensitivity': 0.0,
'lesion_f1_score': 0.0}}

# Create non-empty reference
ref = np.zeros((10, 10, 10))
Expand All @@ -129,7 +138,10 @@ def test_non_empty_ref_and_pred(self):
'fbeta': 0.26666667461395266,
'nsd': 0.5373134328358209,
'rel_vol_error': 300.0,
'vol_diff': 3.0}}
'vol_diff': 3.0,
'lesion_ppv': 1.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 1.0}}

# Create non-empty reference
ref = np.zeros((10, 10, 10))
Expand All @@ -156,14 +168,20 @@ def test_non_empty_ref_and_pred_multi_class(self):
'vol_diff': 2.0,
'rel_vol_error': 200.0,
'EmptyRef': False,
'EmptyPred': False},
'EmptyPred': False,
'lesion_ppv': 1.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 1.0},
2.0: {'dsc': 0.26666666666666666,
'fbeta': 0.26666667461395266,
'nsd': 0.5373134328358209,
'vol_diff': 3.0,
'rel_vol_error': 300.0,
'EmptyRef': False,
'EmptyPred': False}}
'EmptyPred': False,
'lesion_ppv': 1.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 1.0}}

# Create non-empty reference
ref = np.zeros((10, 10, 10))
Expand Down Expand Up @@ -191,7 +209,10 @@ def test_non_empty_ref_and_pred_with_full_overlap(self):
'fbeta': 1.0,
'nsd': 1.0,
'rel_vol_error': 0.0,
'vol_diff': 0.0}}
'vol_diff': 0.0,
'lesion_ppv': 1.0,
'lesion_sensitivity': 1.0,
'lesion_f1_score': 1.0}}

# Create non-empty reference
ref = np.zeros((10, 10, 10))
Expand Down
Loading