regex_glob
- bidsaid.io.regex_glob(src_dir, pattern, recursive=False)[source]
Use regex to get content in the source directory with specific patterns.
Parameters
- src_dir
strorPath The source directory.
- pattern
str The regex pattern.
- recursive
bool, default=False If True, regex pattern is applied to content in the top-level directory (i.e., sub-101.log) and nested directories (i.e. logs/sub-101.log). If False, regex pattern is only applied to content in the top-level directory.
Yields
- Path
Paths in the directory whose names match
pattern.
Example
>>> from bidsaid.io import regex_glob >>> # Get any file ending in pdf or txt >>> regex_glob(r"path/to/directory", pattern=r"^.*.(pdf|txt)$")
- src_dir