Skip to content

Commit 6b80704

Browse files
authored
Merge pull request #496 from dbic/bf-noderivativesetc
ENH+BF: find_files to take list of topdirs, look for _bold only under sub-* directories
2 parents 6734d48 + 2e1e1d3 commit 6b80704

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

heudiconv/bids.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def populate_aggregated_jsons(path):
114114
# way too many -- let's just collect all which are the same!
115115
# FIELDS_TO_TRACK = {'RepetitionTime', 'FlipAngle', 'EchoTime',
116116
# 'Manufacturer', 'SliceTiming', ''}
117-
for fpath in find_files('.*_task-.*\_bold\.json', topdir=path,
117+
for fpath in find_files('.*_task-.*\_bold\.json',
118+
topdir=glob(op.join(path, 'sub-*')),
118119
exclude_vcs=True,
119120
exclude="/\.(datalad|heudiconv)/"):
120121
#

heudiconv/parser.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
_VCS_REGEX = '%s\.(?:git|gitattributes|svn|bzr|hg)(?:%s|$)' % (op.sep, op.sep)
2626

27+
2728
@docstring_parameter(_VCS_REGEX)
2829
def find_files(regex, topdir=op.curdir, exclude=None,
2930
exclude_vcs=True, dirs=False):
@@ -36,12 +37,16 @@ def find_files(regex, topdir=op.curdir, exclude=None,
3637
exclude_vcs:
3738
If True, excludes commonly known VCS subdirectories. If string, used
3839
as regex to exclude those files (regex: `{}`)
39-
topdir: basestring, optional
40+
topdir: basestring or list, optional
4041
Directory where to search
4142
dirs: bool, optional
4243
Either to match directories as well as files
4344
"""
44-
45+
if isinstance(topdir, (list, tuple)):
46+
for topdir_ in topdir:
47+
yield from find_files(
48+
regex, topdir=topdir_, exclude=exclude, exclude_vcs=exclude_vcs, dirs=dirs)
49+
return
4550
for dirpath, dirnames, filenames in os.walk(topdir):
4651
names = (dirnames + filenames) if dirs else filenames
4752
paths = (op.join(dirpath, name) for name in names)

0 commit comments

Comments
 (0)