Warning: This document is for an old version of smriprep. The main version is master.

smriprep.utils.bids module

Utilities to handle BIDS inputs.

smriprep.utils.bids.collect_anat_derivatives(derivatives, subject_id, std_spaces, session_id=None)[source]

Gather precomputed anatomical derivatives from one or more datasets.

Parameters:
  • derivatives (list of os.PathLike) – Derivatives datasets to search. Later datasets take precedence for each derivative they provide; transforms are merged per space and direction.

  • subject_id (str) – Subject label, without sub-.

  • std_spaces (list of str) – Standard spaces to look for transforms to and from. Transforms to fsnative are always searched for.

  • session_id (str or None) – Session label, without ses-.

Returns:

Paths to precomputed derivatives, as returned by collect_derivatives().

Return type:

dict

smriprep.utils.bids.collect_derivatives(derivatives_dir, subject_id, std_spaces, spec=None, patterns=None, session_id=None)[source]

Gather existing derivatives and compose a cache.

smriprep.utils.bids.write_bidsignore(deriv_dir)[source]
smriprep.utils.bids.write_derivative_description(bids_dir, deriv_dir)[source]

Write a dataset_description.json for the derivatives folder.

>>> from smriprep.data import load
>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> tmpdir = TemporaryDirectory()
>>> bids_dir = load('tests')
>>> deriv_desc = Path(tmpdir.name) / 'dataset_description.json'

>>> write_derivative_description(bids_dir, deriv_desc.parent)
>>> deriv_desc.is_file()
True
>>> tmpdir.cleanup()