dissector.evaluation
Functions
|
Hash every file in two folders and assert they are identical. |
|
Hash two image files and assert they are identical. |
|
Get boundary pixels of a binary mask on 2d image. |
|
Get boundary voxels of a 3D binary mask. |
|
Simple square dilation on a 2D mask using NumPy only. |
|
Simple dilation using NumPy only on a 3D matrix. |
|
Binary cross entropy between two binary segmentation masks. |
|
Mean Dice between every pair of adjacent slices in a 3D binary mask. |
|
Boundary iou. |
|
Extract boundary iou. |
|
Graph a single image. |
|
Plot a radar chart for all rows in a dataset. |
|
Two radarplots. |
|
Violin plots comparing two sets of segmentation results across CSV files. |
Module Contents
- dissector.evaluation.compare_folders(folder_a: str, folder_b: str) bool[source]
Hash every file in two folders and assert they are identical.
Compares file names and SHA-256 content. Raises AssertionError with a human-readable diff if anything differs. Returns True if identical.
- dissector.evaluation.compare_images(path_a: str, path_b: str) bool[source]
Hash two image files and assert they are identical.
Computes SHA-256 of each file and raises AssertionError if they differ. Returns True if the files are byte-for-byte identical.
- Parameters:
path_a – path to the first image file.
path_b – path to the second image file.
- Returns:
True if both files have the same SHA-256 hash.
- Raises:
AssertionError – if the hashes differ, with both paths in the message.
- dissector.evaluation.extract_boundary_2d(mask: numpy.ndarray) numpy.ndarray[source]
Get boundary pixels of a binary mask on 2d image.
- dissector.evaluation.extract_boundary_3d(mask: numpy.ndarray) numpy.ndarray[source]
Get boundary voxels of a 3D binary mask.
- dissector.evaluation.dilate_2d(mask: numpy.ndarray, distance: int) numpy.ndarray[source]
Simple square dilation on a 2D mask using NumPy only.
- dissector.evaluation.dilate_3d(mask: numpy.ndarray, distance: int) numpy.ndarray[source]
Simple dilation using NumPy only on a 3D matrix.
- dissector.evaluation.binary_cross_entropy(y_true: numpy.ndarray, y_pred: numpy.ndarray, eps: float = 1e-07) float[source]
Binary cross entropy between two binary segmentation masks.
Clips y_pred to [eps, 1-eps] so that exact 0/1 voxels don’t produce log(0).
- dissector.evaluation.inter_slice_dice(mask: numpy.ndarray) float[source]
Mean Dice between every pair of adjacent slices in a 3D binary mask.
mask shape: (slices, H, W). Returns a value in [0, 1]; higher means smoother continuity across slices. Pairs where both slices are empty are skipped; a slice with no foreground paired against a non-empty one contributes 0.
- dissector.evaluation.boundary_iou_3d(distance: int, mask_a: numpy.ndarray, mask_b: numpy.ndarray) float[source]
Boundary iou.
From metric definition same as boundary_iou_2d but done in 3d.
- dissector.evaluation.boundary_iou_2d(distance: int, mask_a: numpy.ndarray, mask_b: numpy.ndarray) float[source]
Extract boundary iou.
According to formula from https://metrics-reloaded.dkfz.de/metric-library/ boundary_intersection_over_union_local definition.
- dissector.evaluation.single_row_viz(metrics: list, dataset: pandas.dataframe, row: int, title: str) None[source]
Graph a single image.
This visualizes a single row of metrics on a radar plot. metrics is a list, dataset is the dataframe, row is the row number.
- dissector.evaluation.radarplot_single_dataset(metrics: list[str], dataset: pandas.DataFrame, title: str, labels: list[str] | None = None) None[source]
Plot a radar chart for all rows in a dataset.
If labels is None, metrics are used as axis labels.
- dissector.evaluation.side_by_side_comp(datasets: list, metrics: list, titles: list, colors: list, labels: list) None[source]
Two radarplots.
Warning, titles and colors must go in order of dataset1, dataset2
- dissector.evaluation.violin_compare(csv_list_a: list[str], csv_list_b: list[str], label_a: str = 'Algorithm A', label_b: str = 'Algorithm B', metrics: list[str] | None = None, save_path: str | None = None) None[source]
Violin plots comparing two sets of segmentation results across CSV files.
Each CSV list comes from one segmentation algorithm. Shared numeric columns (or an explicit metrics list) are plotted side by side as paired violins.