Sequence.write

Contents

Sequence.write#

Sequence.write()[source]#

Write the sequence as a Pulseq text file, 1.5.1 by default.

signature_type, signature_file and signature_value record the signature written.

Parameters:
  • name (str | os.PathLike[str]) – Where to write it.

  • create_signature (bool, default=True) – Append an MD5 signature of the file’s contents.

  • remove_duplicates (bool, default=True) – Write a copy with identical library rows collapsed; this sequence’s libraries are unchanged.

  • check_timing (bool, default=False) – Run check_timing() first and warn if it finds anything.

  • v141_compat (bool, default=False) – Write Pulseq 1.4.1 as write_v141() does.

Returns:

The signature written, or None if the file is unsigned. With remove_duplicates it is that of the collapsed copy.

Return type:

str | None

Warns:

UserWarning – If check_timing is set and the timing check finds anything.

Examples

>>> import pathlib, tempfile
>>> import pypulseqpp as pp
>>> folder = tempfile.mkdtemp()
>>> seq = pp.Sequence(pp.Opts())
>>> seq.add_block(pp.make_trapezoid("x", area=1000, duration=2e-3))
1
>>> signature = seq.write(pathlib.Path(folder) / "gre.seq")
>>> len(signature), seq.signature_type, seq.signature_file
(32, 'md5', 'text')