run#
- pypulseqpp.cli.run()[source]#
Run a sequence script’s
mainfrom the command line.Every keyword parameter of
mainannotated with a scalar becomes an option, described by whatmain’s own docstring says about it. Five names are answered here instead:plot,test_report,write_seqandseq_filename, which are the calling convention rather than the prescription, andsystem, which is built from the limit options.- Parameters:
main (callable) – The script’s entry point. Returns the sequence.
argv (list of str, default=None) – The arguments, without the program name.
sys.argv[1:]when omitted.description (str, default=None) – What
--helpsays the script does. The first line ofmain’s docstring when omitted.default_output (str, default='sequence.seq') – Where to write when
--outputis not given.
- Returns:
The exit status: zero when the sequence was written.
- Return type:
Notes
The sequence
mainreturns is written to--outputwithpypulseqpp.io.write(), in binary form under--binary. Themainof aSequenceAppsubclass instead writes the application’s chain of prescan and main-sequence files throughwrite().Examples
>>> import pypulseqpp as pp >>> from pypulseqpp.cli import run >>> def main(write_seq: bool = False, seq_filename: str = "x.seq", ... *, n_x: int = 128, tr: float | None = None) -> pp.Sequence: ... '''One line. ... ... Parameters ... ---------- ... n_x : int, optional ... Readout samples. ... tr : float or None, optional ... Repetition time, in seconds. ... ''' ... return pp.Sequence()
The options are the function’s parameters, described by its docstring:
>>> import contextlib, io >>> text = io.StringIO() >>> with contextlib.redirect_stdout(text), contextlib.suppress(SystemExit): ... run(main, ["--help"]) >>> "--n-x" in text.getvalue(), "Readout samples." in text.getvalue() (True, True)