cmtklib.bids.io module

This module provides classes to handle custom BIDS derivatives file input.

class cmtklib.bids.io.CustomAparcAsegBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted Freesurfer aparc+aseg file in the form sub-<label>_desc-aparcaseg_dseg.nii.gz.

class cmtklib.bids.io.CustomBIDSFile(p_toolbox_derivatives_dir='', p_datatype='', p_suffix='', p_extension='', p_acquisition='', p_rec='', p_atlas='', p_res='', p_label='', p_desc='', p_task='')[source]

Bases: traits.has_traits.HasTraits

Base class used to represent a BIDS-formatted file inside a custom BIDS derivatives directory.

toolbox_derivatives_dir

Toolbox folder name in the derivatives/ of the BIDS dataset

Type

Str

datatype

BIDS data type

Type

Enum([“anat”, “dwi”, “func”, “eeg”])

suffix

Filename suffix e.g. sub-01_T1w.nii.gz has suffix T1w

Type

Str

acquisition

Label used in _acq-<label>_

Type

Str

task

Label used in _task-<label>_

Type

Str

rec

Label used in _rec-<label>_

Type

Str

res

Label used in _res-<label>_

Type

Str

extension

File extension

Type

Str

atlas

Label used in _atlas-<label>_

Type

Str

label

Label used in _label-<label>_

Type

Str

desc

Label used in _desc-<label>_

Type

Str

get_filename(subject, session=None, debug=False)[source]

Return the filename path with extension of the represented BIDS file.

Parameters
  • subject (str) – Subject filename entity e.g. “sub-01”

  • session (str) – Session filename entity e.g. “ses-01” if applicable (Default: None)

  • debug (bool) – Debug mode (Extra output messages) if True

get_filename_path(base_dir, subject, session=None, debug=False)[source]

Return the filename path without extension of the represented BIDS file.

Parameters
  • base_dir (str) – BIDS root directory or derivatives/ directory in BIDS root directory

  • subject (str) – Subject filename entity e.g. “sub-01”

  • session (str) – Session filename entity e.g. “ses-01” if applicable (Default: None)

  • debug (bool) – Debug mode (Extra output messages) if True

get_query_dict()[source]

Return the dictionary to be passed to BIDSDataGrabber to query a list of files.

get_toolbox_derivatives_dir()[source]

Return the value of custom_derivatives_dir attribute.

class cmtklib.bids.io.CustomBrainMaskBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom brain mask in the form sub-<label>_desc-brain_mask.nii.gz.

class cmtklib.bids.io.CustomCSFMaskBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom CSF mask in the form sub-<label>_label-CSF_dseg.nii.gz.

class cmtklib.bids.io.CustomEEGCartoolElectrodesBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted electrode file produced by Cartool, in the form sub-<label>_eeg.xyz.

class cmtklib.bids.io.CustomEEGCartoolInvSolBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted inverse solution file produced by Cartool in the form sub-<label>_eeg.[LAURA|LORETA].is.

class cmtklib.bids.io.CustomEEGCartoolMapSpiRoisBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted spi / rois mapping file in the form sub-<label>_eeg.pickle.rois.

class cmtklib.bids.io.CustomEEGCartoolSpiBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted Source Point Irregularly spaced file produced by Cartool, in the form sub-<label>_eeg.spi.

class cmtklib.bids.io.CustomEEGElectrodesBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted EEG electrodes file in the form sub-<label>_task-<label>_electrodes.tsv.

class cmtklib.bids.io.CustomEEGEpochsBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted EEG Epochs file in .set or .fif format.

class cmtklib.bids.io.CustomEEGEventsBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted EEG task events file in the form sub-<label>_task-<label>_events.tsv.

extract_event_ids_from_json_sidecar(base_dir, subject, session=None, debug=False)[source]
class cmtklib.bids.io.CustomEEGMNETransformBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted electrode transform file in the form sub-<label>_trans.fif.

class cmtklib.bids.io.CustomEEGPreprocBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom BIDS-formatted preprocessed EEG file in the form sub-<label>_task-<label>_desc-preproc_eeg.[set|fif].

class cmtklib.bids.io.CustomGMMaskBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom gray-matter mask in the form sub-<label>_label-GM_dseg.nii.gz.

class cmtklib.bids.io.CustomParcellationBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom parcellation files in the form sub-<label>_atlas-<label>[_res-<label>]_dseg.nii.gz.

get_nb_of_regions(bids_dir, subject, session=None, debug=False)[source]

Return the number of regions by reading its associated TSV side car file describing the nodes.

Parameters
  • bids_dir (str) – BIDS root directory

  • subject (str) – Subject filename entity e.g. “sub-01”

  • session (str) – Session filename entity e.g. “ses-01” if applicable (Default: None)

  • debug (bool) – Debug mode (Extra output messages) if True

class cmtklib.bids.io.CustomWMMaskBIDSFile[source]

Bases: cmtklib.bids.io.CustomBIDSFile

Represent a custom white-matter mask in the form sub-<label>_label-WM_dseg.nii.gz.