runBatches - josalggui/MaRGE GitHub Wiki
The runBatches method executes multiple waveform batches generated from PyPulseq sequences, manages data acquisition from the hardware (or demo mode), and stores both oversampled and decimated RX data in the internal mapVals dictionary.
This method is designed to handle long MRI sequences by splitting them into hardware-compatible batches, executing each batch sequentially, and ensuring data integrity by automatically repeating acquisitions if data loss is detected.
-
waveforms (
dict)
Dictionary containing waveform sequences for each batch.- Keys: batch identifiers (e.g.,
"batch_1","batch_2") - Values: waveform data generated by PyPulseq and interpreted by FloSeq.
- Keys: batch identifiers (e.g.,
-
n_readouts (
dict)
Dictionary specifying the number of readout points per batch.- Keys must match the batch identifiers in
waveforms. - Values represent the number of readout points per batch before oversampling.
- Keys must match the batch identifiers in
-
n_adc (
int)
Number of ADC windows in the full sequence.
All ADC windows must have the same length. -
frequency (
float, optional)
Larmor frequency in MHz used for the acquisition.
Defaults tohw.larmorFreq. -
bandwidth (
float, optional)
Acquisition bandwidth in MHz.
The sampling period is computed as1 / bandwidth.
Defaults to0.03. -
decimate (
str, optional)
Decimation mode applied after acquisition:-
'Normal': Standard decimation without preprocessing. -
'PETRA': Adjusts pre-readout points to align with the desired acquisition start.
Useful to avoid oscillations caused by anti-aliasing filters on signal jumps between consecutive readouts.
-
-
add_rd_points (
int, optional)
Number of additional points acquired before and after each readout window.
These points are handled during decimation and can be used to mitigate filter transients.
Defaults tohw.addRdPoints. -
oversampling_factor (
int, optional)
Oversampling factor applied during acquisition.
Defaults tohw.oversamplingFactor. -
decimation_factor (
int, optional)
Decimation factor applied when reducing oversampled data using an FIR filter.
Defaults tohw.oversamplingFactor. -
hardware (
bool, optional)
IfTrue, gradient and ADC delays defined in the hardware configuration are applied. -
output (
str, optional)
Optional suffix appended to the output keys stored inmapVals.
Useful for distinguishing multiple acquisitions. -
channels (
list, optional)
List of receiver channels used for acquisition (e.g.,[0],[0, 1]).
Currently supports single-channel RX; multi-channel (MIMO) support is planned.
-
bool
ReturnsTrueif all batches are executed successfully.
ReturnsFalseif an error occurs (e.g., waveform constraints exceed hardware limits).
After execution, the following entries are added to self.mapVals:
-
n_readouts
List containing the number of readout points per batch (before oversampling). -
n_batches
Total number of executed batches. -
data_overordata_over_<output>
Concatenated oversampled complex RX data from all batches and scans. -
data_decimatedordata_decimated_<output>
Decimated RX data after applying the selected decimation method.
- Store batch metadata (
n_readouts,n_batches) inmapVals. - Initialize an empty container for oversampled RX data.
- For each batch:
- Initialize the Red Pitaya experiment (unless running in demo mode).
- Convert PyPulseq waveforms to
mriBlankSeqformat usingpypulseq2mriblankseq. - Load waveforms into the hardware and validate hardware limits.
- For each scan:
- Execute the batch.
- Verify the number of acquired points:
- Expected points =
n_readouts[batch] × oversampling_factor
- Expected points =
- Automatically repeat the batch if data loss is detected.
- Concatenate oversampled RX data across all batches and scans.
- Apply decimation using
utils.decimate, including:- Oversampling and decimation factors
- Additional readout points (
add_rd_points) - Selected decimation mode (
NormalorPETRA)
- Store oversampled and decimated data in
mapVals. - Optionally plot the sequence instead of executing it.
- Release hardware resources.
- In demo mode, synthetic complex Gaussian noise is generated instead of acquiring hardware data.
- The method automatically retries a batch if the number of acquired points does not match the expected count.
- Oversampled data is always preserved before decimation for further processing or debugging.
- When
plotSeqis enabled andstandalone=True, the sequence is visualized and not executed on hardware. - Decimation is performed using an FIR filter and supports PETRA-style preprocessing via
add_rd_points.