extract_sequence_from_filepath#
- extract_sequence_from_filepath(ifile, default=None)[source]#
Extract the sequence number from a filename stem.
Searches for the first occurrence of a 3- or 6-digit decimal run in the stem. The match is not anchored to a particular position so it works for both the strict MAS schema (
br001001.h5) and looser naming conventions.- Parameters:
- Returns:
Examples
>>> from pathlib import Path >>> from psi_io.mhd_io 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