ultrasound_metrics.metrics.rf_snr#
Radiofrequency Signal-to-Noise Ratio (RF SNR) metric.
This module provides functions to calculate the Signal-to-Noise Ratio (SNR) for radiofrequency ultrasound data. SNR quantifies how much stronger the signal (pulse echo) is compared to background noise.
References
Functions#
|
Calculate the Signal-to-Noise Ratio (SNR) for radiofrequency data. |
Automatically estimate signal and noise regions in RF data. |
Module Contents#
- ultrasound_metrics.metrics.rf_snr.compute_rf_snr(signal_data: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *signal_dims], noise_data: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *noise_dims], *, center: bool = True, max_power: bool = False, show: bool = False, ax: Optional[matplotlib.pyplot.Axes] = None) float[source]#
Calculate the Signal-to-Noise Ratio (SNR) for radiofrequency data.
SNR quantifies how much stronger the signal (pulse echo) is compared to background noise. This metric is commonly used in ultrasound imaging quality assessment [1] and has been implemented in analysis tools [2].
The calculation uses the formula:
SNR (dB) = 10 * log10(signal_power / noise_power)
where power is calculated as the Root Mean Square (RMS) squared.
- Parameters:
signal_data (ArrayAPIObj) – The signal region data to evaluate. Should be a 1D array of RF values.
noise_data (ArrayAPIObj) – The noise region data to evaluate. Should be a 1D array of RF values.
center (bool, optional) – If True, center the signal and noise regions to zero mean before calculating power. This removes DC offset effects.
max_power (bool, optional) – If True, use the maximum squared value in the signal region instead of the average power. Default is False (use average power).
show (bool, optional) – If True, display a plot showing the signal and noise data.
ax (plt.Axes, optional) – If set, plots the signal and noise data on the given Axes object.
- Returns:
The Signal-to-Noise Ratio in decibels (dB).
- Return type:
Notes
Higher SNR values indicate better signal quality
Typical SNR values range from 30-100 dB for good quality RF data
Centering the data (center=True) is recommended to remove DC offset
- ultrasound_metrics.metrics.rf_snr.find_signal_and_noise(data: jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *dims], signal_width: Union[int, list[int]] = 20, noise_offset: int = 50, ignore_until: int = 0, noise_size: Optional[int] = None, show: bool = False, ax: Optional[matplotlib.pyplot.Axes] = None) tuple[jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *signal_dims], jaxtyping.Num[ultrasound_metrics._utils.array_api.ArrayAPIObj, *noise_dims]][source]#
Automatically estimate signal and noise regions in RF data.
This function finds the maximum value in the data (after ignoring initial samples) and defines signal and noise regions around it based on the provided parameters.
- Parameters:
data (ArrayAPIObj) – The RF data to analyze. Should be a 1D array.
signal_width (int or list[int], optional) – Width of the signal region. If int, defines total width centered on max. If list[int], defines [samples_before_max, samples_after_max].
noise_offset (int, optional) – Number of samples to skip between signal and noise regions.
ignore_until (int, optional) – Number of initial samples to ignore (e.g., to avoid startup artifacts).
noise_size (int, optional) – Maximum number of samples for noise region. If None, uses all available.
show (bool, optional) – If True, display a plot showing the estimated regions.
ax (plt.Axes, optional) – If set, plots the signal and noise data on the given Axes object.
- Returns:
(signal_data, noise_data) where each is the extracted data array.
- Return type:
tuple[ArrayAPIObj, ArrayAPIObj]
Notes
The signal region is centered on the maximum value in the data
The noise region is placed after the signal region with the specified offset
This is a heuristic approach and may need manual adjustment for best results