read_chain#
- pypulseqpp.io.read_chain()[source]#
Read a sequence file and every file its
NextSequencedefinitions name, in play order.pypulseqpp.sequences.SequenceApp.write()writes a scan with prescans as such a chain. ANextSequencename is relative to the directory of the file naming it. Each file is read byread(), 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:
- Raises:
FileNotFoundError – If a file of the chain does not exist.
ValueError – If the chain names a file it has already played.
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']