Evaluating segmentation algorithms using SimpleITK filters (Python) and results of statistical analysis (R) in order to demonstrate the statistical significance of comparisons between used models.
The python library can be found here.
In order to apply and evaluate segmentation models, images must be in a dictionary with the following structure:
dict[Rater][Image] = [list_of_segmentations]
Where
- Rater is rater's ground truth name
- Image is image's path
- list_of_segmentations is the list of GT segmentations.
For example:
data_dir = "/home/"
dataset_folders = sorted(glob.glob(os.path.join(data_dir,"subset*")))
images = []
segmentations = {"Rater_Name":{}}
for folder in dataset_folders:
images = images + sorted(glob.glob(folder + "/*.mhd"))
for image in images:
name = os.path.split(image)[1]
segmentation_file_names = glob.glob(os.path.join(data_dir,'seg-lungs/',name))
segmentations["Rater_Name"][image] = [segmentation_file_names]
Get Measures of applying Neural Network to an image and its evaluation by SimpleITK filters. These measures will be saved in a csv file. Here is an example of how to apply this method.
rois_labels = {1:"Right_Lung", 2:"Left_Lung", 3:"Both_Lungs"}
GT_label_values = [2,3]
saving_path = "/path/results"
measures = GetMeasures(subset_name, segmentations, rois_labels, saving_path, GT_label_values = GT_label_values,
debug_mode = False, flip_image = True, flip_GT = True, image_extension = ".mhd", GT_extension = ".mhd")
Images and GTs must be in axial plane, as it is shown in the following pictures. If you need to rotate them, turn on flip_image and / or flip_GT.
This function shows all GTs that are in the dictionary segmentations and their labels.
ShowGT(segmentations,flip_GT)