Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Use t1w2fsnative_xfm to resample segmentations #201

Merged
merged 3 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ jobs:
pyenv local $PY2
echo -n "Python version: "
python --version
pip install --upgrade pip setuptools
pip install --upgrade "pip<21"
pip install --upgrade setuptools
pip install --upgrade wrapper/
which smriprep-docker
smriprep-docker -i poldracklab/smriprep:latest --help
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'python': ('https://docs.python.org/', None),
'niworkflows': ('https://poldracklab.github.io/niworkflows/', None),
'niworkflows': ('https://www.nipreps.org/niworkflows/', None),
}

# -- Options for versioning extension ----------------------------------------
Expand Down
24 changes: 14 additions & 10 deletions smriprep/workflows/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,12 @@ def init_surface_recon_wf(omp_nthreads, hires, name='surface_recon_wf'):
(autorecon_resume_wf, aseg_to_native_wf, [
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
('outputnode.subject_id', 'inputnode.subject_id')]),
(fsnative2t1w_xfm, aseg_to_native_wf, [('out_reg_file', 'inputnode.fsnative2t1w_xfm')]),
(inputnode, aparc_to_native_wf, [('corrected_t1', 'inputnode.in_file')]),
(autorecon_resume_wf, aparc_to_native_wf, [
('outputnode.subjects_dir', 'inputnode.subjects_dir'),
('outputnode.subject_id', 'inputnode.subject_id')]),
(fsnative2t1w_xfm, aparc_to_native_wf, [('out_reg_file', 'inputnode.fsnative2t1w_xfm')]),
(aseg_to_native_wf, refine, [('outputnode.out_file', 'in_aseg')]),

# Output
Expand Down Expand Up @@ -502,6 +504,8 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):
FreeSurfer SUBJECTS_DIR
subject_id
FreeSurfer subject ID
fsnative2t1w_xfm
LTA-style affine matrix translating from FreeSurfer-conformed subject space to T1w

Outputs
-------
Expand All @@ -510,13 +514,15 @@ def init_segs_to_native_wf(name='segs_to_native', segmentation='aseg'):

"""
workflow = Workflow(name='%s_%s' % (name, segmentation))
inputnode = pe.Node(niu.IdentityInterface([
'in_file', 'subjects_dir', 'subject_id']), name='inputnode')
inputnode = pe.Node(
niu.IdentityInterface(['in_file', 'subjects_dir', 'subject_id', 'fsnative2t1w_xfm']),
name='inputnode')
outputnode = pe.Node(niu.IdentityInterface(['out_file']), name='outputnode')
# Extract the aseg and aparc+aseg outputs
fssource = pe.Node(nio.FreeSurferSource(), name='fs_datasource')
tonative = pe.Node(fs.Label2Vol(), name='tonative')
tonii = pe.Node(fs.MRIConvert(out_type='niigz', resample_type='nearest'), name='tonii')
# Resample from T1.mgz to T1w.nii.gz, applying any offset in fsnative2t1w_xfm,
# and convert to NIfTI while we're at it
resample = pe.Node(fs.ApplyVolTransform(transformed_file='seg.nii.gz'), name='resample')

if segmentation.startswith('aparc'):
if segmentation == 'aparc_aseg':
Expand All @@ -531,12 +537,10 @@ def _sel(x): return [parc for parc in x if 'DKTatlas+' in parc][0] # noqa
(inputnode, fssource, [
('subjects_dir', 'subjects_dir'),
('subject_id', 'subject_id')]),
(inputnode, tonii, [('in_file', 'reslice_like')]),
(fssource, tonative, [(segmentation, 'seg_file'),
('rawavg', 'template_file'),
('aseg', 'reg_header')]),
(tonative, tonii, [('vol_label_file', 'in_file')]),
(tonii, outputnode, [('out_file', 'out_file')]),
(inputnode, resample, [('in_file', 'target_file'),
('fsnative2t1w_xfm', 'lta_file')]),
(fssource, resample, [(segmentation, 'source_file')]),
(resample, outputnode, [('transformed_file', 'out_file')]),
])
return workflow

Expand Down