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

Re-enable anat fasttrack for dataset without t1w #3202

Merged
merged 11 commits into from
Jan 18, 2024
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,21 @@ jobs:
environment:
VARIANT: '_partial'
SUBDIR: 'fmriprep-partial'
- run:
name: Re-run fMRIPrep on single run of task data, without T1w in BIDS
bpinsard marked this conversation as resolved.
Show resolved Hide resolved
no_output_timeout: 2h
command: |
rm -Rf /tmp/data/${DATASET}/sub-01/anat
FASTRACK_ARG="--derivatives anat=/tmp/${DATASET}/smriprep"
fmriprep-docker -i nipreps/fmriprep:latest \
-e FMRIPREP_DEV 1 --user $(id -u):$(id -g) \
--network none \
--config $PWD/nipype.cfg -w /tmp/${DATASET}/work_partial \
/tmp/data/${DATASET} /tmp/${DATASET}/fmriprep-partial-noT1w participant \
--fs-subjects-dir /tmp/${DATASET}/freesurfer \
${FASTRACK_ARG} \
--sloppy --write-graph --mem-mb 14336 \
--level minimal --nthreads 4 -vv
- run:
name: Clean working directory
when: on_success
Expand Down
7 changes: 6 additions & 1 deletion fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,12 @@
"Making sure the input data is BIDS compliant (warnings can be ignored in most "
"cases)."
)
validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
validate_input_dir(

Check warning on line 828 in fmriprep/cli/parser.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/cli/parser.py#L828

Added line #L828 was not covered by tests
config.environment.exec_env,
opts.bids_dir,
opts.participant_label,
need_T1w=not config.execution.derivatives,
)

# Setup directories
config.execution.log_dir = config.execution.fmriprep_dir / "logs"
Expand Down
4 changes: 2 additions & 2 deletions fmriprep/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def write_derivative_description(bids_dir, deriv_dir):
Path.write_text(deriv_dir / 'dataset_description.json', json.dumps(desc, indent=4))


def validate_input_dir(exec_env, bids_dir, participant_label):
def validate_input_dir(exec_env, bids_dir, participant_label, need_T1w=True):
# Ignore issues and warnings that should not influence FMRIPREP
import subprocess
import tempfile
Expand Down Expand Up @@ -196,7 +196,7 @@ def validate_input_dir(exec_env, bids_dir, participant_label):
"MISSING_TSV_COLUMN_EEG_ELECTRODES",
"MISSING_SESSION",
],
"error": ["NO_T1W"],
"error": ["NO_T1W"] if need_T1w else [],
"ignoredFiles": ['/dataset_description.json', '/participants.tsv'],
}
# Limit validation only to data from requested participants
Expand Down
22 changes: 18 additions & 4 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
subject_data=subject_data,
anat_only=config.workflow.anat_only,
subject_id=subject_id,
anat_derivatives=anatomical_cache if anatomical_cache else None,
),
name='bidssrc',
)
Expand Down Expand Up @@ -338,9 +339,24 @@
skull_strip_fixed_seed=config.workflow.skull_strip_fixed_seed,
)

# allow to run with anat-fast-track on fMRI-only dataset
if 't1w_preproc' in anatomical_cache and not subject_data['t1w']:
workflow.connect([

Check warning on line 344 in fmriprep/workflows/base.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/workflows/base.py#L344

Added line #L344 was not covered by tests
(bidssrc, bids_info, [(('bold', fix_multi_T1w_source_name), 'in_file')]),
(anat_fit_wf, summary, [('outputnode.t1w_preproc', 't1w')]),
(anat_fit_wf, ds_report_summary, [('outputnode.t1w_preproc', 'source_file')]),
(anat_fit_wf, ds_report_about, [('outputnode.t1w_preproc', 'source_file')]),
]) # fmt:skip
else:
workflow.connect([
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]),
(bidssrc, summary, [('t1w', 't1w')]),
(bidssrc, ds_report_summary, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
(bidssrc, ds_report_about, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
]) # fmt:skip

workflow.connect([
(inputnode, anat_fit_wf, [('subjects_dir', 'inputnode.subjects_dir')]),
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]),
(bidssrc, anat_fit_wf, [
('t1w', 'inputnode.t1w'),
('t2w', 'inputnode.t2w'),
Expand All @@ -350,10 +366,8 @@
(bids_info, anat_fit_wf, [(('subject', _prefix), 'inputnode.subject_id')]),
# Reporting connections
(inputnode, summary, [('subjects_dir', 'subjects_dir')]),
(bidssrc, summary, [('t1w', 't1w'), ('t2w', 't2w'), ('bold', 'bold')]),
(bidssrc, summary, [('t2w', 't2w'), ('bold', 'bold')]),
(bids_info, summary, [('subject', 'subject_id')]),
(bidssrc, ds_report_summary, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
(bidssrc, ds_report_about, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
(summary, ds_report_summary, [('out_report', 'in_file')]),
(about, ds_report_about, [('out_report', 'in_file')]),
]) # fmt:skip
Expand Down