Skip to content

Commit 0133ad4

Browse files
committed
WIP: Add in fMRIPrep fsLR processing, minus MCRIBS adjustment
1 parent 18b1514 commit 0133ad4

File tree

4 files changed

+386
-233
lines changed

4 files changed

+386
-233
lines changed

nibabies/workflows/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ def init_single_subject_wf(
470470
('outputnode.subject_id', 'inputnode.subject_id'),
471471
('outputnode.t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
472472
('outputnode.fsnative2t1w_xfm', 'inputnode.fsnative2t1w_xfm'),
473-
('outputnode.anat_ribbon', 'inputnode.anat_ribbon'),
473+
('outputnode.surfaces', 'inputnode.surfaces'),
474+
('outputnode.morphometrics', 'inputnode.morphometrics'),
475+
('outputnode.sphere_reg_fsLR', 'inputnode.sphere_reg_fsLR'),
474476
]),
475477
])
476478
# fmt:on
@@ -587,7 +589,6 @@ def init_workflow_spaces(execution_spaces, age_months):
587589
if config.workflow.cifti_output:
588590
# CIFTI grayordinates to corresponding FSL-MNI resolutions.
589591
vol_res = "2" if config.workflow.cifti_output == "91k" else "1"
590-
spaces.add(Reference("fsaverage", {"den": "164k"}))
591592
spaces.add(Reference("MNI152NLin6Asym", {"res": vol_res}))
592593
# Ensure a non-native version of MNIInfant is added as a target
593594
cohort = cohort_by_months("MNIInfant", age_months)

nibabies/workflows/bold/base.py

Lines changed: 73 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,7 @@ def init_func_preproc_wf(bold_file, spaces, has_fieldmap=False, existing_derivat
193193
freesurfer = config.workflow.run_reconall
194194
nibabies_dir = str(config.execution.nibabies_dir)
195195
freesurfer_spaces = spaces.get_fs_spaces()
196-
project_goodvoxels = config.workflow.project_goodvoxels
197-
198-
if project_goodvoxels and freesurfer_spaces != ["fsaverage"]:
199-
config.loggers.workflow.critical(
200-
f"--project-goodvoxels only works with fsaverage (requested: {freesurfer_spaces})"
201-
)
202-
config.loggers.workflow.warn("Disabling --project-goodvoxels")
203-
project_goodvoxels = False
196+
project_goodvoxels = config.workflow.project_goodvoxels and config.workflow.cifti_output
204197

205198
# Extract BIDS entities and metadata from BOLD file(s)
206199
entities = extract_entities(bold_file)
@@ -344,6 +337,9 @@ def init_func_preproc_wf(bold_file, spaces, has_fieldmap=False, existing_derivat
344337
"fsnative2t1w_xfm",
345338
"subject_id",
346339
"subjects_dir",
340+
"surfaces",
341+
"morphometrics",
342+
"sphere_reg_fsLR",
347343
]
348344
),
349345
name="inputnode",
@@ -929,7 +925,6 @@ def init_func_preproc_wf(bold_file, spaces, has_fieldmap=False, existing_derivat
929925
mem_gb=mem_gb["resampled"],
930926
surface_spaces=freesurfer_spaces,
931927
medial_surface_nan=config.workflow.medial_surface_nan,
932-
project_goodvoxels=project_goodvoxels,
933928
surface_recon_method=config.workflow.surface_recon_method,
934929
name="bold_surf_wf",
935930
)
@@ -938,67 +933,83 @@ def init_func_preproc_wf(bold_file, spaces, has_fieldmap=False, existing_derivat
938933
(inputnode, bold_surf_wf, [
939934
('subjects_dir', 'inputnode.subjects_dir'),
940935
('subject_id', 'inputnode.subject_id'),
941-
('t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm'),
942-
("anat_ribbon", "inputnode.anat_ribbon"),
943-
("anat_mask", "inputnode.t1w_mask")]),
936+
('t1w2fsnative_xfm', 'inputnode.t1w2fsnative_xfm')]),
944937
(bold_t1_trans_wf, bold_surf_wf, [('outputnode.bold_t1', 'inputnode.source_file')]),
945938
(bold_surf_wf, outputnode, [('outputnode.surfaces', 'surfaces')]),
946939
(bold_surf_wf, func_derivatives_wf, [
947940
('outputnode.target', 'inputnode.surf_refs')]),
948-
(bold_surf_wf, func_derivatives_wf, [("outputnode.goodvoxels_ribbon",
949-
"inputnode.goodvoxels_ribbon")]),
950941
])
951942
# fmt:on
952943

