smriprep.interfaces.templateflow module

Interfaces to get templates from TemplateFlow.

class smriprep.interfaces.templateflow.TemplateDesc(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Select template description and name pairs.

This interface is necessary to ensure the good functioning with iterables and JoinNodes.

>>> select = TemplateDesc(template='MNI152NLin2009cAsym')
>>> result = select.run()
>>> result.outputs.name
'MNI152NLin2009cAsym'
>>> result.outputs.spec
{}
>>> select = TemplateDesc(template='MNIPediatricAsym:cohort-2')
>>> result = select.run()
>>> result.outputs.name
'MNIPediatricAsym'
>>> result.outputs.spec
{'cohort': '2'}
Mandatory Inputs:

template (a string) – Univocal template identifier.

Outputs:
  • name (a string) – Template identifier.

  • spec (a dictionary with keys which are any value and with values which are any value) – Template arguments.

class smriprep.interfaces.templateflow.TemplateFlowSelect(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Select TemplateFlow elements.

>>> select = TemplateFlowSelect(resolution=1)
>>> select.inputs.template = 'MNI152NLin2009cAsym'
>>> result = select.run()
>>> result.outputs.t1w_file  
'.../tpl-MNI152NLin2009cAsym_res-01_T1w.nii.gz'
>>> result.outputs.brain_mask  
'.../tpl-MNI152NLin2009cAsym_res-01_desc-brain_mask.nii.gz'
>>> select = TemplateFlowSelect()
>>> select.inputs.template = 'MNIPediatricAsym'
>>> select.inputs.template_spec = {'cohort': 5, 'resolution': 1}
>>> result = select.run()
>>> result.outputs.t1w_file  
'.../tpl-MNIPediatricAsym_cohort-5_res-1_T1w.nii.gz'
>>> select = TemplateFlowSelect(resolution=2)
>>> select.inputs.template = 'MNIPediatricAsym:cohort-5'
>>> select.inputs.template_spec = {'resolution': 1}
>>> result = select.run()
>>> result.outputs.t1w_file  
'.../tpl-MNIPediatricAsym_cohort-5_res-2_T1w.nii.gz'
>>> select = TemplateFlowSelect()
>>> select.inputs.template = 'MNIPediatricAsym:cohort-2'
>>> select.inputs.template_spec = {'cohort': 5, 'resolution': 1}
>>> result = select.run()
>>> result.outputs.t1w_file  
'.../tpl-MNIPediatricAsym_cohort-5_res-1_T1w.nii.gz'
>>> select = TemplateFlowSelect()
>>> select.inputs.template = 'MNI305'
>>> select.inputs.template_spec = {'resolution': 1}
>>> result = select.run()
>>> result.outputs.t1w_file  
'.../tpl-MNI305_T1w.nii.gz'
Mandatory Inputs:

template (a string) – Template ID.

Optional Inputs:
  • atlas (a list of items which are a string) – Specify an atlas.

  • cohort (a list of items which are a string or an integer) – Specify a cohort.

  • resolution (a list of items which are an integer) – Specify a template resolution index.

  • template_spec (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – Template specifications. (Nipype default value: {'atlas': None, 'cohort': None})

Outputs:
  • brain_mask (a pathlike object or string representing an existing file) – Template’s brain mask.

  • t1w_file (a pathlike object or string representing an existing file) – T1w template.

smriprep.interfaces.templateflow.fetch_template_files(template: str, specs: dict | None = None, sloppy: bool = False) dict[source]