Skip to content

Commit b214d26

Browse files
committed
Small fixes for detecting the correct files in folders with multiple timestamps. [skip ci]
1 parent 230d29f commit b214d26

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

raidionicsval/Studies/AbstractStudy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def compute_and_plot_categorical_metric_over_metric_categories(self, class_name:
433433
category=category,
434434
study_name=study_name,
435435
suffix=suffix + '_' + metric2 + '_' + cat)
436+
suffix = "tp" + suffix if category == "True Positive" else suffix
436437
export_segmentation_df_to_latex_paper(folder=self.output_folder, class_name=class_name, study=study_name,
437438
categories=list(optimal_results_per_cutoff.keys()), suffix=suffix)
438439
except Exception as e:

raidionicsval/Studies/SegmentationStudy.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,40 @@ def run(self):
3131
metric2_cutoffs=[2.], category='All')
3232
"""
3333
for c in self.class_names:
34-
# super().compute_and_plot_overall(c, category='All')
35-
# super().compute_and_plot_overall(c, category='True Positive')
36-
#
37-
# # Plotting the results based on the selection of dense parameters
38-
# for s in SharedResources.getInstance().studies_selections_dense:
39-
# parsing = s.split(',')
40-
# metric1 = parsing[0]
41-
# metric2 = parsing[1]
42-
# if parsing[2] != '':
43-
# metric2_cutoff = [float(x) for x in parsing[2].split('-')]
44-
# else:
45-
# metric2_cutoff = None
46-
# category = parsing[3]
47-
# self.compute_and_plot_metric_over_metric_categories(class_name=c, metric1=metric1, metric2=metric2,
48-
# metric2_cutoffs=metric2_cutoff, category=category)
49-
#
50-
# # Plotting the results based on the selection of categorical parameters
51-
# for s in SharedResources.getInstance().studies_selections_categorical:
52-
# parsing = s.split(',')
53-
# metric1 = parsing[0].strip()
54-
# metric2 = parsing[1].strip()
55-
# if parsing[2].strip() != '':
56-
# metric2_cutoff = [x for x in parsing[2].split('-')]
57-
# else:
58-
# metric2_cutoff = None
59-
# category = parsing[3].strip()
60-
# self.compute_and_plot_categorical_metric_over_metric_categories(class_name=c, metric1=metric1,
61-
# metric2=metric2,
62-
# metric2_cutoffs=metric2_cutoff,
63-
# category=category)
64-
#
65-
# # Correlation matrix between all metrics
66-
# super().compute_and_plot_metrics_correlation_matrix(class_name=c, category='All')
67-
# super().compute_and_plot_metrics_correlation_matrix(class_name=c, category='True Positive')
34+
super().compute_and_plot_overall(c, category='All')
35+
super().compute_and_plot_overall(c, category='True Positive')
36+
37+
# Plotting the results based on the selection of dense parameters
38+
for s in SharedResources.getInstance().studies_selections_dense:
39+
parsing = s.split(',')
40+
metric1 = parsing[0]
41+
metric2 = parsing[1]
42+
if parsing[2] != '':
43+
metric2_cutoff = [float(x) for x in parsing[2].split('-')]
44+
else:
45+
metric2_cutoff = None
46+
category = parsing[3]
47+
self.compute_and_plot_metric_over_metric_categories(class_name=c, metric1=metric1, metric2=metric2,
48+
metric2_cutoffs=metric2_cutoff, category=category)
49+
50+
# Plotting the results based on the selection of categorical parameters
51+
for s in SharedResources.getInstance().studies_selections_categorical:
52+
parsing = s.split(',')
53+
metric1 = parsing[0].strip()
54+
metric2 = parsing[1].strip()
55+
if parsing[2].strip() != '':
56+
metric2_cutoff = [x for x in parsing[2].split('-')]
57+
else:
58+
metric2_cutoff = None
59+
category = parsing[3].strip()
60+
self.compute_and_plot_categorical_metric_over_metric_categories(class_name=c, metric1=metric1,
61+
metric2=metric2,
62+
metric2_cutoffs=metric2_cutoff,
63+
category=category)
64+
65+
# Correlation matrix between all metrics
66+
super().compute_and_plot_metrics_correlation_matrix(class_name=c, category='All')
67+
super().compute_and_plot_metrics_correlation_matrix(class_name=c, category='True Positive')
6868

6969
# Cascading results based on a combination of the selected dense/categorical parameters
7070
self.compute_and_plot_metric_over_metric_cascading_categories(class_name=c, category='All')

raidionicsval/Validation/kfold_model_validation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __compute_metrics(self):
116116
results_per_folds.append(results)
117117

118118
def __compute_metrics_for_fold(self, data_list, fold_number):
119+
data_list = ["5_1000_MR_FLAIR_post_4125", "5_1000_MR_FLAIR_pre_2366"]
119120
for i, patient in enumerate(tqdm(data_list)):
120121
uid = None
121122
try:
@@ -195,7 +196,7 @@ def __identify_patient_files(self, patient_metrics: PatientMetrics, folder_index
195196
for _, _, files in os.walk(detection_image_base):
196197
for f in files:
197198
if pred_suffix in f:
198-
if use_internal_convention and patient_metrics.patient_id.split('_')[1] in f:
199+
if use_internal_convention and patient_metrics.patient_id.split('_')[1] in f.split('_'):
199200
detection_filename = os.path.join(detection_image_base, f)
200201
elif not use_internal_convention:
201202
detection_filename = os.path.join(detection_image_base, f)

0 commit comments

Comments
 (0)