953-
# CIFTI output
954-
if config.workflow.cifti_output:
955-
from .alignment import (
956-
init_subcortical_mni_alignment_wf,
957-
init_subcortical_rois_wf,
958-
)
959-
from .resampling import init_bold_grayords_wf
960-
961-
key = get_MNIInfant_key(spaces)
962-
963-
# BOLD/ROIs should be in MNIInfant space
964-
cifti_select_std = pe.Node(
965-
KeySelect(fields=["bold_std", "bold_aseg_std"], key=key),
966-
name="cifti_select_std",
967-
run_without_submitting=True,
968-
)
969-
970-
subcortical_rois_wf = init_subcortical_rois_wf()
971-
subcortical_mni_alignment_wf = init_subcortical_mni_alignment_wf()
972-
bold_grayords_wf = init_bold_grayords_wf(
973-
grayord_density=config.workflow.cifti_output,
974-
mem_gb=mem_gb["resampled"],
975-
repetition_time=metadata["RepetitionTime"],
976-
)
944+
# CIFTI output
945+
if config.workflow.cifti_output:
946+
from .alignment import (
947+
init_subcortical_mni_alignment_wf,
948+
init_subcortical_rois_wf,
949+
)
950+
from .resampling import init_bold_fsLR_resampling_wf, init_bold_grayords_wf
951+
952+
# key = get_MNIInfant_key(spaces)
953+
# # BOLD/ROIs should be in MNIInfant space
954+
# cifti_select_std = pe.Node(
955+
# KeySelect(fields=["bold_std", "bold_aseg_std"], key=key),
956+
# name="cifti_select_std",
957+
# run_without_submitting=True,
958+
# )
959+
960+
subcortical_rois_wf = init_subcortical_rois_wf()
961+
subcortical_mni_alignment_wf = init_subcortical_mni_alignment_wf()
962+
bold_grayords_wf = init_bold_grayords_wf(
963+
grayord_density=config.workflow.cifti_output,
964+
mem_gb=mem_gb["resampled"],
965+
repetition_time=metadata["RepetitionTime"],
966+
)
977967

