Skip to content

Commit 54fc2ff

Browse files
committed
RF: Make more functions anatagnostic
1 parent e6e3501 commit 54fc2ff

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

smriprep/workflows/outputs.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
423423
)
424424
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_dseg']), name='outputnode')
425425

426-
ds_t1w_dseg = pe.Node(
426+
ds_anat_dseg = pe.Node(
427427
DerivativesDataSink(
428428
base_directory=output_dir,
429429
suffix='dseg',
@@ -436,9 +436,9 @@ def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
436436

437437
# fmt:off
438438
workflow.connect([
439-
(inputnode, ds_t1w_dseg, [('anat_dseg', 'in_file'),
439+
(inputnode, ds_anat_dseg, [('anat_dseg', 'in_file'),
440440
('source_files', 'source_file')]),
441-
(ds_t1w_dseg, outputnode, [('out_file', 'anat_dseg')]),
441+
(ds_anat_dseg, outputnode, [('out_file', 'anat_dseg')]),
442442
])
443443
# fmt:on
444444

@@ -484,7 +484,7 @@ def init_ds_tpms_wf(
484484
)
485485
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_tpms']), name='outputnode')
486486

487-
ds_t1w_tpms = pe.Node(
487+
ds_anat_tpms = pe.Node(
488488
DerivativesDataSink(
489489
base_directory=output_dir,
490490
suffix='probseg',
@@ -494,13 +494,13 @@ def init_ds_tpms_wf(
494494
name='ds_anat_tpms',
495495
run_without_submitting=True,
496496
)
497-
ds_t1w_tpms.inputs.label = tpm_labels
497+
ds_anat_tpms.inputs.label = tpm_labels
498498

499499
# fmt:off
500500
workflow.connect([
501-
(inputnode, ds_t1w_tpms, [('anat_tpms', 'in_file'),
501+
(inputnode, ds_anat_tpms, [('anat_tpms', 'in_file'),
502502
('source_files', 'source_file')]),
503-
(ds_t1w_tpms, outputnode, [('out_file', 'anat_tpms')]),
503+
(ds_anat_tpms, outputnode, [('out_file', 'anat_tpms')]),
504504
])
505505
# fmt:on
506506

@@ -596,10 +596,12 @@ def init_ds_template_registration_wf(
596596
def init_ds_fs_registration_wf(
597597
*,
598598
output_dir: str,
599+
image_type: ty.Literal['T1w', 'T2w'] = 'T1w',
599600
name: str = 'ds_fs_registration_wf',
600601
):
601602
"""
602-
Save rigid registration between subject anatomical template and FreeSurfer T1.mgz
603+
Save rigid registration between subject anatomical template and either
604+
FreeSurfer T1.mgz or T2.mgz
603605
604606
Parameters
605607
----------
@@ -611,70 +613,70 @@ def init_ds_fs_registration_wf(
611613
Inputs
612614
------
613615
source_files
614-
List of input T1w images
615-
fsnative2t1w_xfm
616+
List of input anatomical images
617+
fsnative2anat_xfm
616618
LTA-style affine matrix translating from FreeSurfer-conformed
617-
subject space to T1w
619+
subject space to T1/T2
618620
619621
Outputs
620622
-------
621-
t1w2fsnative_xfm
622-
LTA-style affine matrix translating from T1w to
623+
anat2fsnative_xfm
624+
LTA-style affine matrix translating from T1/T2 to
623625
FreeSurfer-conformed subject space
624-
fsnative2t1w_xfm
626+
fsnative2anat_xfm
625627
LTA-style affine matrix translating from FreeSurfer-conformed
626628
subject space to T1w
627629
628630
"""
629631
workflow = Workflow(name=name)
630632

631633
inputnode = pe.Node(
632-
niu.IdentityInterface(fields=['source_files', 'fsnative2t1w_xfm']),
634+
niu.IdentityInterface(fields=['source_files', 'fsnative2anat_xfm']),
633635
name='inputnode',
634636
)
635637
outputnode = pe.Node(
636-
niu.IdentityInterface(fields=['fsnative2t1w_xfm', 't1w2fsnative_xfm']),
638+
niu.IdentityInterface(fields=['fsnative2anat_xfm', 'anat2fsnative_xfm']),
637639
name='outputnode',
638640
)
639641

640642
from niworkflows.interfaces.nitransforms import ConcatenateXFMs
641643

642644
# FS native space transforms
643645
lta2itk = pe.Node(ConcatenateXFMs(inverse=True), name='lta2itk', run_without_submitting=True)
644-
ds_t1w_fsnative = pe.Node(
646+
ds_anat_fsnative = pe.Node(
645647
DerivativesDataSink(
646648
base_directory=output_dir,
647649
mode='image',
648650
to='fsnative',
649651
suffix='xfm',
650652
extension='txt',
651-
**{'from': 'T1w'},
653+
**{'from': image_type},
652654
),
653-
name='ds_t1w_fsnative',
655+
name='ds_anat_fsnative',
654656
run_without_submitting=True,
655657
)
656-
ds_fsnative_t1w = pe.Node(
658+
ds_fsnative_anat = pe.Node(
657659
DerivativesDataSink(
658660
base_directory=output_dir,
659661
mode='image',
660-
to='T1w',
662+
to=image_type,
661663
suffix='xfm',
662664
extension='txt',
663665
**{'from': 'fsnative'},
664666
),
665-
name='ds_fsnative_t1w',
667+
name='ds_fsnative_anat',
666668
run_without_submitting=True,
667669
)
668670

669671
# fmt:off
670672
workflow.connect([
671-
(inputnode, lta2itk, [('fsnative2t1w_xfm', 'in_xfms')]),
672-
(inputnode, ds_t1w_fsnative, [('source_files', 'source_file')]),
673-
(lta2itk, ds_t1w_fsnative, [('out_inv', 'in_file')]),
674-
(inputnode, ds_fsnative_t1w, [('source_files', 'source_file')]),
675-
(lta2itk, ds_fsnative_t1w, [('out_xfm', 'in_file')]),
676-
(ds_fsnative_t1w, outputnode, [('out_file', 'fsnative2t1w_xfm')]),
677-
(ds_t1w_fsnative, outputnode, [('out_file', 't1w2fsnative_xfm')]),
673+
(inputnode, lta2itk, [('fsnative2anat_xfm', 'in_xfms')]),
674+
(inputnode, ds_anat_fsnative, [('source_files', 'source_file')]),
675+
(lta2itk, ds_anat_fsnative, [('out_inv', 'in_file')]),
676+
(inputnode, ds_fsnative_anat, [('source_files', 'source_file')]),
677+
(lta2itk, ds_fsnative_anat, [('out_xfm', 'in_file')]),
678+
(ds_fsnative_anat, outputnode, [('out_file', 'fsnative2anat_xfm')]),
679+
(ds_anat_fsnative, outputnode, [('out_file', 'anat2fsnative_xfm')]),
678680
])
679681
# fmt:on
680682
return workflow
@@ -704,7 +706,7 @@ def init_ds_surfaces_wf(
704706
Inputs
705707
------
706708
source_files
707-
List of input T1w images
709+
List of input anatomical images
708710
``<surface>``
709711
Left and right GIFTIs for each surface passed to ``surfaces``
710712

0 commit comments

Comments
 (0)