Skip to content

Commit f719949

Browse files
authored
Re-enable anat fasttrack for dataset without t1w (#3202)
Re-enables the possibility to run fMRIPrep on a fMRI only dataset using anat derivatives from another (anatomical) dataset with the same participant. Tries to implement integration test for that feature. fixes #3201 related to #2201
2 parents 9568ccb + e56a819 commit f719949

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

.circleci/config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,21 @@ jobs:
551551
environment:
552552
VARIANT: '_partial'
553553
SUBDIR: 'fmriprep-partial'
554+
- run:
555+
name: Re-run fMRIPrep on single run of task data, without T1w in BIDS
556+
no_output_timeout: 2h
557+
command: |
558+
rm -Rf /tmp/data/${DATASET}/sub-01/anat
559+
FASTRACK_ARG="--derivatives anat=/tmp/${DATASET}/smriprep"
560+
fmriprep-docker -i nipreps/fmriprep:latest \
561+
-e FMRIPREP_DEV 1 --user $(id -u):$(id -g) \
562+
--network none \
563+
--config $PWD/nipype.cfg -w /tmp/${DATASET}/work_partial \
564+
/tmp/data/${DATASET} /tmp/${DATASET}/fmriprep-partial-noT1w participant \
565+
--fs-subjects-dir /tmp/${DATASET}/freesurfer \
566+
${FASTRACK_ARG} \
567+
--sloppy --write-graph --mem-mb 14336 \
568+
--level minimal --nthreads 4 -vv
554569
- run:
555570
name: Clean working directory
556571
when: on_success

fmriprep/cli/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,12 @@ def parse_args(args=None, namespace=None):
825825
"Making sure the input data is BIDS compliant (warnings can be ignored in most "
826826
"cases)."
827827
)
828-
validate_input_dir(config.environment.exec_env, opts.bids_dir, opts.participant_label)
828+
validate_input_dir(
829+
config.environment.exec_env,
830+
opts.bids_dir,
831+
opts.participant_label,
832+
need_T1w=not config.execution.derivatives,
833+
)
829834

830835
# Setup directories
831836
config.execution.log_dir = config.execution.fmriprep_dir / "logs"

fmriprep/utils/bids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def write_derivative_description(bids_dir, deriv_dir):
146146
Path.write_text(deriv_dir / 'dataset_description.json', json.dumps(desc, indent=4))
147147

148148

149-
def validate_input_dir(exec_env, bids_dir, participant_label):
149+
def validate_input_dir(exec_env, bids_dir, participant_label, need_T1w=True):
150150
# Ignore issues and warnings that should not influence FMRIPREP
151151
import subprocess
152152
import tempfile
@@ -196,7 +196,7 @@ def validate_input_dir(exec_env, bids_dir, participant_label):
196196
"MISSING_TSV_COLUMN_EEG_ELECTRODES",
197197
"MISSING_SESSION",
198198
],
199-
"error": ["NO_T1W"],
199+
"error": ["NO_T1W"] if need_T1w else [],
200200
"ignoredFiles": ['/dataset_description.json', '/participants.tsv'],
201201
}
202202
# Limit validation only to data from requested participants

fmriprep/workflows/base.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def init_single_subject_wf(subject_id: str):
269269
subject_data=subject_data,
270270
anat_only=config.workflow.anat_only,
271271
subject_id=subject_id,
272+
anat_derivatives=anatomical_cache if anatomical_cache else None,
272273
),
273274
name='bidssrc',
274275
)
@@ -338,9 +339,24 @@ def init_single_subject_wf(subject_id: str):
338339
skull_strip_fixed_seed=config.workflow.skull_strip_fixed_seed,
339340
)
340341

342+
# allow to run with anat-fast-track on fMRI-only dataset
343+
if 't1w_preproc' in anatomical_cache and not subject_data['t1w']:
344+
workflow.connect([
345+
(bidssrc, bids_info, [(('bold', fix_multi_T1w_source_name), 'in_file')]),
346+
(anat_fit_wf, summary, [('outputnode.t1w_preproc', 't1w')]),
347+
(anat_fit_wf, ds_report_summary, [('outputnode.t1w_preproc', 'source_file')]),
348+
(anat_fit_wf, ds_report_about, [('outputnode.t1w_preproc', 'source_file')]),
349+
]) # fmt:skip
350+
else:
351+
workflow.connect([
352+
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]),
353+
(bidssrc, summary, [('t1w', 't1w')]),
354+
(bidssrc, ds_report_summary, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
355+
(bidssrc, ds_report_about, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
356+
]) # fmt:skip
357+
341358
workflow.connect([
342359
(inputnode, anat_fit_wf, [('subjects_dir', 'inputnode.subjects_dir')]),
343-
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]),
344360
(bidssrc, anat_fit_wf, [
345361
('t1w', 'inputnode.t1w'),
346362
('t2w', 'inputnode.t2w'),
@@ -350,10 +366,8 @@ def init_single_subject_wf(subject_id: str):
350366
(bids_info, anat_fit_wf, [(('subject', _prefix), 'inputnode.subject_id')]),
351367
# Reporting connections
352368
(inputnode, summary, [('subjects_dir', 'subjects_dir')]),
353-
(bidssrc, summary, [('t1w', 't1w'), ('t2w', 't2w'), ('bold', 'bold')]),
369+
(bidssrc, summary, [('t2w', 't2w'), ('bold', 'bold')]),
354370
(bids_info, summary, [('subject', 'subject_id')]),
355-
(bidssrc, ds_report_summary, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
356-
(bidssrc, ds_report_about, [(('t1w', fix_multi_T1w_source_name), 'source_file')]),
357371
(summary, ds_report_summary, [('out_report', 'in_file')]),
358372
(about, ds_report_about, [('out_report', 'in_file')]),
359373
]) # fmt:skip

0 commit comments

Comments
 (0)