Python scripts for Dynamic Mode Decomposition (DMD) based low-latency online reconstruction and self-gating routines for real-time 2D cardiac MR imaging.
Reference:
- E. Yagiz et al. "Dynamic Mode Decomposition enables low-latency high temporal resolution reconstruction for golden-angle spiral real-time MRI". Int. Society of Mag Res in Med (ISMRM) 2024. Singapore.
- E Yagiz et al. "Dynamic Mode Decomposition (DMD) Cardiac Phase Estimation for adult and fetal real-time MRI". Int. Society of Mag Res in Med (ISMRM) 2024. Singapore.
Clone repo
git clone https://github.com/usc-mrel/DMD-RT.git
Create a conda environment and activate it.
conda create env -f env.yml
conda activate pydmd_env
[Optional] For visualization, you can install pyArrView from repo. Follow the instructions there.
2 example datasets are shared here. Download these files into the DMD-RT folder.
- Adult (
example_gridded_adult.h5andexample_ref_adult.h5) - Fetal (
example_gridded_fetal.h5andexample_ref_fetal.h5)
Gridded data:
- Data collected at a prototype 0.55 T MRI scanner at USC.
- Acquisition for both datasets is GA spiral. The details can be found in the reference.
- Per frame, 8 arms are gridded (Non-uniform Fourier Transform applied) to obtain an undersampled image series. Again, the details can be seen in the reference.
- Dimensions: [Nx, Ny, Nf] number of spatial pixels in x-, y- directions and number of frames
Reference data:
- A spatiotemporally constrained reconstruction (STCR) is applied.
The relevant parameters for the scripts are read from the config.toml.
The parameters are listed in config.toml under lowlatency. Parameters are as follows:
data_path = ''-> Absolute path to the data.in_filename = 'example_gridded_adult.h5'-> Filename of the data.out_filename = 'out_lowlatency.h5'-> Output h5.ref_filename = 'example_ref_adult.h5'-> Filename of the reference dataf_th = 2-> Threshold Frequency [Hz] (3 Hz for fetal, 2 Hz for adult)res_flag = false-> Residual Flag (True/False), (True for fetal)alpha = 0.3-> Scalar for the residual part if res_flag. (can be tuned)gpu = 0-> device to use. -1 => CPU, 0, ... => GPU indexNbuff = 20-> Number of frames in the buffer. 20 is optimal for spiral GA
To run the low-latency script:
python lowlatency.py
This will use the GPU if the flag is set to >= 0 and the GPU index is valid. -1 will use CPU. The output will be saved as an h5 file with the given name.
If the pyArrView is installed, then the original input (gridded image series), low-latency reconstruction, and a reference reconstruction are displayed side by side.
The parameters are listed in config.toml under selfgating. Parameters are as follows:
data_path = ''-> Absolute path to the data.in_filename = 'example_ref_fetal.h5'-> Filename of the input datafrange = [1, 10]-> Frequency range for self-gating lower-upper. List of one is for upper th [Hz]Nbuff = 200-> Number of frames to process in the buffer. If > number of frames, set to number of framesgpu = 0-> device to use. -1 => CPU, 0, ... => GPU index
To run the self-gating script:
python selfgating.py
Outputs are estimated waveform and end-diastole, end-systole frames from the input data. The thresholds are not fully optimized, and the script hasn't been tested for undersampled fetal data.
- The code is tested on a server with an NVIDIA A100 GPU (40GB memory)—the required memory scales with the input image series. The shared example data is around 2GB.
- You are encouraged to modify/distribute this code. However, please acknowledge this code, cite the paper appropriately.
- This work is for research purposes and is a work in progress, so use it at your own risk.