欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【SimpleITK】分割结果融合策略

程序员文章站 2022-05-08 14:37:47
...

前言

有时我们会有多个专家标注的结果或者是多个模型得到的结果,对所有的结果做一个融合,目前有两种主流做法:

  • 投票法 (majority vote)
  • STAPLE (Simultaneous Truth and Performance Level Estimation)

对多个专家的标注结果进行融合之后,我们得到的标注就可以作为ground truth参与到模型的分割训练;当然,对多模型的结果进行融合,同样可以得到更加鲁棒的结果。
此处针对的场景是医疗影像,所以我们使用SimpleITK相应的API来实现结果融合的功能。官方notebook可以参考:http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/34_Segmentation_Evaluation.html

样例数据

数据

import SimpleITK as sitk
import numpy as np
import matplotlib.pyplot as plt
image = sitk.ReadImage("../Data/liverTumorSegmentations/Patient01Homo.mha")

segmentation_file_names = ["../Data/liverTumorSegmentations/Patient01Homo_Rad01.mha", 
                          "../Data/liverTumorSegmentations/Patient01Homo_Rad02.mha",
                          "../Data/liverTumorSegmentations/Patient01Homo_Rad03.mha"]
                          
segmentations = [sitk.ReadImage(file_name, sitk.sitkUInt8) for file_name in segmentation_file_names]

样例数据中有3个不同的标注,打印如下:

fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize = (20, 10))
ax1.imshow(sitk.GetArrayFromImage(image)[75], cmap=plt.cm.bone)
ax1.set_title('image')
ax2.imshow(sitk.GetArrayFromImage(segmentations[0])[75])
ax2.set_title('label 1')
ax3.imshow(sitk.GetArrayFromImage(segmentations[1])[75])
ax3.set_title('label 2')
ax4.imshow(sitk.GetArrayFromImage(segmentations[2])[75])
ax4.set_title('label 3')

一幅图像,3个标注:
【SimpleITK】分割结果融合策略

投票法

Use majority voting to obtain the reference segmentation.

API

  • sitk.LabelVoting
help(sitk.LabelVoting)

Help on function LabelVoting in module SimpleITK.SimpleITK:
LabelVoting(*args)

  • LabelVoting(VectorOfImage images, uint64_t labelForUndecidedPixels) -> Image

投票法无法处理ties?

labelForUndecidedPixels = 10
reference_segmentation_majority_vote = sitk.LabelVoting(segmentations, labelForUndecidedPixels)    

manual_plus_majority_vote = list(segmentations)  
# Append the reference segmentation to the list of manual bsegmentations
manual_plus_majority_vote.append(reference_segmentation_majority_vote)

显示:
【SimpleITK】分割结果融合策略

STAPLE algorithm

# Use the STAPLE algorithm to obtain the reference segmentation. This implementation of the original algorithm
# combines a single label from multiple segmentations, the label is user specified. The result of the
# filter is the voxel's probability of belonging to the foreground. We then have to threshold the result to obtain
# a reference binary segmentation.
foregroundValue = 1
threshold = 0.95
reference_segmentation_STAPLE_probabilities = sitk.STAPLE(segmentations, foregroundValue) 
# We use the overloaded operator to perform thresholding, another option is to use the BinaryThreshold function.
reference_segmentation_STAPLE = reference_segmentation_STAPLE_probabilities > threshold

manual_plus_staple = list(segmentations)  
# Append the reference segmentation to the list of manual segmentations
manual_plus_staple.append(reference_segmentation_STAPLE)

显示:
【SimpleITK】分割结果融合策略

对比

显示对比:
【SimpleITK】分割结果融合策略

相关标签: 医疗影像处理