Experiment class - josalggui/MaRGE GitHub Wiki
The Experiment class is a custom extension of the base Experiment class provided by the marge.marcos.marcos_client.experiment module. It adds MaRGE-specific functionality and hardware-aware behavior, particularly accounting for oversampling and ADC scaling defined in the hardware configuration.
This class is responsible for:
- Initializing MRI experiments with appropriate hardware parameters
- Managing sampling rates and timing
- Compiling and running sequences on the MARCOS server
- Retrieving and scaling received IQ data into physical units
-
lo_freq(float, MHz). Local oscillator frequency. -
rx_t(float, µs). Receiver sampling period. Must be a multiple of 1 / 122.88. Values such as 3.125 are exact. -
seq_dict(dict, optional). Dictionary containing the sequence definition. -
seq_csv(str, optional). Path to a CSV file describing the sequence. -
rx_lo(int). Index of the internal NCO local oscillator to use (0, 1, or 2). -
grad_max_update_rate(float, MSPS). Maximum gradient update rate across all channels. -
gpa_fhdo_offset_time(int). Offset time applied when using GPA-FHDO to emulate simultaneous gradient updates. -
print_infos(bool). Enable or disable server info messages. -
assert_errors(bool) Halt execution when server errors occur. -
init_gpa(bool). Initialize the GPA upon experiment creation. -
initial_wait(float, µs). Initial delay before the experiment starts, required for LO and RX configuration. -
auto_leds(bool). Automatically scan LED patterns during sequence execution. -
prev_socket(socket, optional). Reuse an existing socket connection to the server. -
fix_cic_scale(bool). Apply precise CIC scaling based on the RX rate. -
set_cic_shift(bool). Configure CIC bit shifting to keep gain consistent across rates. -
allow_user_init_cfg(bool). Allow user modifications to the default flocra configuration. -
halt_and_reset(bool). Stop any running sequences when connecting to the server. -
flush_old_rx(bool). Clear RX FIFOs before running the sequence. -
oversampling_factor(int, optional). Oversampling factor applied to the readout.
The constructor automatically adjusts the receiver sampling time (rx_t) by dividing it by the hardware oversampling factor (hw.oversamplingFactor) before passing it to the base class.
-
getSamplingRate(): Returns the effective sampling rate use by the sequence discounting the oversampling. -
get_sampling_period(): Returns the effective sampling rate use by the sequence discounting the oversampling.
Compiles the sequence (if not already compiled), sends the machine code to the MARCOS server, executes the experiment, and retrieves the acquired RX data.
Behaviour:
- Compiles the sequence if required.
- Optionally flushes old RX data from the server.
- Sends the compiled sequence to the server for execution.
- Retrieves raw IQ data.
- Scales and converts the data to complex values in millivolts.
Returns tuple:
-
rxd_iq(dict): Dictionary containing complex IQ signals per receiver channel (rx0, rx1) in millivolts. -
msgs(list): Server messages returned during execution.
Notes:
- RX data is scaled using:
- Hardware ADC factor (hw.adcFactor)
- CIC normalization factors
- Channels that are unavailable or missing are safely ignored.
The Experiment class provides a MaRGE-specific abstraction over the base MARCOS experiment interface. It ensures correct handling of oversampling, hardware scaling, and RX data conversion, making it suitable for high-level MRI sequence execution and data acquisition within the MaRGE framework.