decimation - josalggui/MaRGE GitHub Wiki

decimate method

Description

The decimate method from marge_utils converts oversampled MRI readout data to the desired bandwidth using a two-stage decimation approach:

  1. FIR-based decimation with an anti-aliasing filter
  2. Optional averaging-based 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.


Parameters

  • 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)
    If True, removes add_rd_points from the start and end of each readout line after decimation.
    Defaults to True.

  • 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 to 10.

  • oversampling_factor (int, optional)
    Oversampling factor used during acquisition.
    Defines the total effective decimation factor applied to the data.
    Defaults to 5.

  • decimation_factor (int, optional)
    FIR decimation factor applied using an anti-aliasing filter.
    If smaller than oversampling_factor, the remaining decimation is performed by averaging.
    Defaults to 5.


Returns

  • numpy.ndarray
    Decimated RX data array, optionally with extra readout points removed.

Notes

  • The total effective decimation factor is always equal to oversampling_factor.
  • oversampling_factor must be a multiple of decimation_factor; otherwise, an error is raised.
  • When decimation_factor < oversampling_factor, the remaining factor
    (oversampling_factor / decimation_factor) is applied by averaging consecutive samples.
  • Averaging 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.

Workflow

  1. Validate decimation factors
    Ensure oversampling_factor is a multiple of decimation_factor.

  2. Optional preprocessing (PETRA mode)

    • Reshape data into (n_adc, samples_per_adc)
    • Replace early readout samples with a stabilized value to reduce filter ringing.
  3. FIR decimation
    Apply anti-aliasing FIR filtering and decimate by decimation_factor.

  4. Averaging-based decimation (if required)

    • Complete the remaining decimation by averaging consecutive samples.
    • Improves SNR while preserving phase.
  5. Optional trimming of readout points
    Remove add_rd_points from the beginning and end of each ADC window.

  6. Return decimated data


Typical Use Case

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
⚠️ **GitHub.com Fallback** ⚠️