3647

Python pulse sequence development kit for a fast MRI simulator
Ryoichi Kose1 and Katsumi Kose1
1MRIsimulations,Inc., Tokyo, Japan

Synopsis

A software tool that can efficiently describe MRI pulse sequences in Python has been developed for a fast MRI simulator. The essential part of this tool consists of application program interface (API) developed in C++, and any pulse sequence can be written by calling the API from a Python program. Using this tool, several pulse sequences including magnetic resonance fingerprinting were developed, and their usefulness was evaluated by performing MRI simulations for numerical phantoms. As a result, the tool developed in this study was shown to be very efficient in developing MRI pulse sequences.

Introduction

MRI vendors provide their own pulse sequence development environments using high level languages such as C and C ++, and these environments are widely used for pulse sequence developments in the MRI community. On the other hand, a pulse sequence development framework independent of MRI vender hardware has been proposed1. In 2017, we published a fast MRI simulator2 that operates exactly the same pulse sequence as some MRI systems. The pulse sequence format2-4 supported by the simulator had an advantage that it was very easy to develop pulse sequences, but there was a problem that it was very complicated to develop pulse sequences with many arbitrary RF and gradient waveforms. To solve this problem, we developed a software tool (Python pulse sequence development kit: PSDK) that can efficiently describe pulse sequences in Python. The usefulness of this tool was evaluated by MRI simulations using various pulse sequences.

Python pulse sequence development kit

Figure 1 shows the application program interface (API) that is the interface between Python and the MRI simulator developed in C++. It consist of “RF” for controlling RF pulses, “GX”, “GY”, and “GZ” for controlling gradient amplitudes with linear rise or fall, “GX.waveform”, “GY.waveform”, and “GZ.waveform” for controlling arbitrary gradient waveforms, “AD” for data acquisition, “WaitFor” and “WaitUntil” for sequence timing control. Since both scalar values and tuples can be used for the arguments of the API functions, flexible description of control structures is possible. Since all of the Python statements are used for the sequence description, various pulse sequences can be written with the small number of the API functions. To demonstrate the usefulness of the PSDK, MRI simulations were performed using numerical phantoms and the fast MRI simulator4 running on a graphical processing unit (GeForce GTX-1070 for laptop, NVIDIA, Santa Clara, CA).

Results

Figures 2-4 shows (a) pulse sequence codes written in Python, (b) pulse sequence blocks, and (c) simulation results for a 3D RF spoiled gradient-echo (GRE), a multi-slice fast spin-echo (FSE), and a 2D spiral imaging sequences. The Python code for the 3D RF spoiled GRE sequence consists of ‘Excitation’, ‘PhaseEncoding’, ‘Readout’, and ‘Rewinding’ blocks and a dual sequence loop with loop variables of ‘PE2’ and ‘PE1’ as described by Main(). The simulated result clearly shows 3D T1 weighted images. The Python code for the multi-slice FSE sequence consists of ‘Excitation’, ‘Slice_refocus’, ‘ReadPredephasing’, ‘Refocus’, ‘PhaseEncoding’, ‘Readout’, and ‘Rewinding’ blocks and a triple loop with loop variables of ‘PE1’ (Phase encoding), ‘SL’ (multiple slice), and ‘Echo’ (multiple echo) as described by Main(). The simulated result clearly shows multiple-slice T2 weighted images. The Python code for the spiral sequence consists of ‘Excitation’, ‘Slice_refocus’, and ‘Readout’ blocks and a single loop with a loop variable of ‘SHOT’ as described by Main(). In the ‘Readout’ block, the data acquisition was performed under the application of Gx and Gy field gradients described by the GX.waveform and GY.waveform API functions. The waveforms of the Gx and Gy gradients were those of the 48-shot variable density spiral trajectory designed by the formalism developed by Kim et al5. The waveforms were calculated beforehand and input from the “Gx.dbl” and “Gy.dbl” files. The simulated result clearly shows the spiral images as expected from the sequence parameters. Figure 5 shows (a) pulse sequence codes written in Python, (b) raw image data and T1, T2, and proton density (PD) images obtained from a dictionary matching, (c) matched T1 plotted against the designed T1, and (d) matched T2 plotted against the designed T2 for the magnetic resonance fingerprinting (MRF) sequence. The Python code for the MRF sequence consists of ‘Inversion’, ‘Excitation’, ‘Slice_refocus’, and ‘Readout’ blocks and a single loop with a loop variable of ‘SHOT’ as described by Main(). The variable TR and variable flip angle (FA) were calculated beforehand and input from “variable_TR.dbl” and “variable_FA.dbl” files. TR was changed between 15 and 20 ms and randomized using perlin noise. FA was sinusoidally changed between 0-200, 250-450, 500-700, and 750-950 shots of the 1,000 times spiral acquisition. In the MRF acquisition, the 48-shot spiral trajectories as used in Fig.4 were used and signal sampling was performed while increasing the trajectory rotation angle at intervals of 7 trajectories (52.5°) at each TR. Image reconstruction was performed for the seven consecutive datasets using the sliding window reconstruction technique. The PD, T1, and T2 images obtained from the dictionary matching demonstrate the correctness of the MRF sequence.

