Skip to content

Commit eccdb3a

Browse files
committed
ENH: Add t2star outputs
1 parent c7c51fb commit eccdb3a

File tree

2 files changed

+70
-14
lines changed

2 files changed

+70
-14
lines changed

nibabies/workflows/bold/base.py

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,9 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
346346
outputnode = pe.Node(
347347
niu.IdentityInterface(
348348
fields=[
349+
"anat2bold_xfm",
349350
"bold_anat",
350351
"bold_anat_ref",
351-
"bold2anat_xfm",
352-
"anat2bold_xfm",
353352
"bold_mask_anat",
354353
"bold_aseg_anat",
355354
"bold_aparc_anat",
@@ -363,6 +362,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
363362
"bold_mask_native",
364363
"bold_echos_native",
365364
"bold_cifti",
365+
"bold2anat_xfm",
366366
"cifti_variant",
367367
"cifti_metadata",
368368
"cifti_density",
@@ -433,6 +433,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
433433
('bold_anat_ref', 'inputnode.bold_t1_ref'),
434434
('bold2anat_xfm', 'inputnode.bold2anat_xfm'),
435435
('anat2bold_xfm', 'inputnode.anat2bold_xfm'),
436+
('hmc_xforms', 'inputnode.hmc_xforms'),
436437
('bold_aseg_anat', 'inputnode.bold_aseg_t1'),
437438
('bold_aparc_anat', 'inputnode.bold_aparc_t1'),
438439
('bold_mask_anat', 'inputnode.bold_mask_t1'),
@@ -449,6 +450,9 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
449450
('cifti_variant', 'inputnode.cifti_variant'),
450451
('cifti_metadata', 'inputnode.cifti_metadata'),
451452
('cifti_density', 'inputnode.cifti_density'),
453+
('t2star_bold', 'inputnode.t2star_bold'),
454+
('t2star_t1', 'inputnode.t2star_t1'),
455+
('t2star_std', 'inputnode.t2star_std'),
452456
('confounds_metadata', 'inputnode.confounds_metadata'),
453457
('acompcor_masks', 'inputnode.acompcor_masks'),
454458
('tcompcor_mask', 'inputnode.tcompcor_mask'),
@@ -548,7 +552,8 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
548552
)
549553

550554
bold_final = pe.Node(
551-
niu.IdentityInterface(fields=["bold", "boldref", "mask", "bold_echos"]), name="bold_final"
555+
niu.IdentityInterface(fields=["bold", "boldref", "mask", "bold_echos", "t2star"]),
556+
name="bold_final",
552557
)
553558

554559
# Mask input BOLD reference image
@@ -580,6 +585,9 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
580585
('bold_ref', 'inputnode.raw_ref_image')]),
581586
(validate_bolds, bold_hmc_wf, [
582587
(("out_file", pop_file), 'inputnode.bold_file')]),
588+
(bold_hmc_wf, outputnode, [
589+
("outputnode.xforms", "hmc_xforms"),
590+
]),
583591
# Native-space BOLD files
584592
(final_boldref_wf, final_boldref_mask, [('outputnode.epi_ref_file', 'in_file')]),
585593
(final_boldref_wf, bold_final, [('outputnode.epi_ref_file', 'boldref')]),
@@ -589,6 +597,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
589597
('boldref', 'bold_native_ref'),
590598
('mask', 'bold_mask_native'),
591599
('bold_echos', 'bold_echos_native'),
600+
('t2star', 't2star_bold'),
592601
]),
593602
# EPI-T1 registration workflow
594603
(inputnode, bold_reg_wf, [
@@ -668,15 +677,22 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
668677
workflow.connect([
669678
# update name source for optimal combination
670679
(inputnode, func_derivatives_wf, [
671-
(('bold_file', combine_meepi_source), 'inputnode.source_file')]),
672-
(join_echos, bold_t2s_wf, [
673-
('bold_files', 'inputnode.bold_file')]),
674-
(bold_t2s_wf, split_opt_comb, [
675-
('outputnode.bold', 'in_file')]),
676-
(split_opt_comb, bold_t1_trans_wf, [
677-
("out_files", "inputnode.bold_split")]),
680+
(("bold_file", combine_meepi_source), "inputnode.source_file"),
681+
]),
682+
(join_echos, bold_t2s_wf, [("bold_files", "inputnode.bold_file")]),
678683
(join_echos, bold_final, [("bold_files", "bold_echos")]),
679-
(bold_t2s_wf, bold_final, [("outputnode.bold", "bold")]),
684+
(bold_t2s_wf, split_opt_comb, [("outputnode.bold", "in_file")]),
685+
(split_opt_comb, bold_t1_trans_wf, [("out_files", "inputnode.bold_split")]),
686+
(bold_t2s_wf, bold_final, [("outputnode.bold", "bold"),
687+
("outputnode.t2star_map", "t2star")]),
688+
(inputnode, t2s_reporting_wf, [("anat_dseg", "inputnode.label_file")]),
689+
(bold_reg_wf, t2s_reporting_wf, [
690+
("outputnode.itk_t1_to_bold", "inputnode.label_bold_xform")
691+
]),
692+
(bold_final, t2s_reporting_wf, [("t2star", "inputnode.t2star_file"),
693+
("boldref", "inputnode.boldref")]),
694+
(t2s_reporting_wf, ds_report_t2scomp, [('outputnode.t2s_comp_report', 'in_file')]),
695+
(t2s_reporting_wf, ds_report_t2star_hist, [("outputnode.t2star_hist", "in_file")]),
680696
])
681697
# fmt:on
682698

