Skip to content

Commit 9b69f75

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1458d15 commit 9b69f75

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

mne_bids/path.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,8 @@ def match(self, *, ignore_json=True, ignore_nosub=False, check=False):
11051105
datatype=self.datatype,
11061106
ignore_json=ignore_json,
11071107
ignore_nosub=ignore_nosub,
1108-
entities=self.entities
1109-
)
1108+
entities=self.entities,
1109+
)
11101110

11111111
fnames = _filter_fnames(
11121112
paths, suffix=self.suffix, extension=self.extension, **self.entities
@@ -2543,7 +2543,9 @@ def find_matching_paths(
25432543
return bids_paths
25442544

25452545

2546-
def _return_root_paths(root, datatype=None, ignore_json=True, ignore_nosub=False, entities=None):
2546+
def _return_root_paths(
2547+
root, datatype=None, ignore_json=True, ignore_nosub=False, entities=None
2548+
):
25472549
"""Return all file paths + .ds paths in root with entity-aware optimization.
25482550
25492551
Can be filtered by datatype (which is present in the path but not in
@@ -2573,14 +2575,14 @@ def _return_root_paths(root, datatype=None, ignore_json=True, ignore_nosub=False
25732575
root = Path(root) # if root is str
25742576

25752577
# OPTIMIZATION: Use entity-aware path construction when entities available
2576-
if entities and entities.get('subject'):
2578+
if entities and entities.get("subject"):
25772579
# Build targeted search path starting from subject directory
25782580
search_parts = [f"sub-{entities['subject']}"]
2579-
2581+
25802582
# Add session if available
2581-
if entities.get('session'):
2583+
if entities.get("session"):
25822584
search_parts.append(f"ses-{entities['session']}")
2583-
2585+
25842586
# Add datatype-specific path
25852587
if datatype is not None:
25862588
datatype = _ensure_tuple(datatype)
@@ -2594,22 +2596,26 @@ def _return_root_paths(root, datatype=None, ignore_json=True, ignore_nosub=False
25942596
for dt in datatype:
25952597
dt_search_parts = search_parts + ["**", dt]
25962598
dt_search_str = "/".join(dt_search_parts) + "/*.*"
2597-
paths.extend([
2598-
Path(root, fn)
2599-
for fn in glob.iglob(dt_search_str, root_dir=root, recursive=True)
2600-
])
2599+
paths.extend(
2600+
[
2601+
Path(root, fn)
2602+
for fn in glob.iglob(
2603+
dt_search_str, root_dir=root, recursive=True
2604+
)
2605+
]
2606+
)
26012607
return _filter_paths_optimized(paths, ignore_json)
26022608
else:
26032609
# No datatype specified - search all datatypes under subject
26042610
search_parts.append("**")
26052611
search_str = "/".join(search_parts) + "/*.*"
2606-
2612+
26072613
# Single search with optimized path
26082614
paths = [
26092615
Path(root, fn)
26102616
for fn in glob.iglob(search_str, root_dir=root, recursive=True)
26112617
]
2612-
2618+
26132619
else:
26142620
# FALLBACK: Original implementation when entities not available or subject unknown
26152621
if datatype is None and not ignore_nosub:
@@ -2702,4 +2708,3 @@ def _fnames_to_bidspaths(fnames, root, check=False):
27022708

27032709
bids_paths.append(bids_path)
27042710
return bids_paths
2705-

0 commit comments

Comments
 (0)