Discussion

By using the API developed in this study, we succeeded in describing the pulse sequence of 3D spoiled GRE, 2D multi-slice FSE, 2D spiral, and 2D MRF with as few as 50-90 Python statements. The largest advantage of our pulse sequence development tool is that the MRI pulse sequence can be written in the Python statements themselves, which is very different from the development tools published so far. This tool was developed for our MRI simulator, but if API is developed for a real MRI machine, the same pulse sequence can be used simultaneously for the real machine and the simulator. In conclusion, we succeeded in development of a software tool efficiently describing pulse sequences for a fast MRI simulator in Python statements and the API.

Acknowledgements

No acknowledgement found.

References

[1] Layton KJ, Kroboth S, Jia F, Littin S, Yu H, Leupold J, Nielsen JF, Stöcker T, Zaitsev M. Pulseq: a rapid and hardware-independent pulse sequence prototyping framework. Magn Reson Med 2017;77:1544–1552.

[2] Kose R, Kose K. BlochSolver: A GPU-optimized fast 3D MRI simulator for experimentally compatible pulse sequences. J Magn Reson 2017;281:51-65.

[3] Hashimoto S, Kose K, Haishi T. Development of a pulse programmer for magnetic resonance imaging using a personal computer and a high-speed digital input–output board, Rev. Sci. Instrum 2012;83:053702.

[4] Kose R, Setoi A, Kose K. A fast GPU-optimized 3D MRI simulator for arbitrary k-space sampling. Magn Reson Med Sci, 2019;18:208-218.

[5] Kim D, Adalsteinsson, Spielman DM. Simple analytic variable density spiral design. Magn Reson Med 2003;50:214–219.

Figures

Application program interface functions for the Python pulse sequence development kit. Parameters except ‘channels’ are written by float or tuple (list[float], list[str]). The units of time, pitch, and rise_time are µs. The units of phase and frequency are radian and kHz. The units of waveforms are µT for RF and mT/m for gradients. Channels are written by (list[int]).

(a) Python sequence code, (b) sequence block, and (c) simulated images for a 3D RF spoiled gradient echo sequence. The numerical phantom comprised nine cylindrical bottles filled with different relaxation-time materials and a right triangular block installed in a cylindrical container (diameter = 200 mm, height = 160mm). The parameters of the sequence were: TR/TE = 18ms/10ms, FA = 30°, phase offset angle = 117°, FOV = (256 mm)3, image matrix = 256 ×256 × 32. The number of subvoxels was 25 × 1 × 1. Simulation time was 50 min.

(a) Python sequence code, (b) sequence block, and (c) simulated images for a T2 weighted multi-slice fast spin-echo sequence.

(a) Python sequence code, (b) sequence block, and (c) simulated images for a 2D spiral sequence.

(a) Python sequence code, (b) raw image and T1, T2, proton density obtained by an MRF dictionary matching, (c) scatter plot for designed T1 and matched T1, and (d) scatter plot for designed T2 and matched T2 for the MR fingerprinting sequence.

Proc. Intl. Soc. Mag. Reson. Med. 28 (2020)
3647