braindecode.datasets.bids.BIDSIterableDataset#
- class braindecode.datasets.bids.BIDSIterableDataset(reader_fn, pool_size=4, bids_paths=None, root=None, subjects=None, sessions=None, tasks=None, acquisitions=None, runs=None, processings=None, recordings=None, spaces=None, splits=None, descriptions=None, suffixes=None, extensions=['.con', '.sqd', '.pdf', '.fif', '.ds', '.vhdr', '.set', '.edf', '.bdf', '.EDF', '.snirf', '.cdt', '.mef', '.nwb'], datatypes=None, check=False)[source]#
Dataset for loading BIDS.
Warning
This class is experimental and may change in the future.
Warning
This dataset is not consistent with the Braindecode API.
This class has the same parameters as the
mne_bids.find_matching_paths()function as it will be used to find the files to load. The defaultextensionsparameter was changed.More information on BIDS (Brain Imaging Data Structure) can be found at https://bids.neuroimaging.io
Examples
>>> from braindecode.datasets import BaseConcatDataset, RawDataset, RecordDataset >>> from braindecode.datasets.bids import BIDSIterableDataset >>> from braindecode.preprocessing import create_fixed_length_windows >>> >>> def my_reader_fn(path): ... raw = mne_bids.read_raw_bids(path) ... ds: RecordDataset = RawDataset(raw, description={"path": path.fpath}) ... windows_ds = create_fixed_length_windows( ... BaseConcatDataset([ds]), ... window_size_samples=400, ... window_stride_samples=200, ... ) ... return windows_ds >>> >>> dataset = BIDSIterableDataset( ... reader_fn=my_reader_fn, ... root="root/of/my/bids/dataset/", ... )
- Parameters:
reader_fn (
Callable[[BIDSPath],Sequence]) – A function that takes a BIDSPath and returns a dataset (e.g., a RecordDataset or BaseConcatDataset of RecordDataset).pool_size (
int) – The number of recordings to read and sample from.bids_paths (
list[BIDSPath] |None) – A list of BIDSPaths to load. If None, will use the paths found bymne_bids.find_matching_paths()and the arguments below.subjects (
str|list[str] |None) – The subject ID. Corresponds to “sub”.sessions (
str|list[str] |None) – The acquisition session. Corresponds to “ses”.tasks (
str|list[str] |None) – The experimental task. Corresponds to “task”.acquisitions (
str|list[str] |None) – The acquisition parameters. Corresponds to “acq”.runs (
str|list[str] |None) – The run number. Corresponds to “run”.processings (
str|list[str] |None) – The processing label. Corresponds to “proc”.recordings (
str|list[str] |None) – The recording name. Corresponds to “rec”.spaces (
str|list[str] |None) – The coordinate space for anatomical and sensor location files (e.g.,*_electrodes.tsv,*_markers.mrk). Corresponds to “space”. Note that valid values forspacemust come from a list of BIDS keywords as described in the BIDS specification.splits (
str|list[str] |None) – The split of the continuous recording file for.fifdata. Corresponds to “split”.descriptions (
str|list[str] |None) – This corresponds to the BIDS entitydesc. It is used to provide additional information for derivative data, e.g., preprocessed data may be assigneddescription='cleaned'.suffixes (
str|list[str] |None) – The filename suffix. This is the entity after the last_before the extension. E.g.,'channels'. The following filename suffix’s are accepted: ‘meg’, ‘markers’, ‘eeg’, ‘ieeg’, ‘T1w’, ‘participants’, ‘scans’, ‘electrodes’, ‘coordsystem’, ‘channels’, ‘events’, ‘headshape’, ‘digitizer’, ‘beh’, ‘physio’, ‘stim’extensions (
str|list[str] |None) – The extension of the filename. E.g.,'.json'. By default, uses the ones accepted bymne_bids.read_raw_bids().datatypes (
str|list[str] |None) – The BIDS data type, e.g.,'anat','func','eeg','meg','ieeg'.check (
bool) – IfTrue, only returns paths that conform to BIDS. IfFalse(default), the.checkattribute of the returnedmne_bids.BIDSPathobject will be set toTruefor paths that do conform to BIDS, and toFalsefor those that don’t.preload (bool) – If True, preload the data. Defaults to False.
n_jobs (int) – Number of jobs to run in parallel. Defaults to 1.