@@ -704,6 +720,23 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
704720
])
705721
# fmt:on
706722

723+
if multiecho:
724+
t2star_to_t1w = pe.Node(
725+
ApplyTransforms(interpolation="LanczosWindowedSinc", float=True),
726+
name="t2star_to_t1w",
727+
mem_gb=0.1,
728+
)
729+
# fmt:off
730+
workflow.connect([
731+
(bold_reg_wf, t2star_to_t1w, [("outputnode.itk_bold_to_t1", "transforms")]),
732+
(bold_t1_trans_wf, t2star_to_t1w, [
733+
("outputnode.bold_mask_t1", "reference_image")
734+
]),
735+
(bold_final, t2star_to_t1w, [("t2star", "input_image")]),
736+
(t2star_to_t1w, outputnode, [("output_image", "t2star_t1")]),
737+
])
738+
# fmt:on
739+
707740
if spaces.get_spaces(nonstandard=False, dim=(3,)):
708741
# Apply transforms in 1 shot
709742
# Only use uncompressed output if AROMA is to be run
@@ -712,6 +745,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
712745
mem_gb=mem_gb["resampled"],
713746
omp_nthreads=omp_nthreads,
714747
spaces=spaces,
748+
multiecho=multiecho,
715749
name="bold_std_trans_wf",
716750
use_compression=not config.execution.low_mem,
717751
)
@@ -727,6 +761,7 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
727761
('anat_aparc', 'inputnode.bold_aparc')]),
728762
(bold_final, bold_std_trans_wf, [
729763
('mask', 'inputnode.bold_mask'),
764+
('t2star', 'inputnode.t2star'),
730765
]),
731766
(bold_reg_wf, bold_std_trans_wf, [
732767
('outputnode.itk_bold_to_t1', 'inputnode.itk_bold_to_t1')]),
@@ -761,8 +796,8 @@ def init_func_preproc_wf(bold_file, has_fieldmap=False, existing_derivatives=Non
761796
else:
762797
# fmt:off
763798
workflow.connect([
764-
(split_opt_comb, bold_std_trans_wf, [
765-
('out_files', 'inputnode.bold_split')])
799+
(split_opt_comb, bold_std_trans_wf, [('out_files', 'inputnode.bold_split')]),
800+
(bold_std_trans_wf, outputnode, [("outputnode.t2star_std", "t2star_std")]),
766801
])
767802
# fmt:on
768803

nibabies/workflows/bold/resampling.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def init_bold_std_trans_wf(
182182
mem_gb,
183183
omp_nthreads,
184184
spaces,
185+
multiecho,
185186
name="bold_std_trans_wf",
186187
use_compression=True,
187188
):
@@ -321,6 +322,7 @@ def init_bold_std_trans_wf(
321322
"bold_aseg",
322323
"bold_mask",
323324
"bold_split",
325+
"t2star",
324326
"fieldwarp",
325327
"hmc_xforms",
326328
"itk_bold_to_t1",
@@ -426,7 +428,11 @@ def init_bold_std_trans_wf(
426428
"bold_std_ref",
427429
"spatial_reference",
428430
"template",
429-
] + freesurfer * ["bold_aseg_std", "bold_aparc_std"]
431+
]
432+
if freesurfer:
433+
output_names.extend(["bold_aseg_std", "bold_aparc_std"])
434+
if multiecho:
435+
output_names.append("t2star_std")
430436

431437
poutputnode = pe.Node(niu.IdentityInterface(fields=output_names), name="poutputnode")
432438
# fmt: off
@@ -463,6 +469,21 @@ def init_bold_std_trans_wf(
463469
])
464470
# fmt: on
465471

472+
if multiecho:
473+
t2star_std_tfm = pe.Node(
474+
ApplyTransforms(interpolation="LanczosWindowedSinc", float=True),
475+
name="t2star_std_tfm",
476+
mem_gb=1,
477+
)
478+
# fmt:off
479+
workflow.connect([
480+
(inputnode, t2star_std_tfm, [("t2star", "input_image")]),
481+
(select_std, t2star_std_tfm, [("anat2std_xfm", "transforms")]),
482+
(gen_ref, t2star_std_tfm, [("out_file", "reference_image")]),
483+
(t2star_std_tfm, poutputnode, [("output_image", "t2star_std")]),
484+
])
485+
# fmt:on
486+
466487
# Connect parametric outputs to a Join outputnode
467488
outputnode = pe.JoinNode(
468489
niu.IdentityInterface(fields=output_names), name="outputnode", joinsource="iterablesource"

0 commit comments

Comments
 (0)