Skip to content

Commit

Permalink
FIX: Connections
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Nov 13, 2023
1 parent ec8b7cc commit cf993a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
27 changes: 27 additions & 0 deletions fmriprep/workflows/bold/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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, [
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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())
31 changes: 0 additions & 31 deletions fmriprep/workflows/bold/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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())

0 comments on commit cf993a4

Please sign in to comment.