metabci.brainda.paradigms.base module¶
Base Paradigm Design.
- class metabci.brainda.paradigms.base.BaseParadigm(channels: List[str] | None = None, events: List[str] | None = None, intervals: List[Tuple[float, float]] | None = None, srate: float | None = None)[source]¶
Bases:
objectAbstract Base Paradigm.
- get_data(dataset: BaseDataset, subjects: List[int | str] = [], label_encode: bool = True, return_concat: bool = False, n_jobs: int = -1, verbose: bool | None = None) Tuple[Dict[str, ndarray | DataFrame] | ndarray | DataFrame, ...][source]¶
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[source]¶
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)[source]¶
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)[source]¶
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)[source]¶
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.
- class metabci.brainda.paradigms.base.BaseTimeEncodingParadigm(channels: List[str] | None = None, events: List[str] | None = None, intervals: List[Tuple[float, float]] | None = None, minor_event_intervals: List[Tuple[float, float]] | None = None, srate: float | None = None)[source]¶
Bases:
BaseParadigm- get_data(dataset: BaseTimeEncodingDataset, subjects: List[int | str] = [], return_concat: bool = False, n_jobs: int = -1, verbose: bool | None = None)[source]¶
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
- is_valid(dataset)[source]¶
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_trial_hook(hook)[source]¶
Register trial hook before trial operation.
- Parameters:
hook (callable object to process Raw object before epoch operation.) –
Different from the raw_hook, the trial hook allows you to do some specific operation BEFORE epoch operation (i.e. smallest encode unit) and AFTER raw continuous data operation
Its signature should look like:
hook(raw, caches) -> raw, caches
where caches is a dict storing information, raw is MNE Raw instance