diff --git a/.circleci/ds005_fasttrack_outputs.txt b/.circleci/ds005_fasttrack_outputs.txt index 1b2052d68..2fdaea2e7 100644 --- a/.circleci/ds005_fasttrack_outputs.txt +++ b/.circleci/ds005_fasttrack_outputs.txt @@ -23,6 +23,8 @@ sub-01/anat/sub-01_hemi-R_desc-reg_sphere.surf.gii sub-01/anat/sub-01_hemi-R_space-fsLR_desc-msmsulc_sphere.surf.gii sub-01/anat/sub-01_hemi-R_space-fsLR_desc-reg_sphere.surf.gii sub-01/func +sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-coreg_boldref.json @@ -41,6 +43,8 @@ sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsaverage5_bold.fun sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsaverage5_bold.json sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsnative_bold.func.gii sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsnative_bold.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-coreg_boldref.json diff --git a/.circleci/ds005_outputs.txt b/.circleci/ds005_outputs.txt index 1634090d5..9548adfaf 100644 --- a/.circleci/ds005_outputs.txt +++ b/.circleci/ds005_outputs.txt @@ -43,6 +43,8 @@ sub-01/anat/sub-01_label-CSF_probseg.nii.gz sub-01/anat/sub-01_label-GM_probseg.nii.gz sub-01/anat/sub-01_label-WM_probseg.nii.gz sub-01/func +sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-01_desc-coreg_boldref.json @@ -61,6 +63,8 @@ sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsaverage5_bold.fun sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsaverage5_bold.json sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsnative_bold.func.gii sub-01/func/sub-01_task-mixedgamblestask_run-01_hemi-R_space-fsnative_bold.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-coreg_boldref.json diff --git a/.circleci/ds005_partial_fasttrack_outputs.txt b/.circleci/ds005_partial_fasttrack_outputs.txt index 39533d137..243b1a8ab 100644 --- a/.circleci/ds005_partial_fasttrack_outputs.txt +++ b/.circleci/ds005_partial_fasttrack_outputs.txt @@ -51,6 +51,8 @@ sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-magnitude_fieldmap.nii.gz sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-preproc_fieldmap.json sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-preproc_fieldmap.nii.gz sub-01/func +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-coreg_boldref.json diff --git a/.circleci/ds005_partial_outputs.txt b/.circleci/ds005_partial_outputs.txt index 80e9078ca..b8909ad63 100644 --- a/.circleci/ds005_partial_outputs.txt +++ b/.circleci/ds005_partial_outputs.txt @@ -73,6 +73,8 @@ sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-magnitude_fieldmap.nii.gz sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-preproc_fieldmap.json sub-01/fmap/sub-01_run-02_fmapid-auto00000_desc-preproc_fieldmap.nii.gz sub-01/func +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.json +sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-brain_mask.nii.gz sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.json sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-confounds_timeseries.tsv sub-01/func/sub-01_task-mixedgamblestask_run-02_desc-coreg_boldref.json diff --git a/fmriprep/workflows/bold/base.py b/fmriprep/workflows/bold/base.py index 2643b8291..3c1548d27 100644 --- a/fmriprep/workflows/bold/base.py +++ b/fmriprep/workflows/bold/base.py @@ -325,9 +325,6 @@ def init_bold_wf( ds_bold_native_wf.inputs.inputnode.source_files = bold_series workflow.connect([ - (bold_fit_wf, ds_bold_native_wf, [ - ('outputnode.bold_mask', 'inputnode.bold_mask'), - ]), (bold_native_wf, ds_bold_native_wf, [ ('outputnode.bold_native', 'inputnode.bold'), ('outputnode.bold_echos', 'inputnode.bold_echos'), diff --git a/fmriprep/workflows/bold/fit.py b/fmriprep/workflows/bold/fit.py index f81285e62..e5b1961b2 100644 --- a/fmriprep/workflows/bold/fit.py +++ b/fmriprep/workflows/bold/fit.py @@ -47,6 +47,7 @@ # BOLD workflows from .hmc import init_bold_hmc_wf from .outputs import ( + init_ds_boldmask_wf, init_ds_boldref_wf, init_ds_hmc_wf, init_ds_registration_wf, @@ -467,6 +468,13 @@ def init_bold_fit_wf( desc='coreg', name='ds_coreg_boldref_wf', ) + ds_boldmask_wf = init_ds_boldmask_wf( + bids_root=layout.root, + output_dir=config.execution.fmriprep_dir, + desc='brain', + name='ds_boldmask_wf', + ) + ds_boldmask_wf.inputs.inputnode.source_files = [bold_file] # fmt:off workflow.connect([ @@ -474,6 +482,7 @@ def init_bold_fit_wf( (fmapref_buffer, enhance_boldref_wf, [("out", "inputnode.in_file")]), (fmapref_buffer, ds_coreg_boldref_wf, [("out", "inputnode.source_files")]), (ds_coreg_boldref_wf, regref_buffer, [("outputnode.boldref", "boldref")]), + (ds_boldmask_wf, regref_buffer, [('outputnode.boldmask', 'boldmask')]), (fmapref_buffer, func_fit_reports_wf, [("out", "inputnode.sdc_boldref")]), ]) # fmt:on @@ -557,8 +566,8 @@ def init_bold_fit_wf( (unwarp_wf, ds_coreg_boldref_wf, [ ('outputnode.corrected', 'inputnode.boldref'), ]), - (unwarp_wf, regref_buffer, [ - ('outputnode.corrected_mask', 'boldmask'), + (unwarp_wf, ds_boldmask_wf, [ + ('outputnode.corrected_mask', 'inputnode.boldmask'), ]), (fmap_select, func_fit_reports_wf, [("fmap_ref", "inputnode.fmap_ref")]), (fmap_select, summary, [("sdc_method", "distortion_correction")]), @@ -574,8 +583,8 @@ def init_bold_fit_wf( (enhance_boldref_wf, ds_coreg_boldref_wf, [ ('outputnode.bias_corrected_file', 'inputnode.boldref'), ]), - (enhance_boldref_wf, regref_buffer, [ - ('outputnode.mask_file', 'boldmask'), + (enhance_boldref_wf, ds_boldmask_wf, [ + ('outputnode.mask_file', 'inputnode.boldmask'), ]), ]) # fmt:on diff --git a/fmriprep/workflows/bold/outputs.py b/fmriprep/workflows/bold/outputs.py index 3e561abe0..93791db80 100644 --- a/fmriprep/workflows/bold/outputs.py +++ b/fmriprep/workflows/bold/outputs.py @@ -466,6 +466,50 @@ def init_ds_boldref_wf( return workflow +def init_ds_boldmask_wf( + *, + bids_root, + output_dir, + desc: str, + name='ds_boldmask_wf', +) -> pe.Workflow: + """Write out a BOLD mask.""" + workflow = pe.Workflow(name=name) + + inputnode = pe.Node( + niu.IdentityInterface(fields=['source_files', 'boldmask']), + name='inputnode', + ) + outputnode = pe.Node(niu.IdentityInterface(fields=['boldmask']), name='outputnode') + + raw_sources = pe.Node(niu.Function(function=_bids_relative), name='raw_sources') + raw_sources.inputs.bids_root = bids_root + + ds_boldmask = pe.Node( + DerivativesDataSink( + base_directory=output_dir, + desc=desc, + suffix='mask', + compress=True, + dismiss_entities=dismiss_echo(), + ), + name='ds_boldmask', + run_without_submitting=True, + ) + + workflow.connect([ + (inputnode, raw_sources, [('source_files', 'in_files')]), + (inputnode, ds_boldmask, [ + ('boldmask', 'in_file'), + ('source_files', 'source_file'), + ]), + (raw_sources, ds_boldmask, [('out', 'RawSources')]), + (ds_boldmask, outputnode, [('out_file', 'boldmask')]), + ]) # fmt:skip + + return workflow + + def init_ds_registration_wf( *, bids_root: str, @@ -575,7 +619,6 @@ def init_ds_bold_native_wf( fields=[ 'source_files', 'bold', - 'bold_mask', 'bold_echos', 't2star', ] @@ -587,27 +630,6 @@ def init_ds_bold_native_wf( raw_sources.inputs.bids_root = bids_root workflow.connect(inputnode, 'source_files', raw_sources, 'in_files') - # Masks should be output if any other derivatives are output - ds_bold_mask = pe.Node( - DerivativesDataSink( - base_directory=output_dir, - desc='brain', - suffix='mask', - compress=True, - dismiss_entities=dismiss_echo(), - ), - name='ds_bold_mask', - run_without_submitting=True, - mem_gb=DEFAULT_MEMORY_MIN_GB, - ) - workflow.connect([ - (inputnode, ds_bold_mask, [ - ('source_files', 'source_file'), - ('bold_mask', 'in_file'), - ]), - (raw_sources, ds_bold_mask, [('out', 'RawSources')]), - ]) # fmt:skip - if bold_output: ds_bold = pe.Node( DerivativesDataSink(