Skip to content

Commit

Permalink
Fix the error of volume similarity sign
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingnan-Jia committed Jul 16, 2024
1 parent 71e15e6 commit bc37480
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions seg_metrics/seg_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,22 @@ def computeQualityMeasures(lP: np.ndarray,
fnr = fn / (fn + tp)




dicecomputer = sitk.LabelOverlapMeasuresImageFilter()
dicecomputer.Execute(labelTrue > 0.5, labelPred > 0.5)
v_pred = np.sum(labelPred > 0.5)
v_gdth = np.sum(labelTrue > 0.5)
if v_pred + v_gdth == 0: # prediction results and ground truth are all 0
vs = 0
else:
vs = 2 * (v_pred - v_gdth) / (v_pred + v_gdth)
# dicecomputer = sitk.LabelOverlapMeasuresImageFilter()
# dicecomputer.Execute(labelPred > 0.5, labelTrue > 0.5)

quality["dice"] = dice
quality["jaccard"] = jaccard
quality["precision"] = precision
quality["recall"] = recall
quality["fnr"] = fnr
quality["fpr"] = fpr
quality["vs"] = dicecomputer.GetVolumeSimilarity()
quality["vs"] = vs

quality["TP"] = tp
quality["TN"] = tn
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setuptools.setup(
name="seg_metrics", # Replace with your own username
version="1.2.7",
version="1.2.8",
author="Jingnan Jia",
author_email="[email protected]",
description="A package to compute different segmentation metrics for 2D/3D medical images.",
Expand Down

0 comments on commit bc37480

Please sign in to comment.