Skip to content

Commit 123c3f8

Browse files
authored
Track proximal sources of functional GIFTIs (#3263)
Related to #3261. ## Changes proposed in this pull request - Add an outputnode to `init_ds_volumes_wf` with the saved `bold` path. - Add `sources` field to `init_bold_surf_wf`'s inputnode. - Infer Sources for functional GIFTI outputs. - If the user has requested T1w-space outputs, then this should be `bold` from the associated `ds_volumes_wf` and `fsnative2t1w_xfm` - If the user didn't want T1w-space volumetric outputs, then this should be the raw BOLD file, `motion_xfm`, `boldref2anat_xfm`, `fsnative2t1w_xfm`.
1 parent ecf8580 commit 123c3f8

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,25 @@ def init_bold_wf(
514514
(bold_anat_wf, bold_surf_wf, [('outputnode.bold_file', 'inputnode.bold_t1w')]),
515515
]) # fmt:skip
516516

517+
# sources are bold_file, motion_xfm, boldref2anat_xfm, fsnative2t1w_xfm
518+
merge_surface_sources = pe.Node(
519+
niu.Merge(4),
520+
name='merge_surface_sources',
521+
run_without_submitting=True,
522+
)
523+
merge_surface_sources.inputs.in1 = bold_file
524+
workflow.connect([
525+
(bold_fit_wf, merge_surface_sources, [
526+
('outputnode.motion_xfm', 'in2'),
527+
('outputnode.boldref2anat_xfm', 'in3'),
528+
]),
529+
(inputnode, merge_surface_sources, [
530+
('fsnative2t1w_xfm', 'in4'),
531+
]),
532+
]) # fmt:skip
533+
534+
workflow.connect([(merge_surface_sources, bold_surf_wf, [('out', 'inputnode.sources')])])
535+
517536
if config.workflow.cifti_output:
518537
from .resampling import (
519538
init_bold_fsLR_resampling_wf,

fmriprep/workflows/bold/resampling.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
4444
from niworkflows.interfaces.freesurfer import MedialNaNs
4545

46+
from ... import config
4647
from ...config import DEFAULT_MEMORY_MIN_GB
48+
from ...interfaces.bids import BIDSURI
4749
from ...interfaces.workbench import MetricDilate, MetricMask, MetricResample
4850
from ...utils.bids import dismiss_echo
4951
from .outputs import prepare_timing_parameters
@@ -93,6 +95,8 @@ def init_bold_surf_wf(
9395
------
9496
source_file
9597
Original BOLD series
98+
sources
99+
List of files used to create the output files.
96100
bold_t1w
97101
Motion-corrected BOLD series in T1 space
98102
subjects_dir
@@ -128,6 +132,7 @@ def init_bold_surf_wf(
128132
niu.IdentityInterface(
129133
fields=[
130134
'source_file',
135+
'sources',
131136
'bold_t1w',
132137
'subject_id',
133138
'subjects_dir',
@@ -139,6 +144,15 @@ def init_bold_surf_wf(
139144
itersource = pe.Node(niu.IdentityInterface(fields=['target']), name='itersource')
140145
itersource.iterables = [('target', surface_spaces)]
141146

147+
surfs_sources = pe.Node(
148+
BIDSURI(
149+
numinputs=1,
150+
dataset_links=config.execution.dataset_links,
151+
out_dir=str(config.execution.fmriprep_dir.absolute()),
152+
),
153+
name='surfs_sources',
154+
)
155+
142156
get_fsnative = pe.Node(FreeSurferSource(), name='get_fsnative', run_without_submitting=True)
143157

144158
def select_target(subject_id, space):
@@ -212,6 +226,8 @@ def select_target(subject_id, space):
212226
(itk2lta, sampler, [('out_inv', 'reg_file')]),
213227
(targets, sampler, [('out', 'target_subject')]),
214228
(inputnode, ds_bold_surfs, [('source_file', 'source_file')]),
229+
(inputnode, surfs_sources, [('sources', 'in1')]),
230+
(surfs_sources, ds_bold_surfs, [('out', 'Sources')]),
215231
(itersource, ds_bold_surfs, [('target', 'space')]),
216232
(update_metadata, ds_bold_surfs, [('out_file', 'in_file')]),
217233
]) # fmt:skip
@@ -488,14 +504,12 @@ def _calc_lower_thr(in_stats):
488504
)
489505

490506
# apply goodvoxels ribbon mask to bold
491-
workflow.connect(
492-
[
493-
(goodvoxels_mask, goodvoxels_ribbon_mask, [('out_file', 'in_file')]),
494-
(ribbon_boldsrc_xfm, goodvoxels_ribbon_mask, [('output_image', 'mask_file')]),
495-
(goodvoxels_mask, outputnode, [('out_file', 'goodvoxels_mask')]),
496-
(goodvoxels_ribbon_mask, outputnode, [('out_file', 'goodvoxels_ribbon')]),
497-
]
498-
)
507+
workflow.connect([
508+
(goodvoxels_mask, goodvoxels_ribbon_mask, [('out_file', 'in_file')]),
509+
(ribbon_boldsrc_xfm, goodvoxels_ribbon_mask, [('output_image', 'mask_file')]),
510+
(goodvoxels_mask, outputnode, [('out_file', 'goodvoxels_mask')]),
511+
(goodvoxels_ribbon_mask, outputnode, [('out_file', 'goodvoxels_ribbon')]),
512+
]) # fmt:skip
499513

500514
return workflow
501515

0 commit comments

Comments
 (0)