Skip to content

Commit

Permalink
Update formatting.
Browse files Browse the repository at this point in the history
New version of black changes the formatting slightly.
  • Loading branch information
zivy committed Feb 1, 2024
1 parent 90a70c1 commit 5fb28f5
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 42 deletions.
54 changes: 27 additions & 27 deletions Python/34_Segmentation_Evaluation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -277,27 +277,27 @@
"for i, seg in enumerate(segmentations):\n",
" # Overlap measures\n",
" overlap_measures_filter.Execute(seg, reference_segmentation)\n",
" overlap_results[\n",
" i, OverlapMeasures.jaccard.value\n",
" ] = overlap_measures_filter.GetJaccardCoefficient()\n",
" overlap_results[\n",
" i, OverlapMeasures.dice.value\n",
" ] = overlap_measures_filter.GetDiceCoefficient()\n",
" overlap_results[\n",
" i, OverlapMeasures.volume_similarity.value\n",
" ] = overlap_measures_filter.GetVolumeSimilarity()\n",
" overlap_results[\n",
" i, OverlapMeasures.false_negative.value\n",
" ] = overlap_measures_filter.GetFalseNegativeError()\n",
" overlap_results[\n",
" i, OverlapMeasures.false_positive.value\n",
" ] = overlap_measures_filter.GetFalsePositiveError()\n",
" overlap_results[i, OverlapMeasures.jaccard.value] = (\n",
" overlap_measures_filter.GetJaccardCoefficient()\n",
" )\n",
" overlap_results[i, OverlapMeasures.dice.value] = (\n",
" overlap_measures_filter.GetDiceCoefficient()\n",
" )\n",
" overlap_results[i, OverlapMeasures.volume_similarity.value] = (\n",
" overlap_measures_filter.GetVolumeSimilarity()\n",
" )\n",
" overlap_results[i, OverlapMeasures.false_negative.value] = (\n",
" overlap_measures_filter.GetFalseNegativeError()\n",
" )\n",
" overlap_results[i, OverlapMeasures.false_positive.value] = (\n",
" overlap_measures_filter.GetFalsePositiveError()\n",
" )\n",
" # Hausdorff distance\n",
" hausdorff_distance_filter.Execute(reference_segmentation, seg)\n",
"\n",
" surface_distance_results[\n",
" i, SurfaceDistanceMeasures.hausdorff_distance.value\n",
" ] = hausdorff_distance_filter.GetHausdorffDistance()\n",
" surface_distance_results[i, SurfaceDistanceMeasures.hausdorff_distance.value] = (\n",
" hausdorff_distance_filter.GetHausdorffDistance()\n",
" )\n",
" segmented_surface = sitk.LabelContour(seg)\n",
" # Symmetric surface distance measures\n",
" segmented_distance_map = sitk.Abs(\n",
Expand Down Expand Up @@ -336,18 +336,18 @@
" # The maximum of the symmetric surface distances is the Hausdorff distance between the surfaces. In\n",
" # general, it is not equal to the Hausdorff distance between all voxel/pixel points of the two\n",
" # segmentations, though in our case it is. More on this below.\n",
" surface_distance_results[\n",
" i, SurfaceDistanceMeasures.mean_surface_distance.value\n",
" ] = np.mean(all_surface_distances)\n",
" surface_distance_results[i, SurfaceDistanceMeasures.mean_surface_distance.value] = (\n",
" np.mean(all_surface_distances)\n",
" )\n",
" surface_distance_results[\n",
" i, SurfaceDistanceMeasures.median_surface_distance.value\n",
" ] = np.median(all_surface_distances)\n",
" surface_distance_results[\n",
" i, SurfaceDistanceMeasures.std_surface_distance.value\n",
" ] = np.std(all_surface_distances)\n",
" surface_distance_results[\n",
" i, SurfaceDistanceMeasures.max_surface_distance.value\n",
" ] = np.max(all_surface_distances)\n",
" surface_distance_results[i, SurfaceDistanceMeasures.std_surface_distance.value] = (\n",
" np.std(all_surface_distances)\n",
" )\n",
" surface_distance_results[i, SurfaceDistanceMeasures.max_surface_distance.value] = (\n",
" np.max(all_surface_distances)\n",
" )\n",
"\n",
"# Print the matrices\n",
"np.set_printoptions(precision=3)\n",
Expand Down
40 changes: 25 additions & 15 deletions Python/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ def __init__(
# Display the data and the controls, first time we display the images is outside the "update_display" method
# as that method relies on the previous zoom factor which doesn't exist yet.
self.fixed_axes.imshow(
self.fixed_npa[self.fixed_slider.value, :, :]
if self.fixed_slider
else self.fixed_npa,
(
self.fixed_npa[self.fixed_slider.value, :, :]
if self.fixed_slider
else self.fixed_npa
),
cmap=plt.cm.Greys_r,
vmin=self.fixed_min_intensity,
vmax=self.fixed_max_intensity,
)
self.moving_axes.imshow(
self.moving_npa[self.moving_slider.value, :, :]
if self.moving_slider
else self.moving_npa,
(
self.moving_npa[self.moving_slider.value, :, :]
if self.moving_slider
else self.moving_npa
),
cmap=plt.cm.Greys_r,
vmin=self.moving_min_intensity,
vmax=self.moving_max_intensity,
Expand Down Expand Up @@ -164,9 +168,11 @@ def update_display(self):
# Draw the fixed image in the first subplot and the localized points.
self.fixed_axes.clear()
self.fixed_axes.imshow(
self.fixed_npa[self.fixed_slider.value, :, :]
if self.fixed_slider
else self.fixed_npa,
(
self.fixed_npa[self.fixed_slider.value, :, :]
if self.fixed_slider
else self.fixed_npa
),
cmap=plt.cm.Greys_r,
vmin=self.fixed_min_intensity,
vmax=self.fixed_max_intensity,
Expand Down Expand Up @@ -209,9 +215,11 @@ def update_display(self):
# Draw the moving image in the second subplot and the localized points.
self.moving_axes.clear()
self.moving_axes.imshow(
self.moving_npa[self.moving_slider.value, :, :]
if self.moving_slider
else self.moving_npa,
(
self.moving_npa[self.moving_slider.value, :, :]
if self.moving_slider
else self.moving_npa
),
cmap=plt.cm.Greys_r,
vmin=self.moving_min_intensity,
vmax=self.moving_max_intensity,
Expand Down Expand Up @@ -1050,9 +1058,11 @@ def get_rois(self):
both min/max values.
"""
return [
(roi_data[1], roi_data[2], roi_data[3])
if self.npa.ndim == 3
else (roi_data[1], roi_data[2])
(
(roi_data[1], roi_data[2], roi_data[3])
if self.npa.ndim == 3
else (roi_data[1], roi_data[2])
)
for roi_data in self.rois
]

Expand Down

0 comments on commit 5fb28f5

Please sign in to comment.