seq2mrd builds ISMRMRD acquisitions from a pulseq .seq file and enriches them with vendor raw data.
The package is designed around an in-memory workflow:
- pulseq defines the acquisition structure
- vendor raw data provides samples and scanner metadata
- the result can be used directly in Python or written to an
.mrdfile
The current implementation is Siemens-first.
- Siemens Twix input is implemented
- NumPy
.npyinput is implemented for simple in-memory style raw data - Bruker and GE entry points exist, but currently raise
NotImplementedError
The conversion is split into two steps.
MRDSkeleton.from_seq(...) reads the .seq file and creates:
- an ISMRMRD header
- one acquisition per ADC event
- embedded trajectory samples in each acquisition
- indices from pulseq labels when available
This step uses pulseq as the source of truth for:
- acquisition count and order
- trajectory
- encoding and reconstruction geometry
- sequence parameters such as
TR,TE, andTI
Vendor-specific RawSource implementations enrich the skeleton with:
- complex raw k-space samples
- acquisition timestamps
- orientation and position
- table position
- study and system metadata when available
For Siemens, this is done with:
from seq2mrd import MRDSkeleton, SiemensRaw
skeleton = MRDSkeleton.from_seq('sequence.seq')
skeleton = SiemensRaw('meas.dat')(skeleton)For simple raw data stored as a NumPy array, use:
from seq2mrd import MRDSkeleton, NumpyRaw
skeleton = MRDSkeleton.from_seq('sequence.seq')
skeleton = NumpyRaw('raw.npy')(skeleton)The .npy file is expected to contain a complex array with shape (n_adcs, n_coils, n_readout).
The pulseq path currently reads these definitions when present:
FOVReconFOVEncodingMatrixReconMatrixTRTETIReadoutOversamplingFactorTrajectoryType
Fallbacks are used when optional definitions are missing:
ReconFOVfalls back toFOVEncodingMatrixfalls back to ADC and label heuristicsReconMatrixfalls back to encoding-matrix heuristics- if no pulseq labels are present,
LINis generated within ADC-frequency classes and the class ID is stored inuser_int[7]
The simplest interface returns parsed ISMRMRD objects directly:
from seq2mrd import convert_siemens
header, acquisitions = convert_siemens('sequence.seq', 'meas.dat')For NumPy raw input:
from seq2mrd import convert_numpy
header, acquisitions = convert_numpy('sequence.seq', 'raw.npy')This can be passed directly into MRpro or mr2:
from mrpro.data import KData
from mrpro.data.traj_calculators import KTrajectoryIsmrmrd
from seq2mrd import convert_siemens
header, acquisitions = convert_siemens('sequence.seq', 'meas.dat')
kdata = KData.from_ismrmrd(header, acquisitions, trajectory=KTrajectoryIsmrmrd())The mr2 integration path is still work in progress and is not yet merged upstream.
If you want to work with the intermediate in-memory representation:
from seq2mrd import MRDSkeleton, SiemensRaw
skeleton = MRDSkeleton.from_seq('sequence.seq')
skeleton = SiemensRaw('meas.dat')(skeleton)
header = skeleton.header
acquisitions = skeleton.acquisitionsMRDSkeleton can also be written to disk:
from seq2mrd import MRDSkeleton, SiemensRaw
skeleton = SiemensRaw('meas.dat')(MRDSkeleton.from_seq('sequence.seq'))
skeleton.write('output.mrd')After installation, the package provides a seq2mrd command.
seq2mrd siemens --seq sequence.seq --raw meas.dat --output output.mrdseq2mrd numpy --seq sequence.seq --raw raw.npy --output output.mrdseq2mrd siemens --seq sequence.seq --raw meas.dat --output output.mrd --dataset-name dataset_2The CLI writes an ISMRMRD file and uses the same conversion path as the Python API.
Install the package with pip:
pip install git+https://github.com/fzimmermann89/seq2mrd.gitThe command-line entry point is installed as part of the package.