Documentation of eeglib.wrapper module

This module contains the Wrapper class that wraps around a Helper and computes every feature in each window configured. It also allows specifying labels for the whole signal or for specific segments.

class eeglib.wrapper.Wrapper(helper, flat=True, flatSeparator='_', store=True, label=None, segmentation=None, onlySegments=False, showProgress=False)

This class wraps around a helper and allows getting multiple features at once. The main usage of this class if for generating features to use with machine learning techniques.

Methods

addCustomFeature(function[, channels, …])

Adds a custom feature that will be included in the dataset.

addFeatures(features)

Parameters

featuresNames()

Returns the names of the specified features.

getAllFeatures()

Iterates over all the windows in the helper and returns all the values.

getFeatures()

Returns the features in the current window of the helper iterator.

getStoredFeatures()

Returns the stored features if store was set to True, else it returns None.

reset()

Resets the

__init__(helper, flat=True, flatSeparator='_', store=True, label=None, segmentation=None, onlySegments=False, showProgress=False)
Parameters
helper: :py:class:`eeglib.helpers.Helper`

The helper object that will be used to get the data and the iteration settings.

flat: Bool

If True the result of calling getFeatures() will be a one dimensional sequence of data. If False, the return value will be a list containing the result of each feature, that can be a float, a dict or an array. Default: True.

separator: str

It is used to separate the features names when flatten.

store: Bool

If True, the data will be stored in a self.storedFeatures. Default: True.

label: object, optional

This value will be added as a field in the data except if it is None. Default: None.

segmentation: dict of tuples, optional

Parameter format [((begin, end),label), ]; begin is the begin of the segment, end is the end of the segment and label the label realed to that segment. Begin and end can be either an int, a str or a datetime.timedelta, being the same that the parameter of eeglib.helpers.Helper.moveEEGWindow(). The label of the unlabelled segments will be 0. If None, no segmentation will be added. Default: None.

onlySegments: bool, optional

If True, only windows between segments will be computed. Only used if a segmentation argument is used.

showProgress: bool, optional

If True, it will shown the progress when computing all the features.

addCustomFeature(function, channels=None, twoChannels=False, name=None, customArgs=[], customKwargs={})

Adds a custom feature that will be included in the dataset.

Parameters
function: function

The function to apply. It must take an array-like as first parameter if twoChannels parameter is False or two array-like for each of the first two parameters if twoChannels is True.

channels: Variable type, optional

The channels over which the function will be applied. * int: the index of the channel. * str: the name of the channel. * list of strings and integers: a list of channels. * slice: a slice selecting the range of channels. * None: all the channels. The function to apply to the data to obtain the feature.

twoChannels: bool

If function receives two channels of data this parameter should be True. Default: False.

name: str

A custom name for the feature that will be visible in the df.

customArgs: list

A list of fixed arguments for the function.

customKwargs: dict

A dict of keyword arguments, where the key is the argument name and the value is the argument content.

Returns
None
addFeatures(features)
Parameters
features: list(tuple(str,list, dict))

A list containing tuples that represent the parameters needed to add a single feature.

featuresNames()

Returns the names of the specified features.

getAllFeatures()

Iterates over all the windows in the helper and returns all the values.

Returns
pandas.DataFrame
getFeatures()

Returns the features in the current window of the helper iterator.

Returns
pandas.Series
getStoredFeatures()

Returns the stored features if store was set to True, else it returns None.

reset()

Resets the

Returns
None.