brainda.paradigms package

Submodules

brainda.paradigms.base module

Base Paradigm Design.

class brainda.paradigms.base.BaseParadigm(channels: Optional[List[str]] = None, events: Optional[List[str]] = None, intervals: Optional[List[Tuple[float, float]]] = None, srate: Optional[float] = None)

Bases: object

Abstract Base Paradigm.

get_data(dataset: BaseDataset, subjects: List[Union[int, str]] = [], label_encode: bool = True, return_concat: bool = False, n_jobs: int = -1, verbose: Optional[bool] = None) Tuple[Union[Dict[str, Union[ndarray, DataFrame]], ndarray, DataFrame], ...]

Get data from dataset with selected subjects.

Parameters:
  • dataset (BaseDataset) – dataset

  • subjects (List[Union[int, str]],) – selected subjects, by default empty

  • label_encode (bool, optional,) – if True, return y in label encode way

  • return_concat (bool, optional) – if True, return concated ndarray object, otherwise return dict of events, by default False

  • n_jobs (int, optional) – Parallel jobs, by default -1

  • verbose (Optional[bool], optional) – verbose, by default None

Returns:

Xs, ys, metas, corresponding to data, label and meta data

Return type:

Tuple[Union[Dict[str, Union[np.ndarray, pd.DataFrame]], Union[np.ndarray, pd.DataFrame]], …]

Raises:

TypeError – raise error if dataset is not avaliable for the paradigm

abstract is_valid(dataset: BaseDataset) bool

Verify the dataset is compatible with the paradigm.

This method is called to verify dataset is compatible with the paradigm.

This method should raise an error if the dataset is not compatible with the paradigm. This is for example the case if the dataset is an ERP dataset for motor imagery paradigm, or if the dataset does not contain any of the required events.

Parameters:

dataset (BaseDataset) – dataset

register_data_hook(hook)

Register data hook before return data.

Parameters:

hook (callable object) –

Callable object to process ndarray data before return it. Its’ signature should look like:

hook(X, y, meta, caches) -> X, y, meta, caches

where caches is an dict storing information, X, y are ndarray object, meta is a pandas DataFrame instance.

register_epochs_hook(hook)

Register epochs hook after epoch operation.

Parameters:

hook (callable object) –

Callable object to process Epochs object after epoch operation. Its’ signature should look like:

hook(epochs, caches) -> epochs, caches

where caches is an dict storing information, epochs is MNE Epochs instance.

register_raw_hook(hook)

Register raw hook before epoch operation.

Parameters:

hook (callable object) –

Callable object to process Raw object before epoch operation. Its’ signature should look like:

hook(raw, caches) -> raw, caches

where caches is an dict stroing information, raw is MNE Raw instance.

unregister_data_hook()

Register data hook before return data.

unregister_epochs_hook()

Register epochs hook after epoch operation.

unregister_raw_hook()

Unregister raw hook before epoch operation.

brainda.paradigms.base.label_encoder(y, labels)

brainda.paradigms.imagery module

Motor Imagery Paradigm.

class brainda.paradigms.imagery.MotorImagery(channels: Optional[List[str]] = None, events: Optional[List[str]] = None, intervals: Optional[List[Tuple[float, float]]] = None, srate: Optional[float] = None)

Bases: BaseParadigm

Basic motor imagery paradigm.

is_valid(dataset)

Verify the dataset is compatible with the paradigm.

This method is called to verify dataset is compatible with the paradigm.

This method should raise an error if the dataset is not compatible with the paradigm. This is for example the case if the dataset is an ERP dataset for motor imagery paradigm, or if the dataset does not contain any of the required events.

Parameters:

dataset (BaseDataset) – dataset

brainda.paradigms.p300 module

P300 Paradigm.

class brainda.paradigms.p300.P300(channels: Optional[List[str]] = None, events: Optional[List[str]] = None, intervals: Optional[List[Tuple[float, float]]] = None, srate: Optional[float] = None)

Bases: BaseParadigm

is_valid(dataset)

Verify the dataset is compatible with the paradigm.

This method is called to verify dataset is compatible with the paradigm.

This method should raise an error if the dataset is not compatible with the paradigm. This is for example the case if the dataset is an ERP dataset for motor imagery paradigm, or if the dataset does not contain any of the required events.

Parameters:

dataset (BaseDataset) – dataset

brainda.paradigms.ssvep module

SSVEP Paradigm.

class brainda.paradigms.ssvep.SSVEP(channels: Optional[List[str]] = None, events: Optional[List[str]] = None, intervals: Optional[List[Tuple[float, float]]] = None, srate: Optional[float] = None)

Bases: BaseParadigm

is_valid(dataset)

Verify the dataset is compatible with the paradigm.

This method is called to verify dataset is compatible with the paradigm.

This method should raise an error if the dataset is not compatible with the paradigm. This is for example the case if the dataset is an ERP dataset for motor imagery paradigm, or if the dataset does not contain any of the required events.

Parameters:

dataset (BaseDataset) – dataset

Module contents