templateflow.api module

TemplateFlow’s Python Client.

templateflow.api.get(template, raise_empty=False, **kwargs)[source]

Fetch one file from one particular template.

Parameters
  • template (str) – A template identifier (e.g., MNI152NLin2009cAsym).

  • raise_empty (bool, optional) – Raise exception if no files were matched

Keyword Arguments
  • resolution (int or None) – Index to an specific spatial resolution of the template.

  • suffix (str or None) – BIDS suffix

  • atlas (str or None) – Name of a particular atlas

  • hemi (str or None) – Hemisphere

  • space (str or None) – Space template is mapped to

  • density (str or None) – Surface density

  • desc (str or None) – Description field

Examples

>>> str(get('MNI152Lin', resolution=1, suffix='T1w'))  
'.../tpl-MNI152Lin/tpl-MNI152Lin_res-01_T1w.nii.gz'
>>> str(get('MNI152Lin', resolution=2, suffix='T1w'))  
'.../tpl-MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz'
>>> [str(p) for p in get(
...     'MNI152Lin', suffix='T1w')]  
['.../tpl-MNI152Lin/tpl-MNI152Lin_res-01_T1w.nii.gz',
 '.../tpl-MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz']
>>> str(get('fsLR', space=None, hemi='L',
...         density='32k', suffix='sphere'))  
'.../tpl-fsLR_hemi-L_den-32k_sphere.surf.gii'
>>> get('fsLR', space='madeup')
[]
>>> get('fsLR', raise_empty=True, space='madeup')  
Traceback (most recent call last):
Exception:
...
templateflow.api.get_citations(template, bibtex=False)[source]

Fetch template citations

Parameters
  • template (str) – A template identifier (e.g., MNI152NLin2009cAsym).

  • bibtex (bool, optional) – Generate citations in BibTeX format.

templateflow.api.get_metadata(template)[source]

Fetch one file from one template.

Parameters

template (str) – A template identifier (e.g., MNI152NLin2009cAsym).

Examples

>>> get_metadata('MNI152Lin')['Name']
'Linear ICBM Average Brain (ICBM152) Stereotaxic Registration Model'
templateflow.api.templates(**kwargs)[source]

Returns a list of available templates.

Keyword Arguments
  • resolution (int or None) – Index to an specific spatial resolution of the template.

  • suffix (str or None) – BIDS suffix

  • atlas (str) – Name of a particular atlas

  • desc (str) – Description field

Examples

>>> base = ['MNI152Lin', 'MNI152NLin2009cAsym', 'NKI', 'OASIS30ANTs']
>>> tpls = templates()
>>> all([t in tpls for t in base])
True
>>> templates(suffix='PD')
['MNI152Lin', 'MNI152NLin2009cAsym', 'MNI152NLin2009cSym', 'MNIInfant', 'MNIPediatricAsym']