Keywords: Software Tools, Software Tools, Extended Phase Graphs
Motivation: Most existing MR simulators either focus on the implementation of multiple physical phenomena or on massive parallelization, but these two aspects are usually not tackled simultaneously.
Goal(s): To provide a feature-rich, massively parallelized and differentiable MR simulator.
Approach: We built on the Extended Phase Graphs formalism to efficiently simulate all the main MR physical phenomena. We used PyTorch as a backend to enable massive parallelization and efficient differentiation.
Results: Our toolbox, demonstrated on a numerical Fast Spin Echo experiment on an exchanging two-pool system, achieved order of magnitude speed-up compared to existing implementations and efficient differentiation with minimal boilerplate.
Impact: Torch-EPG-X will represent a useful tool for synthetic signal generation for deep learning, parameter fitting, model-based reconstruction and sequence optimization.
This work was partially funded by the INFN-CSN5 PREDATOR project (“Grant Giovani”). Support from the Italian Ministry of Health under the grant RC 2022 and “5 per mille” to IRCCS Fondazione Stella Maris.
1. Malik SJ, Teixeira RPAG, Hajnal JV. Extended phase graph formalism for systems with magnetization transfer and exchange. Magn Reson Med. 2018;80(2):767-779. doi:10.1002/mrm.27040
2. Lamy J, de Sousa de S Paulo Loureiro. Sycomore: an MRI simulation toolkit. In: ; 2020:1038. https://archive.ismrm.org/2020/1038.html
3. Rakshit S, Wang K, Tamir JI. A GPU-accelerated Extended Phase Graph Algorithm for differentiable optimization and learning. In: ; 2021:3754. https://cds.ismrm.org/protected/21MPresentations/abstracts/3754.html
4. Wang G, Shah N, Zhu K, Noll DC, Fessler JA. MIRTorch: A PyTorch-powered Differentiable Toolbox for Fast Image Reconstruction and Scan Protocol Optimization. In: ; 2021:4982. Accessed November 7, 2023. https://archive.ismrm.org/2022/4982.html
5. Tamir JI, Yu SX, Lustig M. DeepInPy: Deep Inverse Problems in Python. In: ; 2020.
6. Weigel M. Extended phase graphs: Dephasing, RF pulses, and echoes - pure and simple. J Magn Reson Imaging. 2015;41(2):266-295. doi:https://doi.org/10.1002/jmri.24619
7. Tamir JI, Uecker M, Chen W, et al. T2 shuffling: Sharp, multicontrast, volumetric fast spin-echo imaging. Magn Reson Med. 2017;77(1):180-195. doi:10.1002/mrm.26102
8. Jiang Y, Ma D, Seiberlich N, Gulani V, Griswold MA. MR fingerprinting using fast imaging with steady state precession (FISP) with spiral readout. Magn Reson Med. 2015;74(6):1621-1631. doi:10.1002/mrm.25559
9. Ma D, Gulani V, Seiberlich N, et al. Magnetic resonance fingerprinting. Nature. 2013;495(7440):187-192. doi:10.1038/nature11971
10. Lee PK, Watkins LE, Anderson TI, Buonincontri G, Hargreaves BA. Flexible and efficient optimization of quantitative sequences using automatic differentiation of Bloch simulations. Magn Reson Med. 2019;82(4):1438-1451. doi:10.1002/mrm.27832
11. Li S, Kang T, Wu J, et al. Sub-second whole brain T2 mapping via multiband SENSE multiple overlapping-echo detachment imaging and deep learning. Phys Med Biol. 2023;68(19):195027. doi:10.1088/1361-6560/acfb71
12. Nataraj G, Nielsen JF, Scott C, Fessler JA. Dictionary-Free MRI PERK: Parameter Estimation via Regression with Kernels. IEEE Trans Med Imaging. 2018;37(9):2103-2114. doi:10.1109/TMI.2018.2817547
13. Heo J, Song P, Liu W, Weller A. Physics-Based Decoding Improves Magnetic Resonance Fingerprinting. In: Greenspan H, Madabhushi A, Mousavi P, et al., eds. Medical Image Computing and Computer Assisted Intervention – MICCAI 2023. Lecture Notes in Computer Science. Springer Nature Switzerland; 2023:446-456. doi:10.1007/978-3-031-43895-0_42
Figure 1 Main sub-packages of Torch-EPG-X. The sub-packages have different levels of abstraction to enable creation of simulators for different sequences with minimal boilerplate while maintaining high customizability for specific applications. All the packages are based on PyTorch 2.1 to enable GPU offload and efficient forward automatic differentiation of generated signals.
Figure 2 Code snippet for the generation of a SSFP-MR Fingerprinting simulator. Panel a) shows the core simulation engine. By defining the simulator as a subclass of epgtorchx.base.BaseSimulator, automatic parallelization and differentiation wrt to tissue parameters are automatically enabled with minimal boilerplate. Panel b) shows a minimal wrapper to instantiate the simulator, run the simulation and return the signals and corresponding derivatives.
Figure 3 Main features of the Torch-EPG-X package. Our toolbox includes both all the main MR physical phenomena and supports massive parallelization and automatic differentiation. By contrast, most available packages either focus on one of these aspects.
Figure 4 Validation and benchmark of Torch-EPG-X with an FSE simulation assuming constant refocusing pulse train (a) and acting on a two-pool spin system (T1: 1000/500ms, T2: 100/20ms, relative fraction: 0.2). Results (b) were identical to the reference implementation both without and with exchange (non-directional exchange rate: 10Hz). Our package also demonstrates high computational efficiency on GPU and CPU both without (c) and with exchange (d).
Figure 5 Validation and benchmark of Torch-EPG-X automatic differentiation capability with an FSE simulation assuming variable refocusing pulse train (a). Both the signal derivative with respect to T2 (b) and the CRLB objective gradient with respect to refocusing angles (c) showed good consistency with the finite-difference implementation, with some differences due to the numerical instability of the latter. Good computational efficiency was achieved, especially for the gradient of CRLB objective (d).