extract_sequence_from_filepath#
- extract_sequence_from_filepath(ifile, default=None)[source]#
Extract the sequence number from a filename stem.
Searches for the first 3- or 6-digit decimal token in the stem that is not immediately preceded or followed by another digit. A 6-digit run is always preferred over a 3-digit run at the same position.
- Parameters:
- Returns:
See also
extract_quantity_from_filepathExtract the quantity name from a filepath stem.
parse_psi_filename_schemaStrict parser requiring both quantity and sequence.
Examples
>>> from pathlib import Path >>> from psi_io.models import extract_sequence_from_filepath >>> extract_sequence_from_filepath(Path('br001001.h5')) 1001 >>> extract_sequence_from_filepath(Path('vr001.h5')) 1 >>> extract_sequence_from_filepath(Path('nosequence.h5')) is None True