Acquisition#
See also
User guide on the acquisition process.
Acquisition Control#
Acquisition Control Class.
- class console.spcm_control.acquisition_control.AcquisitionControl(configuration_file: str, nexus_data_dir: str = '/home/runner/nexus-console', file_log_level: int = 20, console_log_level: int = 20)[source]#
Bases:
object
Acquisition control class.
The main functionality of the acquisition control is to orchestrate transmit and receive cards using
TxCard
andRxCard
instances.- post_processing(parameter: AcquisitionParameter) None [source]#
Proces acquired NMR data.
Data is sorted according to readout size which might vary between different reout windows. Unprocessed and raw data are stored in class attributes _raw and _unproc. Both attributes are list, which store numpy arrays of readout data with the same number of readout sample points.
Post processing contains the following steps (per readout sample size): (1) Extraction of reference signal and scaling to float values [mV] (2) Concatenate reference data and signal data in coil dimensions (3) Demodulation along readout dimensions (4) Decimation along readout dimension (5) Phase correction with reference signal
Dimensions: [averages, coils, phase encoding, readout]
Reference signal is stored in the last entry of the coil dimension.
- Parameters:
parameter – Acquisition parameter
- run() AcquisitionData [source]#
Run an acquisition job.
- Raises:
RuntimeError – The measurement cards are not setup properly
ValueError – Missing raw data or missing averages
- set_sequence(sequence: str | Sequence) None [source]#
Set sequence and acquisition parameter.
- Parameters:
sequence – Path to pulseq sequence file.
parameter – Set of acquisition parameters which are required for the acquisition.
- Raises:
AttributeError – Invalid sequence provided.
FileNotFoundError – Invalid file ending of sequence file.
Acquisition Parameter#
Interface class for acquisition parameters.
- class console.interfaces.acquisition_parameter.AcquisitionParameter(larmor_frequency: float = 2000000.0, b1_scaling: float = 1.0, gradient_offset: Dimensions = Dimensions(x=0.0, y=0.0, z=0.0), fov_scaling: Dimensions = Dimensions(x=1.0, y=1.0, z=1.0), decimation: int = 200, ddc_method: DDCMethod = DDCMethod.FIR, num_averages: int = 1, averaging_delay: float = 0.0, default_state_file_path: str = '/home/runner/nexus-console/acquisition-parameter.state', save_on_mutation: bool = False)[source]#
Bases:
object
Parameters to define an acquisition.
The acquisition parameters are defined in a dataclass which is hashable but still mutable. This allows to easily change parameters and detect updates by comparing the hash.
New instances of acquisition parameters are not saved automatically. Once the autosave flag is set by calling activate_autosave, the parameter state is written to a pickle file acquisition-parameter.state in the default_state_file_path on any mutation of the acquisition parameter instance. The autosave option can be deactivated calling deactivate_autosave. Manually storing the acquisition parameters to a specific directory can be achieved using the save method and providing the desired path.
- averaging_delay: float = 0.0#
Delay in seconds between acquisition averages.
- b1_scaling: float = 1.0#
Scaling of the B1 field (RF transmit power).
- decimation: int = 200#
Decimation rate for initial down-sampling step.
- default_state_file_path: str = '/home/runner/nexus-console/acquisition-parameter.state'#
Default file path for acquisition parameter state.
- dict(use_strings: bool = False) dict [source]#
Return acquisition parameters as dictionary.
- Parameters:
use_strings – boolean flag indicating if values of dictionary should be represented as strings, by default False
optional – boolean flag indicating if values of dictionary should be represented as strings, by default False
- Return type:
Acquisition parameter dictionary
- fov_scaling: Dimensions = Dimensions(x=1.0, y=1.0, z=1.0)#
Field of view scaling for Gx, Gy and Gz.
- gradient_offset: Dimensions = Dimensions(x=0.0, y=0.0, z=0.0)#
Gradient offset values in mV.
- larmor_frequency: float = 2000000.0#
Larmor frequency in MHz.
- classmethod load(file_path: str) AcquisitionParameter [source]#
Load acquisition parameter state from state file in-place.
- Parameters:
file_path – Path to acquisition parameter state file. If file_path is not a pickle file, i.e. ends with .pkl, the default state file designation acquisition-parameter.state is added.
optional – Path to acquisition parameter state file. If file_path is not a pickle file, i.e. ends with .pkl, the default state file designation acquisition-parameter.state is added.
- Return type:
Instance of acquisition parameters with state loaded from provided file_path.
- Raises:
FileNotFoundError – Provided file_path is not a pickle file or does not exist.
- num_averages: int = 1#
Number of acquisition averages.
- save(file_path: str | None = None) None [source]#
Save current acquisition parameter state.
- Parameters:
file_path – Path to the pickle state file, by default None. If None, the default state file path is taken which is <home>/nexus-console/acquisition-parameter.state Default state file path can be changed using the set_default_path method.
optional – Path to the pickle state file, by default None. If None, the default state file path is taken which is <home>/nexus-console/acquisition-parameter.state Default state file path can be changed using the set_default_path method.
- save_on_mutation: bool = False#
Flag which indicates if state is saved on mutation.
The decimation method can be specified by the following enum definition and dimensions are defined by the subsequent dataclass.
Definition of enums.
- class console.interfaces.enums.DDCMethod(value)[source]#
Bases:
str
,Enum
Enum for DDC methods.
- AVG = 'moving-average-filter'#
- CIC = 'cascaded-integrator-comb-filter'#
- FIR = 'finite-impulse-response-filter'#
Interface class for dimensions.
Acquisition Data#
Interface class for acquisition data.
- class console.interfaces.acquisition_data.AcquisitionData(_raw: list[~numpy.ndarray], acquisition_parameters: ~console.interfaces.acquisition_parameter.AcquisitionParameter, sequence: ~console.pulseq_interpreter.sequence_provider.SequenceProvider | ~pypulseq.Sequence.sequence.Sequence, dwell_time: float, session_path: str, meta: dict[str, ~typing.Any] = <factory>, unprocessed_data: list[~numpy.ndarray] = <factory>, _additional_data: dict = <factory>)[source]#
Bases:
object
Parameters which define an acquisition.
- acquisition_parameters: AcquisitionParameter#
Acquisition parameters.
- add_data(data: dict[str, ndarray]) None [source]#
Add data to additional_data dictionary.
- Parameters:
data – Data which is to be added to acquisition data.
- add_info(info: dict[str, Any]) None [source]#
Add entries to meta data dictionary.
- Parameters:
info – Information as dictionary to be added.
- dwell_time: float#
Dwell time of down-sampled raw data in seconds.
- get_data(gate_index: int) ndarray [source]#
Get a single raw data array from raw data list.
During the acquisition, ADC gate events with different durations might occure. The data from the different ADC gate sizes is stored in separate arrays which are gathered in a list.
- Parameters:
gate_size_index – Index of the raw data array to be returned. Raw data from different ADC gate length are stored in separate arrays.
optional – Index of the raw data array to be returned. Raw data from different ADC gate length are stored in separate arrays.
- Return type:
Raw data array.
- meta: dict[str, Any]#
Meta data dictionary for additional acquisition info. Dictionary is updated (extended) by post-init method with some general information.
- property raw: ndarray#
Get the default raw data array.
- Return type:
Returns the first entry in raw data list.
- save(user_path: str | None = None, save_unprocessed: bool = False, overwrite: bool = False) None [source]#
Save all the acquisition data to a given data path.
- Parameters:
user_path – Optional user path, default is None. If provided, it is taken to store the acquisition data. Other wise a datetime-based folder is created.
save_unprocessed – Flag which indicates if unprocessed data is to be written or not, default is False.
overwrite – Flag which indicates whether the acquisition data should be overwritten in case it already exists from a previous call to this function, default is False.
- save_ismrmrd(header: ismrmrdHeader, user_path: str | None = None)[source]#
Store acquisition data in (ISMR)MRD format.
- sequence: SequenceProvider | Sequence#
Sequence object used for the acquisition acquisition.
- session_path: str#
Directory the acquisition data will be stored in. Within the given storage_path a new directory with time stamp and sequence name will be created.
- unprocessed_data: list[ndarray]#
Unprocessed real-valued MRI frequency (without demodulation, filtering, down-sampling). The first entry of the coil dimension also contains the reference signal (16th bit). The data array has the following dimensions: [averages, coils, phase encoding, readout]