read_chain

Contents

read_chain#

pypulseqpp.io.read_chain()[source]#

Read a sequence file and every file its NextSequence definitions name, in play order.

pypulseqpp.sequences.SequenceApp.write() writes a scan with prescans as such a chain. A NextSequence name is relative to the directory of the file naming it. Each file is read by read(), onto a system built from it.

Parameters:
  • file_path (str | os.PathLike[str]) – The first file of the chain.

  • detect_rf_use (bool, default=False) – Work out what each unlabelled pulse of every file is for, as read() does. A file whose pulses all record their use is read as it is.

  • remove_duplicates (bool, default=True) – Collapse identical library rows of every file after reading.

  • verify (bool, default=False) – Check every file against the signature it carries.

Returns:

Each file’s path, joined as the chain names it, and its sequence.

Return type:

list of (pathlib.Path, pypulseqpp.Sequence)

Raises:

Examples

>>> import pathlib, tempfile
>>> import pypulseqpp as pp
>>> directory = pathlib.Path(tempfile.mkdtemp())
>>> for name, following in (("scan.seq", "scan_main.seq"), ("scan_main.seq", "")):
...     seq = pp.Sequence(pp.Opts())
...     _ = seq.add_block(pp.make_delay(1e-3))
...     if following:
...         seq.set_definition("NextSequence", following)
...     _ = pp.io.write(seq, directory / name)
>>> [path.name for path, _ in pp.io.read_chain(directory / "scan.seq")]
['scan.seq', 'scan_main.seq']