seg_metrics package

Module contents

seg_metrics.write_metrics(labels: Sequence, gdth_path: Optional[Union[str, Path, Sequence]] = None, pred_path: Optional[Union[str, Path, Sequence]] = None, csv_file: Optional[Union[str, Path]] = None, gdth_img: Optional[Union[ndarray, Image, Sequence]] = None, pred_img: Optional[Union[ndarray, Image, Sequence]] = None, metrics: Optional[Union[Sequence, Set]] = None, verbose: bool = True, spacing: Optional[Union[Sequence, ndarray]] = None, fully_connected: bool = True, TPTNFPFN: bool = False) Union[List[Dict], Dict]
Parameters:
  • labels – a list of labels to performe the calculation of metrics. Normally used to exclude background label

  • gdth_path – for ground truth, specify an absolute path of a directory or file, or a sequence of pathes of files

  • pred_path – for prediction, specify an absolute path of a directory or file, or a sequence of pathes of files

  • csv_file – filename to save the metrics. Do not save metrics if it is None. Default is None

  • gdth_img – for ground truth, specify a (sequence of) np.ndarray or SimpleITK.Image

  • pred_img – for prediction, specify a (sequence of) np.ndarray or SimpleITK.Image

  • metrics – metric names. Default is [‘dice’, ‘jaccard’, ‘precision’, ‘recall’, ‘fpr’, ‘fnr’, ‘vs’, ‘hd’, ‘hd95’, ‘msd’, ‘mdsd’, ‘stdsd’]

  • verbose – whether to show the animated progress bar. Default is True

  • spacing – spacing of input images, a list of floating numbers with shape (N, ) where N is the dimension of images.

  • fully_connected – whether to apply fully connected border during the calculation of surface distance.

  • TPTNFPFN – whether to return the number of voxels/pixels for true positive, false positive, true negative, false negative predictions. Default is False

Returns:

A dict or a list of dicts which store metrics