Skip to content

Commit

Permalink
Use unique_labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Mar 29, 2024
1 parent e6b973b commit 042a67b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
8 changes: 1 addition & 7 deletions fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,10 @@ def main():

from fmriprep.reports.core import generate_reports

# Generate reports phase
session_list = (
config.execution.get().get('bids_filters', {}).get('bold', {}).get('session')
)

failed_reports = generate_reports(
config.execution.participant_label,
config.execution.unique_labels,
config.execution.fmriprep_dir,
config.execution.run_uuid,
session_list=session_list,
)
write_derivative_description(
config.execution.bids_dir,
Expand Down
22 changes: 7 additions & 15 deletions fmriprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,17 @@ def build_workflow(config_file, retval):
desc_content = dset_desc_path.read_bytes()
config.execution.bids_description_hash = sha256(desc_content).hexdigest()

# First check that bids_dir looks like a BIDS folder
subject_list = collect_participants(
config.execution.layout, participant_label=config.execution.participant_label
)

# Called with reports only
if config.execution.reports_only:
build_log.log(25, 'Running --reports-only on participants %s', ', '.join(subject_list))
session_list = (
config.execution.bids_filters.get('bold', {}).get('session')
if config.execution.bids_filters
else None
build_log.log(
25,
'Running --reports-only on participants %s',
', '.join(config.execution.unique_labels),
)

failed_reports = generate_reports(
config.execution.participant_label,
config.execution.unique_labels,
config.execution.fmriprep_dir,
config.execution.run_uuid,
session_list=session_list,
)
if failed_reports:
config.loggers.cli.error(
Expand All @@ -110,7 +102,7 @@ def build_workflow(config_file, retval):
init_msg = [
"Building fMRIPrep's workflow:",
f'BIDS dataset path: {config.execution.bids_dir}.',
f'Participant list: {subject_list}.',
f'Participant list: {config.execution.unique_labels}.',
f'Run identifier: {config.execution.run_uuid}.',
f'Output spaces: {config.execution.output_spaces}.',
]
Expand All @@ -123,7 +115,7 @@ def build_workflow(config_file, retval):

build_log.log(25, f"\n{' ' * 11}* ".join(init_msg))

retval['workflow'] = init_fmriprep_wf()
retval['workflow'] = init_fmriprep_wf(config.execution.unique_labels)

# Check for FS license after building the workflow
if not check_valid_fs_license():
Expand Down
8 changes: 8 additions & 0 deletions fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ class execution(_Config):
"""Select a particular task from all available in the dataset."""
templateflow_home = _templateflow_home
"""The root folder of the TemplateFlow client."""
unique_labels = None
"""Combinations of subject + session identifiers to be preprocessed."""
work_dir = Path('work').absolute()
"""Path to a working directory where intermediate results will be available."""
write_graph = False
Expand Down Expand Up @@ -468,6 +470,12 @@ class execution(_Config):
@classmethod
def init(cls):
"""Create a new BIDS Layout accessible with :attr:`~execution.layout`."""
# Convert string literal None to NoneType
if cls.unique_labels:
cls.unique_labels = [
[sub, ses] if ses != 'None' else [sub, None] for sub, ses in cls.unique_labels
]

if cls.fs_license_file and Path(cls.fs_license_file).is_file():
os.environ['FS_LICENSE'] = str(cls.fs_license_file)

Expand Down

0 comments on commit 042a67b

Please sign in to comment.