Closed 111678900 closed 2 weeks ago
Can you please provide a translation for your question in English so it is more accesible for other users.?
Hello, I apologize for the inconvenience. Do you have a function developed for calculating segmentation accuracy, including sensitivity, specificity, Hausdorff distance 95%, average surface distance, and residual mean square distance?
I have completed the training process. I'm wondering if you have developed functionality for calculating segmentation accuracy, including sensitivity, specificity, Hausdorff distance 95%, average surface distance, and residual mean square distance. Thank you very much.
找到.../nnunetv2/evaluation/evaluate_predictions.py这个文件,在里面添加函数。nnUNetv1有这些指标,但是没法仿照着写。建议自己写吧? 这是我的,不一定对: ...
results['metrics'][r]['Sensitivity'] = tp / (tp + fn) if (tp + fn) > 0 else np.nan
# Sensitivity = TP/TP+FN (Recall)
results['metrics'][r]['Specificity'] = tn / (tn + fp) if (tn + fp) > 0 else np.nan
# Specificity = TN/TN+FP
results['metrics'][r]['Jaccard'] = tp / (tp + fp + fn) if (tp + fp + fn) != 0 else np.nan
# Jaccard = TP/TP+FP+FN
#Hausdorff distance
results['metrics'][r]['hausdorff distance'] = hd
results['metrics'][r]['hausdorff distance 95'] = hd95
...
def compute_hausdorff(test, reference):
# test & reference: shape(1, 155, 240, 240)
test_slices = test[0] # (155, 240, 240)
reference_slices = reference[0] # (155, 240, 240)
all_hd = []
for i in range(test_slices.shape[0]):
slice_test = test_slices[i]
slice_reference = reference_slices[i]
if slice_test.any() and slice_reference.any():
hd = max(directed_hausdorff(slice_test, slice_reference)[0],
directed_hausdorff(slice_reference, slice_test)[0])
all_hd.append(hd)
if all_hd:
hd95 = np.percentile(all_hd, 95)
return max(all_hd), hd95
else:
return np.nan, np.nan
I assume this issue is concluded with @e-FunJs answer
您好,请问计算分割准确性,包括灵敏度,特异性,Hausdorff距离95%,平均表面距离和残余均方距离。代码该怎么写?