Skip to content

Commit 5d0c9ff

Browse files
mgxdeffigies
authored andcommitted
rf: move wb surface resample to inside cifti block
1 parent 7f40102 commit 5d0c9ff

File tree

1 file changed

+99
-97
lines changed

1 file changed

+99
-97
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 99 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def init_bold_wf(
280280
spaces = config.workflow.spaces
281281
nonstd_spaces = set(spaces.get_nonstandard())
282282
freesurfer_spaces = spaces.get_fs_spaces()
283+
surf_std = [x for x in spaces.get_standard(dim=(2,)) if x.space != 'fsaverage']
283284

284285
#
285286
# Resampling outputs workflow:
@@ -537,103 +538,6 @@ def init_bold_wf(
537538
]),
538539
]) # fmt:skip
539540

540-
surf_std = spaces.get_standard(dim=(2,))
541-
if surf_std and config.workflow.run_reconall and config.workflow.cifti_output:
542-
workflow.__postdesc__ += """\
543-
Non-gridded (surface) resamplings were performed using the Connectome
544-
Workbench.
545-
"""
546-
config.loggers.workflow.debug('Creating BOLD surface workbench resampling workflow.')
547-
from smriprep.workflows.surfaces import init_resample_surfaces_wf
548-
549-
from .resampling import (
550-
init_wb_surf_surf_wf,
551-
init_wb_vol_surf_wf,
552-
)
553-
554-
wb_vol_surf_wf = init_wb_vol_surf_wf(
555-
omp_nthreads=omp_nthreads,
556-
mem_gb=mem_gb['resampled'],
557-
dilate=True,
558-
)
559-
workflow.connect([
560-
(inputnode, wb_vol_surf_wf,[
561-
('white', 'inputnode.white'),
562-
('pial', 'inputnode.pial'),
563-
('midthickness', 'inputnode.midthickness'),
564-
]),
565-
(bold_anat_wf, wb_vol_surf_wf, [
566-
('outputnode.bold_file', 'inputnode.bold_file'),
567-
]),
568-
]) # fmt:skip
569-
570-
if config.workflow.project_goodvoxels:
571-
workflow.connect([
572-
(goodvoxels_bold_mask_wf, wb_vol_surf_wf, [
573-
('outputnode.goodvoxels_mask', 'inputnode.volume_roi'),
574-
]),
575-
]) # fmt:skip
576-
577-
for ref_ in surf_std:
578-
template = ref_.space
579-
density = ref_.spec.get('density') or ref_.spec.get('den') or None
580-
if density is None:
581-
config.loggers.warning(f'Cannot resample {ref_} without density specified.')
582-
continue
583-
584-
resample_surfaces_wb_wf = init_resample_surfaces_wf(
585-
name=f'resample_surfaces_wb_wf_{template}_{density}',
586-
surfaces=['midthickness'],
587-
template=template,
588-
density=density,
589-
)
590-
591-
wb_surf_surf_wf = init_wb_surf_surf_wf(
592-
template=template,
593-
density=density,
594-
omp_nthreads=omp_nthreads,
595-
mem_gb=mem_gb['resampled'],
596-
)
597-
598-
ds_bold_surf_wb = pe.Node(
599-
DerivativesDataSink(
600-
base_directory=fmriprep_dir,
601-
hemi=['L', 'R'],
602-
dismiss_entities=dismiss_echo(),
603-
space=template,
604-
density=density,
605-
suffix='bold',
606-
TaskName=all_metadata[0].get('TaskName'),
607-
extension='.func.gii',
608-
**prepare_timing_parameters(all_metadata[0]),
609-
),
610-
iterfield=('in_file', 'hemi'),
611-
name=f'ds_bold_surf_wb_{template}_{density}',
612-
run_without_submitting=True,
613-
)
614-
ds_bold_surf_wb.inputs.source_file = bold_file
615-
616-
workflow.connect([
617-
(inputnode, resample_surfaces_wb_wf, [
618-
('midthickness', 'inputnode.midthickness'),
619-
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
620-
]),
621-
(wb_vol_surf_wf, wb_surf_surf_wf, [
622-
('outputnode.bold_fsnative', 'inputnode.bold_fsnative'),
623-
]),
624-
(inputnode, wb_surf_surf_wf, [
625-
('midthickness', 'inputnode.midthickness'),
626-
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
627-
]),
628-
(resample_surfaces_wb_wf, wb_surf_surf_wf, [
629-
('outputnode.midthickness', 'inputnode.midthickness_resampled'),
630-
]),
631-
(wb_surf_surf_wf, ds_bold_surf_wb, [
632-
('outputnode.bold_resampled', 'in_file'),
633-
# TODO: json metadata?
634-
]),
635-
]) # fmt:skip
636-
637541
if config.workflow.run_reconall and freesurfer_spaces:
638542
workflow.__postdesc__ += """\
639543
Non-gridded (surface) resamplings were performed using `mri_vol2surf`
@@ -770,6 +674,104 @@ def init_bold_wf(
770674
]),
771675
]) # fmt:skip
772676

677+
if surf_std:
678+
from smriprep.workflows.surfaces import init_resample_surfaces_wf
679+
680+
from .resampling import (
681+
init_wb_surf_surf_wf,
682+
init_wb_vol_surf_wf,
683+
)
684+
workflow.__postdesc__ += (
685+
'Non-gridded (surface) resamplings were performed using the Connectome Workbench.'
686+
)
687+
config.loggers.workflow.debug('Creating BOLD surface workbench resampling workflow.')
688+
689+
wb_vol_surf_wf = init_wb_vol_surf_wf(
690+
omp_nthreads=omp_nthreads,
691+
mem_gb=mem_gb['resampled'],
692+
dilate=True,
693+
)
694+
workflow.connect([
695+
(inputnode, wb_vol_surf_wf,[
696+
('white', 'inputnode.white'),
697+
('pial', 'inputnode.pial'),
698+
('midthickness', 'inputnode.midthickness'),
699+
]),
700+
(bold_anat_wf, wb_vol_surf_wf, [
701+
('outputnode.bold_file', 'inputnode.bold_file'),
702+
]),
703+
]) # fmt:skip
704+
705+
if config.workflow.project_goodvoxels:
706+
workflow.connect([
707+
(goodvoxels_bold_mask_wf, wb_vol_surf_wf, [
708+
('outputnode.goodvoxels_mask', 'inputnode.volume_roi'),
709+
]),
710+
]) # fmt:skip
711+
712+
for ref_ in surf_std:
713+
template = ref_.space
714+
density = ref_.spec.get('density') or ref_.spec.get('den') or None
715+
if density is None:
716+
config.loggers.warning(f'Cannot resample {ref_} without density specified.')
717+
continue
718+
719+
resample_surfaces_wf = init_resample_surfaces_wf(
720+
name=f'resample_surfaces_wf_{template}_{density}',
721+
surfaces=['midthickness'],
722+
template=template,
723+
density=density,
724+
)
725+
726+
wb_surf_surf_wf = init_wb_surf_surf_wf(
727+
template=template,
728+
density=density,
729+
omp_nthreads=omp_nthreads,
730+
mem_gb=mem_gb['resampled'],
731+
)
732+
733+
ds_bold_surf_wb = pe.Node(
734+
DerivativesDataSink(
735+
base_directory=fmriprep_dir,
736+
hemi=['L', 'R'],
737+
dismiss_entities=dismiss_echo(),
738+
space=template,
739+
density=density,
740+
suffix='bold',
741+
TaskName=all_metadata[0].get('TaskName'),
742+
extension='.func.gii',
743+
**prepare_timing_parameters(all_metadata[0]),
744+
),
745+
iterfield=('in_file', 'hemi'),
746+
name=f'ds_bold_surf_wb_{template}_{density}',
747+
run_without_submitting=True,
748+
)
749+
ds_bold_surf_wb.inputs.source_file = bold_file
750+
751+
workflow.connect([
752+
(inputnode, resample_surfaces_wf, [
753+
('midthickness', 'inputnode.midthickness'),
754+
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
755+
]),
756+
(wb_vol_surf_wf, wb_surf_surf_wf, [
757+
('outputnode.bold_fsnative', 'inputnode.bold_fsnative'),
758+
]),
759+
(inputnode, wb_surf_surf_wf, [
760+
('midthickness', 'inputnode.midthickness'),
761+
('sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
762+
]),
763+
(resample_surfaces_wf, wb_surf_surf_wf, [
764+
(
765+
f'outputnode.midthickness_{template}',
766+
'inputnode.midthickness_resampled'
767+
),
768+
]),
769+
(wb_surf_surf_wf, ds_bold_surf_wb, [
770+
('outputnode.bold_resampled', 'in_file'),
771+
# TODO: json metadata?
772+
]),
773+
]) # fmt:skip
774+
773775
bold_confounds_wf = init_bold_confs_wf(
774776
mem_gb=mem_gb['largemem'],
775777
metadata=all_metadata[0],

0 commit comments

Comments
 (0)