@@ -231,10 +231,12 @@ def init_surface_recon_wf(omp_nthreads, hires, name='surface_recon_wf'):
231
231
(autorecon_resume_wf , aseg_to_native_wf , [
232
232
('outputnode.subjects_dir' , 'inputnode.subjects_dir' ),
233
233
('outputnode.subject_id' , 'inputnode.subject_id' )]),
234
+ (fsnative2t1w_xfm , aseg_to_native_wf , [('out_reg_file' , 'inputnode.fsnative2t1w_xfm' )]),
234
235
(inputnode , aparc_to_native_wf , [('corrected_t1' , 'inputnode.in_file' )]),
235
236
(autorecon_resume_wf , aparc_to_native_wf , [
236
237
('outputnode.subjects_dir' , 'inputnode.subjects_dir' ),
237
238
('outputnode.subject_id' , 'inputnode.subject_id' )]),
239
+ (fsnative2t1w_xfm , aparc_to_native_wf , [('out_reg_file' , 'inputnode.fsnative2t1w_xfm' )]),
238
240
(aseg_to_native_wf , refine , [('outputnode.out_file' , 'in_aseg' )]),
239
241
240
242
# Output
@@ -502,6 +504,8 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):
502
504
FreeSurfer SUBJECTS_DIR
503
505
subject_id
504
506
FreeSurfer subject ID
507
+ fsnative2t1w_xfm
508
+ LTA-style affine matrix translating from FreeSurfer-conformed subject space to T1w
505
509
506
510
Outputs
507
511
-------
@@ -510,13 +514,15 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):
510
514
511
515
"""
512
516
workflow = Workflow (name = '%s_%s' % (name , segmentation ))
513
- inputnode = pe .Node (niu .IdentityInterface ([
514
- 'in_file' , 'subjects_dir' , 'subject_id' ]), name = 'inputnode' )
517
+ inputnode = pe .Node (
518
+ niu .IdentityInterface (['in_file' , 'subjects_dir' , 'subject_id' , 'fsnative2t1w_xfm' ]),
519
+ name = 'inputnode' )
515
520
outputnode = pe .Node (niu .IdentityInterface (['out_file' ]), name = 'outputnode' )
516
521
# Extract the aseg and aparc+aseg outputs
517
522
fssource = pe .Node (nio .FreeSurferSource (), name = 'fs_datasource' )
518
- tonative = pe .Node (fs .Label2Vol (), name = 'tonative' )
519
- tonii = pe .Node (fs .MRIConvert (out_type = 'niigz' , resample_type = 'nearest' ), name = 'tonii' )
523
+ # Resample from T1.mgz to T1w.nii.gz, applying any offset in fsnative2t1w_xfm,
524
+ # and convert to NIfTI while we're at it
525
+ resample = pe .Node (fs .ApplyVolTransform (transformed_file = 'seg.nii.gz' ), name = 'resample' )
520
526
521
527
if segmentation .startswith ('aparc' ):
522
528
if segmentation == 'aparc_aseg' :
@@ -531,12 +537,10 @@ def _sel(x): return [parc for parc in x if 'DKTatlas+' in parc][0] # noqa
531
537
(inputnode , fssource , [
532
538
('subjects_dir' , 'subjects_dir' ),
533
539
('subject_id' , 'subject_id' )]),
534
- (inputnode , tonii , [('in_file' , 'reslice_like' )]),
535
- (fssource , tonative , [(segmentation , 'seg_file' ),
536
- ('rawavg' , 'template_file' ),
537
- ('aseg' , 'reg_header' )]),
538
- (tonative , tonii , [('vol_label_file' , 'in_file' )]),
539
- (tonii , outputnode , [('out_file' , 'out_file' )]),
540
+ (inputnode , resample , [('in_file' , 'target_file' ),
541
+ ('fsnative2t1w_xfm' , 'lta_file' )]),
542
+ (fssource , resample , [(segmentation , 'source_file' )]),
543
+ (resample , outputnode , [('transformed_file' , 'out_file' )]),
540
544
])
541
545
return workflow
542
546
0 commit comments