dissector.evaluation ==================== .. py:module:: dissector.evaluation Functions --------- .. autoapisummary:: dissector.evaluation.compare_folders dissector.evaluation.compare_images dissector.evaluation.extract_boundary_2d dissector.evaluation.extract_boundary_3d dissector.evaluation.dilate_2d dissector.evaluation.dilate_3d dissector.evaluation.binary_cross_entropy dissector.evaluation.inter_slice_dice dissector.evaluation.boundary_iou_3d dissector.evaluation.boundary_iou_2d dissector.evaluation.single_row_viz dissector.evaluation.radarplot_single_dataset dissector.evaluation.side_by_side_comp dissector.evaluation.violin_compare Module Contents --------------- .. py:function:: compare_folders(folder_a: str, folder_b: str) -> bool 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. .. py:function:: compare_images(path_a: str, path_b: str) -> bool 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. :param path_a: path to the first image file. :param 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. .. py:function:: extract_boundary_2d(mask: numpy.ndarray) -> numpy.ndarray Get boundary pixels of a binary mask on 2d image. .. py:function:: extract_boundary_3d(mask: numpy.ndarray) -> numpy.ndarray Get boundary voxels of a 3D binary mask. .. py:function:: dilate_2d(mask: numpy.ndarray, distance: int) -> numpy.ndarray Simple square dilation on a 2D mask using NumPy only. .. py:function:: dilate_3d(mask: numpy.ndarray, distance: int) -> numpy.ndarray Simple dilation using NumPy only on a 3D matrix. .. py:function:: binary_cross_entropy(y_true: numpy.ndarray, y_pred: numpy.ndarray, eps: float = 1e-07) -> float 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). .. py:function:: inter_slice_dice(mask: numpy.ndarray) -> float 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. .. py:function:: boundary_iou_3d(distance: int, mask_a: numpy.ndarray, mask_b: numpy.ndarray) -> float Boundary iou. From metric definition same as boundary_iou_2d but done in 3d. .. py:function:: boundary_iou_2d(distance: int, mask_a: numpy.ndarray, mask_b: numpy.ndarray) -> float Extract boundary iou. According to formula from https://metrics-reloaded.dkfz.de/metric-library/ boundary_intersection_over_union_local definition. .. py:function:: single_row_viz(metrics: list, dataset: pandas.dataframe, row: int, title: str) -> None 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. .. py:function:: radarplot_single_dataset(metrics: list[str], dataset: pandas.DataFrame, title: str, labels: list[str] | None = None) -> None Plot a radar chart for all rows in a dataset. If labels is None, metrics are used as axis labels. .. py:function:: side_by_side_comp(datasets: list, metrics: list, titles: list, colors: list, labels: list) -> None Two radarplots. Warning, titles and colors must go in order of dataset1, dataset2 .. py:function:: 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 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.