read_chain

Contents

read_chain#

pypulseqpp.io.read_chain()[source]#

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

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

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

  • detect_rf_use (bool, default=False) – Assign a use to each unlabelled RF event of every file, as read() does.

  • 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']