write

write#

pypulseqpp.sequences.write()[source]#

Write a sequence, or a chain of sequences, as Pulseq files.

One sequence is written at path. A chain is a list of sequences played in order, prescans first and the main sequence last: the first is written at path and each later one beside it as <stem>_<Name>.seq, where <Name> is the sequence’s Name definition, or its position in the chain, counted from 0 at the first, when it has none. A later file whose name an earlier file has taken is written as <stem>_<Name>_<position>.seq, where <position> is its position in the chain, so every sequence has a file of its own. Each file but the last records the next file’s name as its NextSequence definition, so an interpreter plays the chain as one scan while every file stays one repeating unit. The definition is recorded in the file and not on the sequence.

Parameters:
Returns:

The written paths, in play order.

Return type:

list of str

See also

pypulseqpp.io.read_chain

Read the files of a chain in play order.

Examples

>>> import pathlib, tempfile
>>> import pypulseqpp as pp
>>> from pypulseqpp import sequences
>>> def one_delay(name):
...     seq = pp.Sequence(pp.Opts())
...     seq.add_block(pp.make_delay(1e-3))
...     seq.set_definition("Name", name)
...     return seq
>>> directory = pathlib.Path(tempfile.mkdtemp())
>>> written = sequences.write(
...     directory / "scan.seq", [one_delay("calibration"), one_delay("scan")]
... )
>>> [pathlib.Path(path).name for path in written]
['scan.seq', 'scan_scan.seq']
>>> [str(path.name) for path, _ in pp.io.read_chain(written[0])]
['scan.seq', 'scan_scan.seq']

Examples using write#

A sequence function

A sequence function