parse_filenames

tifffile.parse_filenames(files, /, pattern=None, axesorder=None, categories=None, *, _shape=None)

Return shape and axes from sequence of file names matching pattern.

Parameters:
  • files (Sequence[str]) – Sequence of file names to parse.

  • pattern (str | None) – Regular expression pattern matching axes names and chunk indices in file names. By default, no pattern matching is performed. Axes names can be specified by matching groups preceding the index groups in the file name, be provided as group names for the index groups, or be omitted. The predefined ‘axes’ pattern matches Olympus OIF and Leica TIFF series.

  • axesorder (Sequence[int] | None) – Indices of axes in pattern. By default, axes are returned in the order they appear in pattern.

  • categories (dict[str, dict[str, int]] | None) – Map of index group matches to integer indices. {‘axislabel’: {‘category’: index}}

  • _shape (Sequence[int] | None) – Shape of file sequence. The default is maximum - minimum + 1 of the parsed indices for each dimension.

Returns:

  • Axes names for each dimension.

  • Shape of file series.

  • Index of each file in shape.

  • Filtered sequence of file names.

Return type:

tuple[tuple[str, …], tuple[int, …], list[tuple[int, …]], Sequence[str]]

Examples

>>> parse_filenames(
...     ['c1001.ext', 'c2002.ext'], r'([^\d])(\d)(?P<t>\d+)\.ext'
... )
(('c', 't'), (2, 2), [(0, 0), (1, 1)], ['c1001.ext', 'c2002.ext'])