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[[mne_bids.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[mne_bids.BIDSPath] | None) – A list of BIDSPaths to load. If None, will use the paths found by
mne_bids.find_matching_paths()and the arguments below.root (pathlib.Path | str) – The root of the BIDS path.
subjects (str | array-like of str | None) – The subject ID. Corresponds to “sub”.
sessions (str | array-like of str | None) – The acquisition session. Corresponds to “ses”.
tasks (str | array-like of str | None) – The experimental task. Corresponds to “task”.
acquisitions (str | array-like of str | None) – The acquisition parameters. Corresponds to “acq”.
runs (str | array-like of str | None) – The run number. Corresponds to “run”.
processings (str | array-like of str | None) – The processing label. Corresponds to “proc”.
recordings (str | array-like of str | None) – The recording name. Corresponds to “rec”.
spaces (str | array-like of 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 | array-like of str | None) – The split of the continuous recording file for
.fifdata. Corresponds to “split”.descriptions (str | array-like of str | None) – This corresponds to the BIDS entity
desc. It is used to provide additional information for derivative data, e.g., preprocessed data may be assigneddescription='cleaned'.suffixes (str | array-like of 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 | array-like of str | None) – The extension of the filename. E.g.,
'.json'. By default, uses the ones accepted bymne_bids.read_raw_bids().datatypes (str | array-like of str | None) – The BIDS data type, e.g.,
'anat','func','eeg','meg','ieeg'.check (bool) – If
True, 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.