lesion_metrics package

Subpackages

Submodules

lesion_metrics.helper module

lesion_metrics.metrics module

Metrics to evaluate lesion segmentations Author: Jacob Reinhold (jacob.reinhold@jhu.edu) Created on: May 14, 2021

lesion_metrics.metrics.assd(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

average symmetric surface difference between predicted and true binary masks

lesion_metrics.metrics.avd(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

absolute volume difference between predicted and true binary masks

lesion_metrics.metrics.corr(pred_vols: Sequence[float], truth_vols: Sequence[float]) float[source]

pearson correlation coefficient btwn list of predicted and true binary vols

lesion_metrics.metrics.dice(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

dice coefficient between predicted and true binary masks

lesion_metrics.metrics.iou_per_lesion(target: lesion_metrics.typing.Label, other: lesion_metrics.typing.Label, *, return_count: bool = False) Union[List[float], Tuple[List[float], int]][source]

iou of each lesion using target as reference

lesion_metrics.metrics.isbi15_score(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label, *, reweighted: bool = True) float[source]

report the score from label images (minus volume correlation) for a given prediction as described in [1]

reweighted flag puts the score (excluding volume correlation which requires a list of labels) between 0 and 1

References:
[1] Carass, Aaron, et al. “Longitudinal multiple sclerosis

lesion segmentation: resource and challenge.” NeuroImage 148 (2017): 77-102.

lesion_metrics.metrics.isbi15_score_from_metrics(dsc: float, ppv: float, lfdr: float, ltpr: float, *, reweighted: bool = True) float[source]

report the score from the given metrics (minus volume correlation) for a given prediction as described in [1]

reweighted flag puts the score (excluding volume correlation which requires a list of labels) between 0 and 1

References:
[1] Carass, Aaron, et al. “Longitudinal multiple sclerosis

lesion segmentation: resource and challenge.” NeuroImage 148 (2017): 77-102.

lesion_metrics.metrics.jaccard(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

jaccard index (IoU) between predicted and true binary masks

lesion_metrics.metrics.lfdr(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label, *, iou_threshold: float = 0.0, return_pred_count: bool = False) Union[float, Tuple[float, int]][source]

lesion false discovery rate between predicted and true binary masks

lesion_metrics.metrics.ltpr(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label, *, iou_threshold: float = 0.0, return_truth_count: bool = False) Union[float, Tuple[float, int]][source]

lesion true positive rate between predicted and true binary masks

lesion_metrics.metrics.ppv(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

positive predictive value (precision) btwn predicted and true binary masks

lesion_metrics.metrics.tpr(pred: lesion_metrics.typing.Label, truth: lesion_metrics.typing.Label) float[source]

true positive rate (sensitivity) between predicted and true binary masks

lesion_metrics.typing module

Project-specific types

types for lesion_metrics (support np.ndarray or pytorch tensors or anything that implements a sum method)

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: May 14, 2021

class lesion_metrics.typing.Label(*args, **kwargs)[source]

Bases: Protocol

support anything that implements the methods here

any(axis: Optional[Union[int, Tuple[int, ...]]] = None) Any[source]
property ndim: int
nonzero() Any[source]
squeeze() Any[source]
sum() float[source]
class lesion_metrics.typing.LabelWithSpacing(*args, **kwargs)[source]

Bases: lesion_metrics.typing.Label, Protocol

property spacing: Tuple[float, ...]

lesion_metrics.utils module

Utilities for lesion metrics Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: 16 Aug 2021

lesion_metrics.utils.bbox(label: lesion_metrics.typing.Label) List[slice][source]
lesion_metrics.utils.to_numpy(label: lesion_metrics.typing.Label) lesion_metrics.typing.Label[source]

lesion_metrics.volume module

Calculate total lesion burden in a segmentation mask

calculation of lesion burden/volume given some type of medical image in a designated volume unit

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: 16 Aug 2021

class lesion_metrics.volume.SegmentationVolume(label: lesion_metrics.typing.LabelWithSpacing, unit: lesion_metrics.volume.UnitOfVolume = UnitOfVolume.microlitre)[source]

Bases: object

classmethod from_filename(path: Union[os.PathLike, str]) lesion_metrics.volume.SegmentationVolume[source]
volume() float[source]
volume_in_microliters() float[source]
volume_in_microlitres() float[source]
class lesion_metrics.volume.UnitOfVolume(value)[source]

Bases: enum.Enum

An enumeration.

liter = 'litre'
litre = 'litre'
microliter = 'micro'
microlitre = 'micro'
milliliter = 'milli'
millilitre = 'milli'

Module contents