braindecode.datasets package

Loader code for some datasets.

Submodules

braindecode.datasets.bbci module

class braindecode.datasets.bbci.BBCIDataset(filename, load_sensor_names=None, check_class_names=False)[source]

Bases: object

Loader class for files created by saving BBCI files in matlab (make sure to save with ‘-v7.3’ in matlab, see https://de.mathworks.com/help/matlab/import_export/mat-file-versions.html#buk6i87 )

Parameters:
  • filename (str)
  • load_sensor_names (list of str, optional) – Also speeds up loading if you only load some sensors. None means load all sensors.
  • check_class_names (bool, optional) – check if the class names are part of some known class names at Translational NeuroTechnology Lab, AG Ball, Freiburg, Germany.
load()[source]
static get_all_sensors(filename, pattern=None)[source]

Get all sensors that exist in the given file.

Parameters:
  • filename (str)
  • pattern (str, optional) – Only return those sensor names that match the given pattern.
Returns:

sensor_names – Sensor names that match the pattern or all sensor names in the file.

Return type:

list of str

braindecode.datasets.bbci.load_bbci_sets_from_folder(folder, runs='all')[source]

Load bbci datasets from files in given folder.

Parameters:
  • folder (str) – Folder with .BBCI.mat files inside
  • runs (list of int) – If you only want to load specific runs. Assumes filenames with such kind of part: S001R02 for Run 2. Tries to match this regex: 'S[0-9]{3,3}R[0-9]{2,2}_'.

braindecode.datasets.bcic_iv_2a module

class braindecode.datasets.bcic_iv_2a.BCICompetition4Set2A(filename, load_sensor_names=None, labels_filename=None)[source]

Bases: object

load()[source]
extract_data()[source]
extract_events(raw_gdf)[source]

braindecode.datasets.lazy_dataset module

class braindecode.datasets.lazy_dataset.LazyDataset[source]

Bases: abc.ABC

Class implementing an abstract lazy data set. Custom lazy data sets have to override file_paths, X and y as well as the load_lazy function to load trials or crops.

load_lazy(path, start_i, stop_i)[source]

Loading procedure that gets a file path, start and stop indices. Is supposed to return a trial / crop together with its target

Parameters:
  • path (str) – file path
  • start_i (int) – start index of signal crop
  • stop_i (int) – stop index of signal crop

braindecode.datasets.multiple module

class braindecode.datasets.multiple.MultipleSetLoader(set_loaders)[source]

Bases: object

Class to load multiple sets.

Resamples individual sets down to lowest common sampling frequency, if necessary.

Parameters:set_loaders (object with load method: () -> MNE Raw object) – The individual set loaders.
load()[source]

braindecode.datasets.sensor_positions module

braindecode.datasets.sensor_positions.get_channelpos(channame, chan_pos_list)[source]
braindecode.datasets.sensor_positions.get_channelpos_from_angle(channame, chan_pos_list=('angle', ('Fpz', (0.0, 4.0)), ('Fp1', (-3.5, 3.5)), ('Fp2', (3.5, 3.5)), ('AFp3h', (-1.0, 3.5)), ('AFp4h', (1.0, 3.5)), ('AF7', (-4.0, 3.0)), ('AF3', (-2.0, 3.0)), ('AFz', (0.0, 3.0)), ('AF4', (2.0, 3.0)), ('AF8', (4.0, 3.0)), ('AFF5h', (-2.5, 2.5)), ('AFF1', (-0.5, 2.5)), ('AFF2', (0.5, 2.5)), ('AFF6h', (2.5, 2.5)), ('F7', (-4.0, 2.0)), ('F5', (-3.0, 2.0)), ('F3', (-2.0, 2.0)), ('F1', (-1.0, 2.0)), ('Fz', (0.0, 2.0)), ('F2', (1.0, 2.0)), ('F4', (2.0, 2.0)), ('F6', (3.0, 2.0)), ('F8', (4.0, 2.0)), ('FFT7h', (-3.5, 1.5)), ('FFC5h', (-2.5, 1.5)), ('FFC3h', (-1.5, 1.5)), ('FFC1h', (-0.5, 1.5)), ('FFC2h', (0.5, 1.5)), ('FFC4h', (1.5, 1.5)), ('FFC6h', (2.5, 1.5)), ('FFT8h', (3.5, 1.5)), ('FT9', (-5.0, 1.0)), ('FT7', (-4.0, 1.0)), ('FC5', (-3.0, 1.0)), ('FC3', (-2.0, 1.0)), ('FC1', (-1.0, 1.0)), ('FCz', (0.0, 1.0)), ('FC2', (1.0, 1.0)), ('FC4', (2.0, 1.0)), ('FC6', (3.0, 1.0)), ('FT8', (4.0, 1.0)), ('FT10', (5.0, 1.0)), ('FTT9h', (-4.5, 0.5)), ('FTT7h', (-3.5, 0.5)), ('FCC5h', (-2.5, 0.5)), ('FCC3h', (-1.5, 0.5)), ('FCC1h', (-0.5, 0.5)), ('FCC2h', (0.5, 0.5)), ('FCC4h', (1.5, 0.5)), ('FCC6h', (2.5, 0.5)), ('FTT8h', (3.5, 0.5)), ('FTT10h', (4.5, 0.5)), ('M1', (-5.0, 0.0)), ('T9', (-4.5, 0.0)), ('T7', (-4.0, 0.0)), ('C5', (-3.0, 0.0)), ('C3', (-2.0, 0.0)), ('C1', (-1.0, 0.0)), ('Cz', (0.0, 0.0)), ('C2', (1.0, 0.0)), ('C4', (2.0, 0.0)), ('C6', (3.0, 0.0)), ('T8', (4.0, 0.0)), ('T10', (4.5, 0.0)), ('M2', (5.0, 0.0)), ('TTP7h', (-3.5, -0.5)), ('CCP5h', (-2.5, -0.5)), ('CCP3h', (-1.5, -0.5)), ('CCP1h', (-0.5, -0.5)), ('CCP2h', (0.5, -0.5)), ('CCP4h', (1.5, -0.5)), ('CCP6h', (2.5, -0.5)), ('TTP8h', (3.5, -0.5)), ('TP7', (-4.0, -1.0)), ('CP5', (-3.0, -1.0)), ('CP3', (-2.0, -1.0)), ('CP1', (-1.0, -1.0)), ('CPz', (0.0, -1.0)), ('CP2', (1.0, -1.0)), ('CP4', (2.0, -1.0)), ('CP6', (3.0, -1.0)), ('TP8', (4.0, -1.0)), ('TPP9h', (-4.5, -1.5)), ('TPP7h', (-3.5, -1.5)), ('CPP5h', (-2.5, -1.5)), ('CPP3h', (-1.5, -1.5)), ('CPP1h', (-0.5, -1.5)), ('CPP2h', (0.5, -1.5)), ('CPP4h', (1.5, -1.5)), ('CPP6h', (2.5, -1.5)), ('TPP8h', (3.5, -1.5)), ('TPP10h', (4.5, -1.5)), ('P9', (-5.0, -2.0)), ('P7', (-4.0, -2.0)), ('P5', (-3.0, -2.0)), ('P3', (-2.0, -2.0)), ('P1', (-1.0, -2.0)), ('Pz', (0.0, -2.0)), ('P2', (1.0, -2.0)), ('P4', (2.0, -2.0)), ('P6', (3.0, -2.0)), ('P8', (4.0, -2.0)), ('P10', (5.0, -2.0)), ('PPO9h', (-4.5, -2.5)), ('PPO5h', (-3.0, -2.5)), ('PPO1', (-0.65, -2.5)), ('PPO2', (0.65, -2.5)), ('PPO6h', (3.0, -2.5)), ('PPO10h', (4.5, -2.5)), ('PO9', (-5.0, -3.0)), ('PO7', (-4.0, -3.0)), ('PO5', (-3.0, -3.0)), ('PO3', (-2.0, -3.0)), ('PO1', (-1.0, -3.0)), ('POz', (0.0, -3.0)), ('PO2', (1.0, -3.0)), ('PO4', (2.0, -3.0)), ('PO6', (3.0, -3.0)), ('PO8', (4.0, -3.0)), ('PO10', (5.0, -3.0)), ('POO9h', (-4.5, -3.25)), ('POO3h', (-2.0, -3.25)), ('POO4h', (2.0, -3.25)), ('POO10h', (4.5, -3.25)), ('O1', (-2.5, -3.75)), ('Oz', (0.0, -3.75)), ('O2', (2.5, -3.75)), ('OI1h', (1.5, -4.25)), ('OI2h', (-1.5, -4.25)), ('I1', (1.0, -4.5)), ('Iz', (0.0, -4.5)), ('I2', (-1.0, -4.5))))[source]

Return the x/y position of a channel.

This method calculates the stereographic projection of a channel from CHANNEL_10_20, suitable for a scalp plot.

Parameters:
  • channame (str) – Name of the channel, the search is case insensitive.
  • chan_pos_list=CHANNEL_10_20_APPROX,
  • interpolation=’bilinear’
Returns:

x, y – The projected point on the plane if the point is known, otherwise None

Return type:

float or None

Examples

>>> plot.get_channelpos_from_angle('C2')
(0.1720792096741632, 0.0)
>>> # the channels are case insensitive
>>> plot.get_channelpos_from_angle('c2')
(0.1720792096741632, 0.0)
>>> # lookup for an invalid channel
>>> plot.get_channelpos_from_angle('foo')
None