Skip to content

Commit 813b597

Browse files
committed
[ENH] Remaining TemplateFlow integrations
1 parent effe0a2 commit 813b597

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

fmriprep/workflows/bold/confounds.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from nipype.interfaces import utility as niu, fsl
1414
from nipype.algorithms import confounds as nac
1515

16-
from niworkflows.data import get_template
16+
from templateflow.api import get as get_template
1717
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
1818
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
1919
from niworkflows.interfaces.images import SignalExtraction
@@ -360,9 +360,8 @@ def init_carpetplot_wf(mem_gb, metadata, name="bold_carpet_wf"):
360360
# Warp segmentation into EPI space
361361
resample_parc = pe.Node(ApplyTransforms(
362362
float=True,
363-
input_image=str(
364-
get_template('MNI152NLin2009cAsym') /
365-
'tpl-MNI152NLin2009cAsym_space-MNI_res-01_label-carpet_atlas.nii.gz'),
363+
input_image=get_template('MNI152NLin2009cAsym',
364+
'_res-01_desc-carpet_dseg.nii.gz'),
366365
dimension=3, default_value=0, interpolation='MultiLabel'),
367366
name='resample_parc')
368367

@@ -537,8 +536,7 @@ def init_ica_aroma_wf(template, metadata, mem_gb, omp_nthreads,
537536
freesurfer=False,
538537
mem_gb=mem_gb,
539538
omp_nthreads=omp_nthreads,
540-
template_out_grid=str(
541-
get_template('MNI152Lin') / 'tpl-MNI152Lin_space-MNI_res-02_T1w.nii.gz'),
539+
template_out_grid=get_template('MNI152Lin', 'res-02_T1w.nii.gz'),
542540
use_compression=False,
543541
use_fieldwarp=use_fieldwarp,
544542
name='bold_mni_trans_wf'

fmriprep/workflows/bold/resampling.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from nipype.interfaces import utility as niu, freesurfer as fs
1515
from nipype.interfaces.fsl import Split as FSLSplit
1616

17-
from niworkflows.data import get_template, TEMPLATE_ALIASES
17+
from templateflow.api import get as get_template
1818
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
1919
from niworkflows.interfaces.fixes import FixHeaderApplyTransforms as ApplyTransforms
2020
from niworkflows.interfaces.freesurfer import (
@@ -282,13 +282,7 @@ def _aslist(in_value):
282282

283283
gen_ref = pe.Node(GenerateSamplingReference(), name='gen_ref',
284284
mem_gb=0.3) # 256x256x256 * 64 / 8 ~ 150MB)
285-
# Account for template aliases
286-
template_name = TEMPLATE_ALIASES.get(template, template)
287-
# Template path
288-
template_dir = get_template(template_name)
289-
290-
gen_ref.inputs.fixed_image = str(
291-
template_dir / ('tpl-%s_space-MNI_res-01_T1w.nii.gz' % template_name))
285+
gen_ref.inputs.fixed_image = get_template(template, '_res-01_T1w.nii.gz')
292286

293287
mask_mni_tfm = pe.Node(
294288
ApplyTransforms(interpolation='MultiLabel', float=True),
@@ -348,12 +342,10 @@ def _aslist(in_value):
348342
])
349343
elif template_out_grid in ['1mm', '2mm']:
350344
res = int(template_out_grid[0])
351-
mask_mni_tfm.inputs.reference_image = str(
352-
template_dir /
353-
('tpl-%s_space-MNI_res-%02d_brainmask.nii.gz' % (template_name, res)))
354-
bold_to_mni_transform.inputs.reference_image = str(
355-
template_dir /
356-
('tpl-%s_space-MNI_res-%02d_T1w.nii.gz' % (template_name, res)))
345+
mask_mni_tfm.inputs.reference_image = get_template(
346+
template, '_res-%02d_desc-brain_mask.nii.gz' % res)
347+
bold_to_mni_transform.inputs.reference_image = get_template(
348+
template, '_res-%02d_T1w.nii.gz' % res)
357349
else:
358350
mask_mni_tfm.inputs.reference_image = template_out_grid
359351
bold_to_mni_transform.inputs.reference_image = template_out_grid
@@ -382,12 +374,10 @@ def _aslist(in_value):
382374
])
383375
elif template_out_grid in ['1mm', '2mm']:
384376
res = int(template_out_grid[0])
385-
aseg_mni_tfm.inputs.reference_image = str(
386-
template_dir /
387-
('tpl-%s_space-MNI_res-%02d_brainmask.nii.gz' % (template_name, res)))
388-
aparc_mni_tfm.inputs.reference_image = str(
389-
template_dir /
390-
('tpl-%s_space-MNI_res-%02d_T1w.nii.gz' % (template_name, res)))
377+
aseg_mni_tfm.inputs.reference_image = get_template(
378+
template, '_res-%02d_desc-brain_mask.nii.gz' % res)
379+
aparc_mni_tfm.inputs.reference_image = get_template(
380+
template, '_res-%02d_desc-brain_mask.nii.gz' % res)
391381
else:
392382
aseg_mni_tfm.inputs.reference_image = template_out_grid
393383
aparc_mni_tfm.inputs.reference_image = template_out_grid

fmriprep/workflows/bold/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
from nipype.pipeline import engine as pe
1717
from nipype.interfaces import utility as niu, fsl, afni, ants
18-
from niworkflows.data import get_template
18+
19+
from templateflow.api import get as get_template
20+
1921
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
2022
from niworkflows.interfaces.ants import AI
2123
from niworkflows.interfaces.fixes import (
@@ -273,9 +275,8 @@ def init_enhance_and_skullstrip_bold_wf(
273275
apply_mask = pe.Node(fsl.ApplyMask(), name='apply_mask')
274276

275277
if not pre_mask:
276-
bold_template = get_template('fMRIPrep') / 'tpl-fMRIPrep_space-MNI_res-02_boldref.nii.gz'
277-
brain_mask = get_template('MNI152NLin2009cAsym') / \
278-
'tpl-MNI152NLin2009cAsym_space-MNI_res-02_brainmask.nii.gz'
278+
bold_template = get_template('fMRIPrep', 'space-MNI_res-02_boldref.nii.gz')
279+
brain_mask = get_template('MNI152NLin2009cAsym', 'res-02_desc-brain_mask.nii.gz')
279280

280281
# Initialize transforms with antsAI
281282
init_aff = pe.Node(AI(

0 commit comments

Comments
 (0)