Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add optional session filter when collecting data #678

Merged
merged 3 commits into from
Mar 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions niworkflows/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import re
import warnings
from bids import BIDSLayout
from bids.layout import Query
from packaging.version import Version


Expand Down Expand Up @@ -149,6 +150,7 @@ def collect_participants(
def collect_data(
bids_dir,
participant_label,
session_id=Query.OPTIONAL,
task=None,
echo=None,
bids_validate=True,
Expand All @@ -161,6 +163,23 @@ def collect_data(

>>> data_dir_canary()

Parameters
----------
bids_dir : :obj:`str` or :obj:`bids.layout.BIDSLayout`
The BIDS directory
participant_label : :obj:`str`
The participant identifier
session_id : :obj:`str`, None, or :obj:`bids.layout.Query`
The session identifier. By default, all sessions will be used.
task : :obj:`str` or None
The task identifier (for BOLD queries)
echo : :obj:`int` or None
The echo identifier (for BOLD queries)
bids_validate : :obj:`bool`
Whether the `bids_dir` is validated upon initialization
bids_filters: :obj:`dict` or None
Custom filters to alter default queries

Examples
--------
>>> bids_root, _ = collect_data(str(datadir / 'ds054'), '100185',
Expand Down Expand Up @@ -222,6 +241,7 @@ def collect_data(
layout.get(
return_type="file",
subject=participant_label,
session=session_id,
effigies marked this conversation as resolved.
Show resolved Hide resolved
extension=[".nii", ".nii.gz"],
**query,
)
Expand Down