【SimpleITK】医疗影像分割结果评价指标计算
⽂章⽬录
OverlapMeasures
jaccard
dice
volume_similarity
fal_negative
fal_positive
其中:
Volumemeasures:
建⽴枚举对象:
fromenumimportEnum
#Uenumerationstoreprentthevariouvaluationmeasures
classOverlapMeasures(Enum):
jaccard,dice,volume_similarity,fal_negative,fal_positive=range(5)
reference_gmentation=reference_gmentation_STAPLE
建⽴空的数组,为了后⾯保存结果:
#Emptynumpyarraystoholdtheresults
overlap_results=((len(gmentations),len(OverlapMeasures.__members__.items())))
overlap_results
array([[0.,0.,0.,0.,0.],
[0.,0.,0.,0.,0.],
[0.,0.,0.,0.,0.]])
计算每个指标:
overlap_measures_filter=verlapMeasuresImageFilter()
fori,ginenumerate(gmentations):
#Overlapmeasures
overlap_measures_e(reference_gmentation,g)
overlap_results[i,]=overlap_measures_cardCoefficient()
overlap_results[i,]=overlap_measures_eCoefficient()
overlap_results[i,_]=overlap_measures_umeSimilarity()
overlap_results[i,_]=overlap_measures_NegativeError()
overlap_results[i,_]=overlap_measures_PositiveError()
overlap_results
结果:
volumeSimilarityv1+v2
2∗(v1−v2)
array([[0.82,0.901,0.052,0.075,0.122],
[0.881,0.937,-0.013,0.069,0.057],
[0.843,0.915,-0.088,0.124,0.044]])
SurfaceDistanceMeasures
hausdorff_distance
mean_surface_distance
median_surface_distance
std_surface_distance
max_surface_distance
建⽴枚举对象:
classSurfaceDistanceMeasures(Enum):
hausdorff_distance,mean_surface_distance,median_surface_distance,std_surface_distance,max_surface_distance=range(5)
reference_gmentation=reference_gmentation_STAPLE
建⽴空的数组,为了后⾯保存结果:
surface_distance_results=((len(gmentations),len(SurfaceDistanceMeasures.__members__.items())))
surface_distance_results
array([[0.,0.,0.,0.,0.],
[0.,0.,0.,0.,0.],
[0.,0.,0.,0.,0.]])
对GT进⾏预处理:
#Utheabsolutevaluesofthedistancemaptocomputethesurfacedistances(distancemapsign,outsideorinside
#relationship,isirrelevant)
label=1
reference_distance_map=(MaurerDistanceMap(reference_gmentation,squaredDistance=Fal))
reference_surface=ontour(reference_gmentation)
statistics_image_filter=ticsImageFilter()
#Getthenumberofpixelsinthereferencesurfacebycountingallpixelsthatare1.
statistics_image_e(reference_surface)
num_reference_surface_pixels=int(statistics_image_())
计算指标:
hausdorff_distance_filter=rffDistanceImageFilter()
fori,ginenumerate(gmentations):
hausdorff_distance_e(reference_gmentation,g)
surface_distance_results[i,rff_]=hausdorff_distance_sdorffDistance()
#Symmetricsurfacedistancemeasures
gmented_distance_map=(MaurerDistanceMap(g,squaredDistance=Fal,uImageSpacing=True))
gmented_surface=ontour(g)
#ultingdistance
#mapscontainnon-zerovaluesonlyonthesurface(theycanalsocontainzeroonthesurface)
g2ref_distance_map=reference_distance_map*(gmented_surface,oat32)
ref2g_distance_map=gmented_distance_map*(reference_surface,oat32)
#Getthenumberofpixelsinthereferencesurfacebycountingallpixelsthatare1.
statistics_image_e(gmented_surface)
num_gmented_surface_pixels=int(statistics_image_())
#Getallnon-zerodistancesandthenaddzerodistancesifrequired.
g2ref_distance_map_arr=ayViewFromImage(g2ref_distance_map)
g2ref_distances=list(g2ref_distance_map_arr[g2ref_distance_map_arr!=0])
g2ref_distances=g2ref_distances+
list((num_gmented_surface_pixels-len(g2ref_distances)))
ref2g_distance_map_arr=ayViewFromImage(ref2g_distance_map)
ref2g_distances=list(ref2g_distance_map_arr[ref2g_distance_map_arr!=0])
ref2g_distances=ref2g_distances+
list((num_reference_surface_pixels-len(ref2g_distances)))
all_surface_distances=g2ref_distances+ref2g_distances
#Themaximumofthesy
#general,itisnotequaltotheHausdorffdistancebetweenallvoxel/pixelpointsofthetwo
#gmentations,thisbelow.
surface_distance_results[i,_surface_]=(all_surface_distances)
surface_distance_results[i,_surface_]=(all_surface_distances)
surface_distance_results[i,_surface_]=(all_surface_distances)
surface_distance_results[i,_surface_]=(all_surface_distances)
print(surface_distance_results)
结果:
[[4.9050.4590.0.854.905]
[3.4690.290.0.6893.469]
[5.2030.4310.0.8315.203]]
为了理解上⾯的代码,我们需要了解豪斯多夫距离(hausdorffdistance):
豪斯多夫距离
参考,。
在这⾥插⼊图⽚描述
假设有两组集合,,A点集有p个点,⽽B点集有q个点。则这两个点集合之间的Hausdorff距离定义
为:
其中,
为,在A中的每⼀个点,到距离此点最近的B集合中的点的距离,然后对这些距离进⾏排序。
A中有p个点,每个点都有B中距离最近的点。两两之间求距离,需要计算次。
取所有距离中的最⼤值为的值。
someAPI
ontour
Labelsthepixelsontheborderoftheobjectsinalabeledimage.得到mask的3维轮廓。
对reference_gmentation进⾏轮廓提取处理:
reference_surface=ontour(reference_gmentation)
A={a,…,a}1
pB={b,…,b}1
q
H(A,B)=max(h(A,B),h(B,A))
h(A,B)
ai∣a−ib∣i
p∗q
h(A,B)
MaurerDistanceMap
reference_distance_map=(MaurerDistanceMap(reference_gmentation,squaredDistance=Fal,uImageSpacing=True))
ticsImageFilter
statistics_image_filter=ticsImageFilter()
#Getthenumberofpixelsinthereferencesurfacebycountingallpixelsthatare1.
statistics_image_e(reference_surface)
num_reference_surface_pixels=int(statistics_image_())
print(num_reference_surface_pixels)
558
verlapMeasuresImageFilter
overlap_measures_filter=verlapMeasuresImageFilter()
rffDistanceImageFilter
hausdorff_distance_filter=rffDistanceImageFilter()
本文发布于:2022-11-27 04:20:55,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/28732.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |