decimation - josalggui/MaRGE GitHub Wiki
The decimate method from marge_utils converts oversampled MRI readout data to the desired bandwidth using a two-stage decimation approach:
- FIR-based decimation with an anti-aliasing filter
- Optional frequency-domain decimation to complete the effective decimation while preserving phase and improving SNR
This design ensures that the total effective decimation factor always matches the acquisition oversampling factor, even when the FIR decimation factor is smaller.
-
data_over (
numpy.ndarray)
Oversampled complex RX data to be decimated.
The data is assumed to be a concatenation of all ADC windows. -
n_adc (
int)
Number of ADC windows in the dataset.
Used to reshape the data so that each readout line is processed independently. -
option (
str, optional)
Preprocessing option applied before decimation:-
'PETRA'(default): Stabilizes the beginning of each readout to reduce oscillations introduced by FIR filtering. -
'Normal': No preprocessing is applied.
-
-
remove (
bool, optional)
IfTrue, removesadd_rd_pointsfrom the start and end of each readout line after decimation.
Defaults toTrue. -
add_rd_points (
int, optional)
Number of additional points acquired at the beginning and end of each readout line.
These points are typically used to absorb filter transients.
Defaults to10. -
oversampling_factor (
int, optional)
Oversampling factor used during acquisition.
Defines the total effective decimation factor applied to the data.
Defaults to5. -
decimation_factor (
int, optional)
FIR decimation factor applied using an anti-aliasing filter.
If smaller thanoversampling_factor, the remaining decimation is performed by frequency-domain downsampling. Defaults to5.
-
numpy.ndarray
Decimated RX data array, optionally with extra readout points removed.
- The total effective decimation factor is always equal to
oversampling_factor. -
oversampling_factormust be a multiple ofdecimation_factor; otherwise, an error is raised. - When
decimation_factor < oversampling_factor, the remaining factor is applied by frequency-domain downsampling (FFT → center crop → IFFT). - Downsampling is performed independently for each ADC window to avoid mixing readout lines.
- The PETRA preprocessing step is designed to reduce Gibbs-like oscillations caused by FIR filtering at the beginning of each readout.
-
Validate decimation factors
Ensureoversampling_factoris a multiple ofdecimation_factor. -
Optional preprocessing (
PETRAmode)- Reshape data into
(n_adc, samples_per_adc) - Replace early readout samples with a stabilized value to reduce filter ringing.
- Reshape data into
-
FIR decimation
Apply anti-aliasing FIR filtering and decimate bydecimation_factor. -
Frequency-domain decimation (FFT → center crop → IFFT)
- Transform each ADC window to frequency domain.
- Center-crop the spectrum.
- Transform back to time domain.
-
Optional trimming of readout points
Removeadd_rd_pointsfrom the beginning and end of each ADC window. -
Return decimated data
This method is typically called internally by runBatches after data acquisition to:
- Reduce oversampled RX data to the target bandwidth
- Suppress FIR filter transients
- Maintain phase coherence across readouts
- Input length must be divisible by
n_adc. - FIR decimation uses zero-phase filtering (
scipy.signal.decimate, FIR mode). - A half-filter offset is applied before FIR decimation to align output samples.
- Data may be complex-valued (typical for MRI RX signals).