978-
# fmt:off
979-
workflow.connect([
980-
(bold_std_trans_wf, cifti_select_std, [
981-
("outputnode.bold_std", "bold_std"),
982-
("outputnode.bold_aseg_std", "bold_aseg_std"),
983-
("outputnode.spatial_reference", "keys")]),
984-
(cifti_select_std, subcortical_rois_wf, [
985-
("bold_aseg_std", "inputnode.MNIInfant_aseg")]),
986-
(cifti_select_std, subcortical_mni_alignment_wf, [
987-
("bold_std", "inputnode.MNIInfant_bold")]),
988-
(subcortical_rois_wf, subcortical_mni_alignment_wf, [
989-
("outputnode.MNIInfant_rois", "inputnode.MNIInfant_rois"),
990-
("outputnode.MNI152_rois", "inputnode.MNI152_rois")]),
991-
(subcortical_mni_alignment_wf, bold_grayords_wf, [
992-
("outputnode.subcortical_volume", "inputnode.subcortical_volume"),
993-
("outputnode.subcortical_labels", "inputnode.subcortical_labels")]),
994-
(bold_surf_wf, bold_grayords_wf, [
995-
('outputnode.surfaces', 'inputnode.surf_files'),
996-
('outputnode.target', 'inputnode.surf_refs')]),
997-
(bold_grayords_wf, outputnode, [
998-
('outputnode.cifti_bold', 'bold_cifti'),
999-
('outputnode.cifti_metadata', 'cifti_metadata')]),
1000-
])
1001-
# fmt:on
968+
# fmt:off
969+
workflow.connect([
970+
(inputnode, bold_fsLR_resampling_wf, [
971+
("surfaces", "inputnode.surfaces"),
972+
("morphometrics", "inputnode.morphometrics"),
973+
("sphere_reg_fsLR", "inputnode.sphere_reg_fsLR"),
974+
("anat_ribbon", "inputnode.anat_ribbon")]),
975+
# (bold_std_trans_wf, cifti_select_std, [
976+
# ("outputnode.bold_std", "bold_std"),
977+
# ("outputnode.bold_aseg_std", "bold_aseg_std"),
978+
# ("outputnode.spatial_reference", "keys")]),
979+
# (cifti_select_std, subcortical_rois_wf, [
980+
# ("bold_aseg_std", "inputnode.MNIInfant_aseg")]),
981+
# (cifti_select_std, subcortical_mni_alignment_wf, [
982+
# ("bold_std", "inputnode.MNIInfant_bold")]),
983+
# (subcortical_rois_wf, subcortical_mni_alignment_wf, [
984+
# ("outputnode.MNIInfant_rois", "inputnode.MNIInfant_rois"),
985+
# ("outputnode.MNI152_rois", "inputnode.MNI152_rois")]),
986+
# (subcortical_mni_alignment_wf, bold_grayords_wf, [
987+
# ("outputnode.subcortical_volume", "inputnode.subcortical_volume"),
988+
# ("outputnode.subcortical_labels", "inputnode.subcortical_labels")]),
989+
# (bold_surf_wf, bold_grayords_wf, [
990+
# ('outputnode.surfaces', 'inputnode.surf_files'),
991+
# ('outputnode.target', 'inputnode.surf_refs')]),
992+
(bold_t1_trans_wf, bold_fsLR_resampling_wf, [
993+
("outputnode.bold_t1", "inputnode.bold_file")]),
994+
(bold_std_trans_wf, bold_grayords_wf, [
995+
("outputnode.bold_std", "inputnode.bold_std"),
996+
("outputnode.spatial_reference", "inputnode.spatial_reference"),
997+
]),
998+
(bold_fsLR_resampling_wf, bold_grayords_wf, [
999+
("outputnode.bold_fsLR", "inputnode.bold_fsLR"),
1000+
]),
1001+
(bold_fsLR_resampling_wf, func_derivatives_wf, [
1002+
("outputnode.goodvoxels_mask", "inputnode.goodvoxels_mask"),
1003+
]),
1004+
(bold_grayords_wf, outputnode, [
1005+
("outputnode.cifti_bold", "bold_cifti"),
1006+
("outputnode.cifti_metadata", "cifti_metadata"),
1007+
]),
1008+
(bold_grayords_wf, outputnode, [
1009+
('outputnode.cifti_bold', 'bold_cifti'),
1010+
('outputnode.cifti_metadata', 'cifti_metadata')]),
1011+
])
1012+
# fmt:on
10021013

10031014
if spaces.get_spaces(nonstandard=False, dim=(3,)):
10041015
if not config.workflow.cifti_output:

nibabies/workflows/bold/outputs.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def init_func_derivatives_wf(
211211
"cifti_density",
212212
"confounds",
213213
"confounds_metadata",
214-
"goodvoxels_ribbon",
214+
"goodvoxels_mask",
215215
"melodic_mix",
216216
"nonaggr_denoised_file",
217217
"source_file",
@@ -786,7 +786,7 @@ def init_func_derivatives_wf(
786786
# fmt: on
787787

788788
if freesurfer and project_goodvoxels:
789-
ds_goodvoxels_ribbon = pe.Node(
789+
ds_goodvoxels_mask = pe.Node(
790790
DerivativesDataSink(
791791
base_directory=output_dir,
792792
space='T1w',
@@ -795,16 +795,15 @@ def init_func_derivatives_wf(
795795
compress=True,
796796
dismiss_entities=("echo",),
797797
),
798-
name='ds_goodvoxels_ribbon',
798+
name='ds_goodvoxels_mask',
799799
run_without_submitting=True,
800800
mem_gb=config.DEFAULT_MEMORY_MIN_GB,
801801
)
802802
# fmt:off
803803
workflow.connect([
804-
(inputnode, ds_goodvoxels_ribbon, [
804+
(inputnode, ds_goodvoxels_mask, [
805805
('source_file', 'source_file'),
806-
('goodvoxels_ribbon', 'in_file'),
807-
('surf_refs', 'keys')]),
806+
('goodvoxels_mask', 'in_file')]),
808807
])
809808
# fmt:on
810809

0 commit comments

Comments
 (0)