ultrasound_metrics.metrics.snr#
Signal-to-Noise Ratio (SNR) metric for ultrasound, commonly used for speckle.
This module provides functions to calculate the Signal-to-Noise Ratio (SNR) for ultrasound speckle patterns. The SNR is calculated as mean/standard-deviation.
References
Functions#
|
Calculate Signal-to-Noise Ratio (SNR) of an image. |
Module Contents#
- ultrasound_metrics.metrics.snr.snr(values: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *pixels], *, db: bool = False) float[source]#
Calculate Signal-to-Noise Ratio (SNR) of an image.
This function computes the Signal-to-Noise Ratio (SNR) for ultrasound speckle patterns by calculating mean/standard-deviation. This metric provides a single value per ROI/image.
\[\text{SNR} = \frac{\mathbb{E}[X]}{\sqrt{\text{Var}(X)}}\]where:
\(\mathbb{E}[X]\) is the mean (average pixel value) across the (post-envelope) image
\(\text{Var}(X)\) is the variance of pixel values across the (post-envelope) image
In ultrasound, the statistics of fully developed speckle signals (post envelope detection) follow a Rayleigh distribution, and the SNR of a Rayleigh distribution is equal to:
\[\text{SNR}_{\text{Rayleigh}} = \sqrt{\frac{\pi}{4 - \pi}} \approx 1.91\]- Parameters:
values (array) – Input values. - spatial dimensions are flattened - Can be real or complex floating-point data
db (bool, optional) – If True, return the SNR in decibels (dB). Default is False.
- Returns:
Signal-to-Noise Ratio (SNR) of the values. If
db=True, the SNR is returned in decibels (dB).- Return type:
- Warns:
UserWarning – If variance is zero (would cause division by zero).
Notes
This implementation is an amplitude ratio, not a power ratio.
Complex data is handled by computing the magnitude (absolute value) before processing
For Rayleigh-distributed speckle, the theoretical SNR is approximately 1.91
If ROI is used, it should be applied to the input values before calling this function