diff --git a/fmriprep/workflows/bold/base.py b/fmriprep/workflows/bold/base.py index e693757ea..37b6e8751 100644 --- a/fmriprep/workflows/bold/base.py +++ b/fmriprep/workflows/bold/base.py @@ -54,6 +54,7 @@ init_ds_registration_wf, init_ds_volumes_wf, init_func_derivatives_wf, + prepare_timing_parameters, ) from .registration import init_bold_reg_wf, init_bold_t1_trans_wf from .resampling import ( @@ -495,6 +496,21 @@ def init_bold_wf( repetition_time=all_metadata[0]["RepetitionTime"], ) + ds_bold_cifti = pe.Node( + DerivativesDataSink( + base_directory=fmriprep_dir, + space='fsLR', + density=config.workflow.cifti_output, + suffix='bold', + compress=False, + TaskName=all_metadata[0].get('TaskName'), + **prepare_timing_parameters(all_metadata[0]), + ), + name='ds_bold_cifti', + run_without_submitting=True, + ) + ds_bold_cifti.inputs.source_file = bold_file + workflow.connect([ # Resample BOLD to MNI152NLin6Asym, may duplicate bold_std_wf above (inputnode, bold_MNI6_wf, [ @@ -532,6 +548,10 @@ def init_bold_wf( (bold_fsLR_resampling_wf, bold_grayords_wf, [ ("outputnode.bold_fsLR", "inputnode.bold_fsLR"), ]), + (bold_grayords_wf, ds_bold_cifti, [ + ('outputnode.cifti_bold', 'in_file'), + (('outputnode.cifti_metadata', _read_json), 'meta_dict'), + ]), ]) # fmt:skip bold_confounds_wf = init_bold_confs_wf( @@ -975,3 +995,10 @@ def get_img_orientation(imgf): """Return the image orientation as a string""" img = nb.load(imgf) return "".join(nb.aff2axcodes(img.affine)) + + +def _read_json(in_file): + from json import loads + from pathlib import Path + + return loads(Path(in_file).read_text()) diff --git a/fmriprep/workflows/bold/outputs.py b/fmriprep/workflows/bold/outputs.py index 40b746700..213fbdcfe 100644 --- a/fmriprep/workflows/bold/outputs.py +++ b/fmriprep/workflows/bold/outputs.py @@ -982,30 +982,6 @@ def init_func_derivatives_wf( ]) # fmt:on - # CIFTI output - if cifti_output: - ds_bold_cifti = pe.Node( - DerivativesDataSink( - base_directory=output_dir, - suffix='bold', - compress=False, - TaskName=metadata.get('TaskName'), - space='fsLR', - **timing_parameters, - ), - name='ds_bold_cifti', - run_without_submitting=True, - mem_gb=DEFAULT_MEMORY_MIN_GB, - ) - # fmt:off - workflow.connect([ - (inputnode, ds_bold_cifti, [(('bold_cifti', _unlist), 'in_file'), - ('source_file', 'source_file'), - ('cifti_density', 'density'), - (('cifti_metadata', _read_json), 'meta_dict')]) - ]) - # fmt:on - if "compcor" in config.execution.debug: ds_acompcor_masks = pe.Node( DerivativesDataSink( @@ -1120,10 +1096,3 @@ def _unlist(in_file): while isinstance(in_file, (list, tuple)) and len(in_file) == 1: in_file = in_file[0] return in_file - - -def _read_json(in_file): - from json import loads - from pathlib import Path - - return loads(Path(in_file).read_text())