PyPulseq: A Python Package for MRI Pulse Sequence Design

Magnetic Resonance Imaging (MRI) is a critical component of healthcare. MRI data is acquired by playing a series of radio-frequency and magnetic field gradient pulses. Designing these pulse sequences requires knowledge of specific programming environments depending on the vendor hardware (generations) and software (revisions) intended for implementation. This impedes the pace of prototyping. Pulseq


Statement of need
MRI is a non-invasive diagnostic imaging tool.It is a critical component of healthcare and has a significant impact on diagnosis and treatment assessment.Structural, functional and metabolic MRI generate valuable information that aid in the accurate diagnosis of a wide range of pathologies.A unique strength of MRI is the ability to visualise diverse pathologies achieved by the flexibility in designing tailored pulse sequences.MRI pulse sequences are a collection of radio-frequency and gradient waveforms that are executed on the scanner hardware to acquire raw data.
Research efforts on pulse sequence design are directed at achieving faster scan times, improving tissue contrast and increasing Signal-to-Noise Ratio (SNR).However, designing pulse sequences requires knowledge of specific programming environments depending on the vendor hardware (generations) and software (revisions) intended for implementation.Typically, MRI researchers program and simulate the pulse sequences on computers and execute them on MRI scanners.This typically involves considerable effort, impeding the pace of prototyping and therefore research and development.This also hampers multi-site multi-vendor studies as it requires researchers to be acquainted with each vendor's programming environment.Furthermore, harmonizing acquisition across MRI vendors will enable reproducible research.This work introduces an open source tool that enables pulse sequence programming for Siemens/GE/Bruker platforms in Python, based on the Pulseq standard (Layton et al., 2017).

Introduction to the Pulseq file format: .seq
The .seq file format introduced in Pulseq (Layton et al., 2017) is a novel way to capture a pulse sequence as plain text.The file format was designed with the following design criteria in mind: human-readable, easily parsable, vendor independent, compact and low-level (Layton et al., 2017).A pulse sequence comprises of radiofrequency pulses, magnetic field gradient waveforms, delays or analog-to-digital converter (ADC) readout events.A block comprises of one or more events occurring simultaneously.Event envelopes are defined by shapes, which are run-length encoded and stored in the .seqfile.In a .seqfile, each event and shape is identified uniquely by an integer.Blocks are constructed by assembling the uniquely referenced events.Therefore, any custom pulse sequence can be synthesised by concatenating blocks.

About PyPulseq
The PyPulseq package presented in this work is an open source vendor-neutral MRI pulse sequence design tool.It enables researchers and users to program pulse sequences in Python, and export them as a .seqfile.These .seqfiles can be executed on the three MRI vendors by leveraging vendor-specific interpreters.The MRI methods have been reported previously (Ravi, Potdar, et al., 2018).The PyPulseq package allows for both representing and deploying custom sequences.This work focuses on the software aspect of the tool.PyPulseq was entirely developed in Python, and this has multiple advantages.Firstly, unlike existing C++ frameworks such as ODIN (Jochimsen & Von Mengershausen, 2004) and SequenceTree (Magland, Li, Langham, & Wehrli, 2016), PyPulseq does not require any compilation of the pulse sequence scripts.Secondly, it does not involve any licensing fees that are otherwise associated with other scientific research platforms such as MATLAB.Thirdly, there has been a proliferation of deep learning projects developed in Python in recent years.These advantages allow PyPulseq to be integrated with projects related to various stages of the MRI pipeline.For example -deep learning techniques for acquisition (intelligent slice planning in Ravi et al. (2018a)) and related downstream reconstruction.Finally, the standard Python package manager -PyPI -enables convenient installs on multiple OS platforms.These Python-derived benefits ensure that PyPulseq can reach a wider audience.
We have leveraged the PyPulseq library to implement acquisition oriented components of the Autonomous MRI (AMRI) package (Ravi et al., 2018a(Ravi et al., , 2019a(Ravi et al., , 2019b)), Virtual Scanner (Tong et al., 2019), and the non-Cartesian acquisition library (Ravi et al., 2018b).Also, the PyPulseq-gpi branch integrates a previous version of PyPulseq with GPI to enable GUI-based pulse sequence design.This work has been previously reported (Ravi, Potdar, et al., 2018) and is not within the scope of this JOSS submission.Currently, PyPulseq does not support external triggers and interactive slice planning.Raw data acquired with pulse sequences designed with PyPulseq cannot be reconstructed vendor-supplied tools.PyPulseq is a translation of Pulseq from MATLAB (Layton et al., 2017).

Target audience
PyPulseq is aimed at MRI researchers focusing on pulse sequence design, image reconstruction, and MRI physics.We also envisage PyPulseq to be utilized for replicability and reproducibility studies such as those for functional MRI (multi-site, multi-vendor).The package could also serve as a hands-on teaching aid for MRI faculty and students.Beginners can get started with the bundled example pulse sequences.More familiar users can import the appropriate packages to construct and deploy custom pulse sequences.