Created
August 26, 2021 12:20
-
-
Save clementpoiret/c257e024ffde904f4169b13ed4ed449c to your computer and use it in GitHub Desktop.
Individual Metrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import pymia.evaluation.evaluator as eval_ | |
import pymia.evaluation.metric as metric | |
y = torch.randint(0, 4, (1, 16, 16, 16)) | |
y_hat = y * .8 - 1 | |
metrics = [ | |
metric.DiceCoefficient(), | |
metric.VolumeSimilarity(), | |
metric.MahalanobisDistance() | |
] | |
labels = { | |
0: 'background', | |
1: 'edema', | |
2: 'non-enhancing tumor', | |
3: 'enhancing tumor' | |
} | |
evaluator = eval_.SegmentationEvaluator(metrics, labels) | |
evaluator.evaluate(y_hat, y, "sub00") | |
{ | |
r.label.title() + " " + r.metric.title(): r.value | |
for r in evaluator.results | |
if r.label != 'background' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment