ultrasound_metrics.metrics.gcnr

ultrasound_metrics.metrics.gcnr#

Generalized Contrast-to-Noise Ratio (gCNR) metric.

References

Functions#

gcnr(→ float)

Calculate the generalized Contrast-to-Noise Ratio (gCNR) between two regions.

main(→ None)

Example usage with synthetic data.

Module Contents#

ultrasound_metrics.metrics.gcnr.gcnr(values_inside: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *inside_dims], values_outside: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *outside_dims], bins: Union[int, jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj,  n_bins]] = 100, ax: Optional[matplotlib.pyplot.Axes] = None) float[source]#

Calculate the generalized Contrast-to-Noise Ratio (gCNR) between two regions.

The gCNR is a robust metric for quantifying lesion detectability in medical imaging, particularly in ultrasound. It is defined as 1 - OVL, where OVL is the overlap area between the probability density functions of the pixel values inside and outside a lesion.

Unlike traditional CNR, gCNR:

  1. Is robust against dynamic range alterations

  2. Can be applied to all kinds of images, units, or scales

  3. Has a simple statistical interpretation: the success rate expected from an ideal observer at the task of separating pixels

See [1] for the original reference.

Parameters:
  • values_inside – Pixel values from inside the lesion (I), i.e. the region of interest. For hypoechoic lesions like cysts, these are typically lower intensity values.

  • values_outside – Pixel values from outside the lesion (O), i.e. the background region.

  • bins – Number of bins for histogram calculation, or a sequence of bin edges.

  • ax – If set, plots the PDFs and their overlap on the given Axes object.

Returns:

Generalized contrast-to-noise ratio (1 - OVL).

Return type:

float

Notes

  • gCNR = 0: Complete overlap of distributions (impossible to distinguish regions)

  • gCNR = 1: No overlap (perfect distinction between regions)

  • Pmax represents the theoretical maximum success rate for an ideal observer trying to classify individual pixels as belonging to either region

ultrasound_metrics.metrics.gcnr.main() None[source]#

Example usage with synthetic data.