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 atpathand each later one beside it as<stem>_<Name>.seq, where<Name>is the sequence’sNamedefinition, 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 itsNextSequencedefinition, 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:
path (str or pathlib.Path) – Where the first file of the chain is written.
result (pypulseqpp.Sequence or list of pypulseqpp.Sequence) – What a sequence function returns.
offline (bool, default=True) – Write signed text. False writes the binary form;
pypulseqpp.io.write()takes this the other way round, asbinary.
- Returns:
The written paths, in play order.
- Return type:
See also
pypulseqpp.io.read_chainRead 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']