Skip to content

Commit e6e3501

Browse files
committed
RF: More T1w -> anat substitutions
1 parent ad72b45 commit e6e3501

File tree

1 file changed

+45
-37
lines changed

1 file changed

+45
-37
lines changed

smriprep/workflows/outputs.py

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def init_ds_mask_wf(
342342
Inputs
343343
------
344344
source_files
345-
List of input T1w images
345+
List of input anat images
346346
mask_file
347347
Mask to save
348348
@@ -370,7 +370,7 @@ def init_ds_mask_wf(
370370
suffix='mask',
371371
compress=True,
372372
),
373-
name='ds_t1w_mask',
373+
name='ds_anat_mask',
374374
run_without_submitting=True,
375375
)
376376
if mask_type == 'brain':
@@ -391,7 +391,7 @@ def init_ds_mask_wf(
391391
return workflow
392392

393393

394-
def init_ds_dseg_wf(*, output_dir, name='ds_dseg_wf'):
394+
def init_ds_dseg_wf(*, output_dir: str, name: str = 'ds_dseg_wf'):
395395
"""
396396
Save discrete segmentations
397397
@@ -405,23 +405,23 @@ def init_ds_dseg_wf(*, output_dir, name='ds_dseg_wf'):
405405
Inputs
406406
------
407407
source_files
408-
List of input T1w images
409-
t1w_dseg
410-
Segmentation in T1w space
408+
List of input anatomical images
409+
anat_dseg
410+
Segmentation in anatomical space
411411
412412
Outputs
413413
-------
414-
t1w_dseg
414+
anat_dseg
415415
The location in the output directory of the discrete segmentation
416416
417417
"""
418418
workflow = Workflow(name=name)
419419

420420
inputnode = pe.Node(
421-
niu.IdentityInterface(fields=['source_files', 't1w_dseg']),
421+
niu.IdentityInterface(fields=['source_files', 'anat_dseg']),
422422
name='inputnode',
423423
)
424-
outputnode = pe.Node(niu.IdentityInterface(fields=['t1w_dseg']), name='outputnode')
424+
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_dseg']), name='outputnode')
425425

426426
ds_t1w_dseg = pe.Node(
427427
DerivativesDataSink(
@@ -430,22 +430,27 @@ def init_ds_dseg_wf(*, output_dir, name='ds_dseg_wf'):
430430
compress=True,
431431
dismiss_entities=['desc'],
432432
),
433-
name='ds_t1w_dseg',
433+
name='ds_anat_dseg',
434434
run_without_submitting=True,
435435
)
436436

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

445445
return workflow
446446

447447

448-
def init_ds_tpms_wf(*, output_dir, name='ds_tpms_wf', tpm_labels=BIDS_TISSUE_ORDER):
448+
def init_ds_tpms_wf(
449+
*,
450+
output_dir: str,
451+
name: str = 'ds_tpms_wf',
452+
tpm_labels: tuple = BIDS_TISSUE_ORDER,
453+
):
449454
"""
450455
Save tissue probability maps
451456
@@ -461,23 +466,23 @@ def init_ds_tpms_wf(*, output_dir, name='ds_tpms_wf', tpm_labels=BIDS_TISSUE_ORD
461466
Inputs
462467
------
463468
source_files
464-
List of input T1w images
465-
t1w_tpms
466-
Tissue probability maps in T1w space
469+
List of input anatomical images
470+
anat_tpms
471+
Tissue probability maps in anatomical space
467472
468473
Outputs
469474
-------
470-
t1w_tpms
475+
anat_tpms
471476
The location in the output directory of the tissue probability maps
472477
473478
"""
474479
workflow = Workflow(name=name)
475480

476481
inputnode = pe.Node(
477-
niu.IdentityInterface(fields=['source_files', 't1w_tpms']),
482+
niu.IdentityInterface(fields=['source_files', 'anat_tpms']),
478483
name='inputnode',
479484
)
480-
outputnode = pe.Node(niu.IdentityInterface(fields=['t1w_tpms']), name='outputnode')
485+
outputnode = pe.Node(niu.IdentityInterface(fields=['anat_tpms']), name='outputnode')
481486

482487
ds_t1w_tpms = pe.Node(
483488
DerivativesDataSink(
@@ -486,16 +491,16 @@ def init_ds_tpms_wf(*, output_dir, name='ds_tpms_wf', tpm_labels=BIDS_TISSUE_ORD
486491
compress=True,
487492
dismiss_entities=['desc'],
488493
),
489-
name='ds_t1w_tpms',
494+
name='ds_anat_tpms',
490495
run_without_submitting=True,
491496
)
492497
ds_t1w_tpms.inputs.label = tpm_labels
493498

494499
# fmt:off
495500
workflow.connect([
496-
(inputnode, ds_t1w_tpms, [('t1w_tpms', 'in_file'),
501+
(inputnode, ds_t1w_tpms, [('anat_tpms', 'in_file'),
497502
('source_files', 'source_file')]),
498-
(ds_t1w_tpms, outputnode, [('out_file', 't1w_tpms')]),
503+
(ds_t1w_tpms, outputnode, [('out_file', 'anat_tpms')]),
499504
])
500505
# fmt:on
501506

@@ -504,8 +509,9 @@ def init_ds_tpms_wf(*, output_dir, name='ds_tpms_wf', tpm_labels=BIDS_TISSUE_ORD
504509

505510
def init_ds_template_registration_wf(
506511
*,
507-
output_dir,
508-
name='ds_template_registration_wf',
512+
output_dir: str,
513+
image_type: ty.Literal['T1w', 'T2w'] = 'T1w',
514+
name: str = 'ds_template_registration_wf',
509515
):
510516
"""
511517
Save template registration transforms
@@ -514,6 +520,8 @@ def init_ds_template_registration_wf(
514520
----------
515521
output_dir : :obj:`str`
516522
Directory in which to save derivatives
523+
image_type : :obj:`str`
524+
Anatomical image type (T1w, T2w, etc)
517525
name : :obj:`str`
518526
Workflow name (default: anat_derivatives_wf)
519527
@@ -522,7 +530,7 @@ def init_ds_template_registration_wf(
522530
template
523531
Template space and specifications
524532
source_files
525-
List of input T1w images
533+
List of input anatomical images
526534
anat2std_xfm
527535
Nonlinear spatial transform to resample imaging data given in anatomical space
528536
into standard space.
@@ -541,44 +549,44 @@ def init_ds_template_registration_wf(
541549
name='outputnode',
542550
)
543551

544-
ds_std2t1w_xfm = pe.MapNode(
552+
ds_std2anat_xfm = pe.MapNode(
545553
DerivativesDataSink(
546554
base_directory=output_dir,
547-
to='T1w',
555+
to=image_type,
548556
mode='image',
549557
suffix='xfm',
550558
dismiss_entities=['desc'],
551559
),
552560
iterfield=('in_file', 'from'),
553-
name='ds_std2t1w_xfm',
561+
name='ds_std2anat_xfm',
554562
run_without_submitting=True,
555563
)
556564

557-
ds_t1w2std_xfm = pe.MapNode(
565+
ds_anat2std_xfm = pe.MapNode(
558566
DerivativesDataSink(
559567
base_directory=output_dir,
560568
mode='image',
561569
suffix='xfm',
562570
dismiss_entities=['desc'],
563-
**{'from': 'T1w'},
571+
**{'from': image_type},
564572
),
565573
iterfield=('in_file', 'to'),
566-
name='ds_t1w2std_xfm',
574+
name='ds_anat2std_xfm',
567575
run_without_submitting=True,
568576
)
569577

570578
# fmt:off
571579
workflow.connect([
572-
(inputnode, ds_t1w2std_xfm, [
580+
(inputnode, ds_anat2std_xfm, [
573581
('anat2std_xfm', 'in_file'),
574582
(('template', _combine_cohort), 'to'),
575583
('source_files', 'source_file')]),
576-
(inputnode, ds_std2t1w_xfm, [
584+
(inputnode, ds_std2anat_xfm, [
577585
('std2anat_xfm', 'in_file'),
578586
(('template', _combine_cohort), 'from'),
579587
('source_files', 'source_file')]),
580-
(ds_t1w2std_xfm, outputnode, [('out_file', 'anat2std_xfm')]),
581-
(ds_std2t1w_xfm, outputnode, [('out_file', 'std2anat_xfm')]),
588+
(ds_anat2std_xfm, outputnode, [('out_file', 'anat2std_xfm')]),
589+
(ds_std2anat_xfm, outputnode, [('out_file', 'std2anat_xfm')]),
582590
])
583591
# fmt:on
584592

@@ -587,8 +595,8 @@ def init_ds_template_registration_wf(
587595

588596
def init_ds_fs_registration_wf(
589597
*,
590-
output_dir,
591-
name='ds_fs_registration_wf',
598+
output_dir: str,
599+
name: str = 'ds_fs_registration_wf',
592600
):
593601
"""
594602
Save rigid registration between subject anatomical template and FreeSurfer T1.mgz

0 commit comments

Comments
 (0)