Skip to content

Commit 830c7f1

Browse files
committed
Work around the weird multiple-match behavior of path.match()
1 parent a474c5b commit 830c7f1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mne_bids/path.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ def _find_empty_room_candidates(bids_path):
6969
del allowed_extensions[allowed_extensions.index(".pdf")]
7070

7171
# Get possible noise task files in the same directory as the recording.
72-
noisetask_fns = [
72+
noisetask_tmp = [
7373
candidate
7474
for candidate in noisetask_path.match()
7575
if candidate.extension in allowed_extensions
7676
]
77+
# For some reason a single file can produce multiple hits in the match function. Remove dups
78+
noisetask_fns = []
79+
for i in range(len(noisetask_tmp)):
80+
fn = noisetask_tmp.pop()
81+
if not any(fn.fpath == f.fpath for f in noisetask_fns):
82+
noisetask_fns.append(fn)
83+
7784

7885
# If we have more than one noise task file, we need to disambiguate.
7986
# It might be that it's a
@@ -95,9 +102,10 @@ def _find_empty_room_candidates(bids_path):
95102
)
96103
warn(msg)
97104
noisetask_fns = []
98-
else:
105+
elif len(noisetask_fns) == 1:
99106
return noisetask_fns[0]
100107

108+
101109
if not emptyroom_dir.exists() and not noisetask_fns:
102110
return list()
103111

0 commit comments

Comments
 (0)