Skip to content

IO

CMRseq has JSON helpers for serializing sequence objects and Pulseq support through cmrseq.io.PulseSeqFile.

Pulseq

PulseSeqFile reads existing .seq files or converts a Sequence into Pulseq tables.

from cmrseq.io import PulseSeqFile

pulseq_file = PulseSeqFile(sequence=sequence, version="1.5.0")
pulseq_file.write("sequence.seq")

loaded = PulseSeqFile(file_path="sequence.seq")
sequence_list = loaded.to_cmrseq(system_specs)

Export defaults to Pulseq 1.5.0. Use version="1.4.0" when a downstream tool still expects the older RF and ADC table layout.

Recent writer behavior:

  • RF events always write explicit RF time shapes instead of using time_shape_id = 0.
  • Pulseq 1.5.0 RF rows include center, frequency/phase PPM placeholders, and the RF use field.
  • RF dead time is handled at the start of RF blocks; ADC dead time is handled on both sides of ADC blocks when block borders are assembled.
  • Label counters attached to RF or ADC blocks are emitted as Pulseq label extensions.
  • triggerWait and triggerSend labels are emitted as Pulseq trigger extensions. Trigger extensions are placed in dedicated delay blocks so their duration is represented explicitly.

The test suite validates generated files with pypulseq. When modern pypulseq rewrites older Pulseq 1.4.0 RF files, tests use its v1.4 compatibility mode so missing RF use metadata is not misinterpreted as a writer failure.

JSON

cmrseq.io.sequence_to_json and cmrseq.io.sequence_from_json serialize CMRseq sequence objects. Use JSON for CMRseq round trips and Pulseq for exchange with Pulseq-compatible tools.