qsiprep.interfaces.bids module

Interfaces for handling BIDS-like neuroimaging structures

Fetch some example data:

>>> import os
>>> from niworkflows import data
>>> data_root = data.get_bids_examples(variant='BIDS-examples-1-enh-ds054')
>>> os.chdir(data_root)

Disable warnings:

>>> from nipype import logging
>>> logging.getLogger('nipype.interface').setLevel('ERROR')
class qsiprep.interfaces.bids.BIDSDataGrabber(*args, **kwargs)[source]

Bases: SimpleInterface

Collect files from a BIDS directory structure

>>> from qsiprep.interfaces import BIDSDataGrabber
>>> from qsiprep.utils.bids import collect_data
>>> bids_src = BIDSDataGrabber(anat_only=False)
>>> bids_src.inputs.subject_data = collect_data('ds114', '01')[0]
>>> bids_src.inputs.subject_id = 'ds114'
>>> res = bids_src.run()
>>> res.outputs.t1w  
['.../ds114/sub-01/ses-retest/anat/sub-01_ses-retest_T1w.nii.gz',
 '.../ds114/sub-01/ses-test/anat/sub-01_ses-test_T1w.nii.gz']
Optional Inputs:
  • subject_data (a dictionary with keys which are a string and with values which are any value)

  • subject_id (a string)

Outputs:
  • bold (a list of items which are any value) – Output functional images.

  • dwi (a list of items which are any value) – Output DWI images.

  • flair (a list of items which are any value) – Output FLAIR images.

  • fmap (a list of items which are any value) – Output fieldmaps.

  • out_dict (a dictionary with keys which are any value and with values which are any value) – Output data structure.

  • roi (a list of items which are any value) – Output ROI images.

  • sbref (a list of items which are any value) – Output sbrefs.

  • t1w (a list of items which are any value) – Output T1w images.

  • t2w (a list of items which are any value) – Output T2w images.

class qsiprep.interfaces.bids.BIDSInfo(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Extract metadata from a BIDS-conforming filename

This interface uses only the basename, not the path, to determine the subject, session, task, run, acquisition or reconstruction.

Mandatory Inputs:

in_file (a pathlike object or string representing a file) – Input file, part of a BIDS tree.

Outputs:
  • acq_id (a string)

  • rec_id (a string)

  • run_id (a string)

  • session_id (a string)

  • subject_id (a string)

  • task_id (a string)

class qsiprep.interfaces.bids.DerivativesDataSink(allowed_entities=None, out_path_base=None, **inputs)[source]

Bases: DerivativesDataSink

Store derivative files.

A child class of the niworkflows DerivativesDataSink, using xcp_d’s configuration files.

Mandatory Inputs:
  • in_file (a list of items which are a pathlike object or string representing an existing file) – The object to be saved.

  • source_file (a list of items which are a pathlike object or string representing a file) – The source file(s) to extract entities from.

Optional Inputs:
  • base_directory (a string or os.PathLike object) – Path to the base directory for storing data.

  • check_hdr (a boolean) – Fix headers of NIfTI outputs. (Nipype default value: True)

  • compress (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None, default). (Nipype default value: [])

  • data_dtype (a string) – NumPy datatype to coerce NIfTI data to, or source tomatch the input file dtype.

  • dismiss_entities (a list of items which are a string or None) – A list entities that will not be propagated from the source file. (Nipype default value: [])

  • meta_dict (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – An input dictionary containing metadata.

Outputs:
  • compression (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None).

  • fixed_hdr (a list of items which are a boolean) – Whether derivative header was fixed.

  • out_file (a list of items which are a pathlike object or string representing an existing file)

  • out_meta (a list of items which are a pathlike object or string representing an existing file)

out_path_base = ''
class qsiprep.interfaces.bids.DerivativesMaybeDataSink(allowed_entities=None, out_path_base=None, **inputs)[source]

Bases: DerivativesDataSink

Mandatory Inputs:

source_file (a list of items which are a pathlike object or string representing a file) – The source file(s) to extract entities from.

Optional Inputs:
  • base_directory (a string or os.PathLike object) – Path to the base directory for storing data.

  • check_hdr (a boolean) – Fix headers of NIfTI outputs. (Nipype default value: True)

  • compress (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None, default). (Nipype default value: [])

  • data_dtype (a string) – NumPy datatype to coerce NIfTI data to, or source tomatch the input file dtype.

  • dismiss_entities (a list of items which are a string or None) – A list entities that will not be propagated from the source file. (Nipype default value: [])

  • in_file (a string or os.PathLike object referring to an existing directory or a list of items which are a pathlike object or string representing an existing file) – The object to be saved.

  • meta_dict (a dictionary with keys which are a value of class ‘str’ and with values which are any value) – An input dictionary containing metadata.

Outputs:
  • compression (a list of items which are a boolean or None) – Whether in_file should be compressed (True), uncompressed (False) or left unmodified (None).

  • fixed_hdr (a list of items which are a boolean) – Whether derivative header was fixed.

  • out_file (a list of items which are a pathlike object or string representing an existing file)

  • out_meta (a list of items which are a pathlike object or string representing an existing file)

exception qsiprep.interfaces.bids.FileNotFoundError[source]

Bases: OSError

qsiprep.interfaces.bids.get_bids_params(fullpath)[source]