Skip to content

Commit cfb9e3f

Browse files
authored
Merge pull request #678 from mgxd/enh/collect-data-session
ENH: Add optional session filter when collecting data
2 parents 3d10143 + 620ce08 commit cfb9e3f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

niworkflows/utils/bids.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import re
2727
import warnings
2828
from bids import BIDSLayout
29+
from bids.layout import Query
2930
from packaging.version import Version
3031

3132

@@ -149,6 +150,7 @@ def collect_participants(
149150
def collect_data(
150151
bids_dir,
151152
participant_label,
153+
session_id=Query.OPTIONAL,
152154
task=None,
153155
echo=None,
154156
bids_validate=True,
@@ -161,6 +163,23 @@ def collect_data(
161163
162164
>>> data_dir_canary()
163165
166+
Parameters
167+
----------
168+
bids_dir : :obj:`str` or :obj:`bids.layout.BIDSLayout`
169+
The BIDS directory
170+
participant_label : :obj:`str`
171+
The participant identifier
172+
session_id : :obj:`str`, None, or :obj:`bids.layout.Query`
173+
The session identifier. By default, all sessions will be used.
174+
task : :obj:`str` or None
175+
The task identifier (for BOLD queries)
176+
echo : :obj:`int` or None
177+
The echo identifier (for BOLD queries)
178+
bids_validate : :obj:`bool`
179+
Whether the `bids_dir` is validated upon initialization
180+
bids_filters: :obj:`dict` or None
181+
Custom filters to alter default queries
182+
164183
Examples
165184
--------
166185
>>> bids_root, _ = collect_data(str(datadir / 'ds054'), '100185',
@@ -222,6 +241,7 @@ def collect_data(
222241
layout.get(
223242
return_type="file",
224243
subject=participant_label,
244+
session=session_id,
225245
extension=[".nii", ".nii.gz"],
226246
**query,
227247
)

0 commit comments

Comments
 (0)