Skip to content

Commit 780f875

Browse files
committed
FIX: Use fsnative2t1w_xfm to resample segmentations
1 parent d8fe13d commit 780f875

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

smriprep/workflows/surfaces.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,12 @@ def init_surface_recon_wf(omp_nthreads, hires, name='surface_recon_wf'):
231231
(autorecon_resume_wf, aseg_to_native_wf, [
232232
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
233233
('outputnode.subject_id', 'inputnode.subject_id')]),
234+
(fsnative2t1w_xfm, aseg_to_native_wf, [('out_reg_file', 'inputnode.fsnative2t1w_xfm')]),
234235
(inputnode, aparc_to_native_wf, [('corrected_t1', 'inputnode.in_file')]),
235236
(autorecon_resume_wf, aparc_to_native_wf, [
236237
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
237238
('outputnode.subject_id', 'inputnode.subject_id')]),
239+
(fsnative2t1w_xfm, aparc_to_native_wf, [('out_reg_file', 'inputnode.fsnative2t1w_xfm')]),
238240
(aseg_to_native_wf, refine, [('outputnode.out_file', 'in_aseg')]),
239241

240242
# Output
@@ -502,6 +504,8 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):
502504
FreeSurfer SUBJECTS_DIR
503505
subject_id
504506
FreeSurfer subject ID
507+
fsnative2t1w_xfm
508+
LTA-style affine matrix translating from FreeSurfer-conformed subject space to T1w
505509
506510
Outputs
507511
-------
@@ -510,13 +514,15 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):
510514
511515
"""
512516
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')
515520
outputnode = pe.Node(niu.IdentityInterface(['out_file']), name='outputnode')
516521
# Extract the aseg and aparc+aseg outputs
517522
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')
520526

521527
if segmentation.startswith('aparc'):
522528
if segmentation == 'aparc_aseg':
@@ -531,12 +537,10 @@ def _sel(x): return [parc for parc in x if 'DKTatlas+' in parc][0] # noqa
531537
(inputnode, fssource, [
532538
('subjects_dir', 'subjects_dir'),
533539
('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')]),
540544
])
541545
return workflow
542546

0 commit comments

Comments
 (0)