Models

class eoglearn.models.EOGDenoiser(raw, downsample=10, n_units=50, n_times=100, noise_picks=None)

Use simultaneous EEG and Eyetracking to Denoise EOG from the EEG data.

Parameters:
rawmne.io.Raw

An instance of mne.io.Raw, with EEG, eyegaze, and pupil channels.

downsampleint

The factor by which to downsample the EEG and eyetracking data. EEG channels will be low-pass filtered before downsampling using mne.io.filter.resample. Eyetracking channels will be decimated without any filtering. resampling and decimating will be done on copies of the data, so the original input data will be preserved.

n_unitsint

The number of units to pass into the initial LSTM layer. Defaults to 50.

n_timesint

The number of timepoints to pass into the LSTM model at once. Defaults to 100.

noise_picks: list | None

Channels that contain the noise channels.

Attributes:
rawmne.io.Raw

The original input mne.io.Raw instance.

downsampleint

The factor by which the data was downsampled.

n_unitsint

The number of units in the initial LSTM layer.

n_timesint

The number of timepoints passed into the LSTM model at once.

modeleoglearn.model.Model

The Keras LSTM model instance.

Xnp.ndarray

Return an array of the raw eye-tracking data.

Ynp.ndarray

Return an array of the raw EEG data.

X_trainnp.ndarray

The eyetracking data (X)reshaped to fit into the LSTM model.

Y_trainnp.ndarray

The EEG data (Y) reshaped to fit into the LSTM model.

downsampled_sfreqfloat

Return the sampling frequency after downsampling.

scaler_Xsklearn.preprocessing.StandardScaler

The StandardScaler instance used to scale the eyetracking data.

scaler_Ysklearn.preprocessing.StandardScaler

The StandardScaler instance used to scale the EEG data.

noise_picks: list

Channels that contain the noise channels.

denoised_neuralnp.ndarray

Return the MEEG signal without EOG artifact.

Methods

compute_denoised_neural()

Compute the denoised M/EEG neural data.

fit_model([epochs, validation_split, ...])

Fit the EOGDenoiser model using the input Raw object.

get_denoised_neural_raw()

Return an mne.io.Raw object of the MEEG signal without EOG artifact.

plot_eog_topo(montage[, show])

Plot the topography of the eyetracking data.

plot_loss()

Plot the training and validation loss.

predict(data[, predict_kwargs])

Return Model predictions.

predict_eog()

Return the predicted EOG data.

setup_model()

Return a model instance given a raw instance.

train_test_split()

Split Eyetrack and EEG data into training and testing sets.

Notes

See the MNE-Python tutorial on aligning EEG and eyetracking data for information on how to create a raw object with both EEG and eyetracking channels.

property X

Return an array of the raw eye-tracking data.

property Y

Return an array of the raw EEG data.

compute_denoised_neural()

Compute the denoised M/EEG neural data.

property denoised_neural

Return the MEEG signal without EOG artifact.

property downsampled_sfreq

Return the sampling frequency after downsampling.

fit_model(epochs=10, validation_split=0.2, batch_size=1, verbose=2, fitting_kwargs=None)

Fit the EOGDenoiser model using the input Raw object.

Parameters:
fitting_kwargsdict

A dictionary of keyword arguments to pass into the fit method of the Keras Sequential model. Defaults to None, which will use dict(epochs=50, validation_split=0.2, batch_size=1, verbose=2).

get_denoised_neural_raw()

Return an mne.io.Raw object of the MEEG signal without EOG artifact.

plot_eog_topo(montage, show=True)

Plot the topography of the eyetracking data.

Parameters:
montagemne.channels.DigMontage | str

Montage for digitized electrode and headshape position data. See mne.channels.make_standard_montage(), and mne.channels.get_builtin_montages() for more information on making montage objects in MNE.

showbool

Whether to show the plot or not. Defaults to True.

Returns:
figmatplotlib.figure.Figure

The resulting figure object for the topomap plot.

plot_loss()

Plot the training and validation loss.

Returns:
figmatplotlib.figure.Figure

The resulting figure showing the loss functions.

predict(data, predict_kwargs=None)

Return Model predictions.

Parameters:
datanp.ndarray

The data to predict. Must be the same shape as self.X_train.

predict_kwargsdict

A dictionary of keyword arguments to pass into the predict method of the Keras Sequential model. Defaults to None.

Returns:
predictionsnp.ndarray

The predicted data.

Notes

This method is a wrapper for the predict method of the Keras Sequential model.

predict_eog()

Return the predicted EOG data.

Returns:
predicted_eognp.ndarray

The predicted EOG data, scaled back to the original units and shape, i.e. (n_samples, n_meeg_channels) of the input Raw object. The predictions are saved to the predicted_eog_ attribute.

setup_model()

Return a model instance given a raw instance.

Returns:
modeleoglearn.model.Model

a model instance.

train_test_split()

Split Eyetrack and EEG data into training and testing sets.

Notes

The X_train and Y_train attributes will be reshaped into 3D arrays of shape (n_samples, n_timesteps, n_features). The n_samples dimension will be the number of samples in the raw data divided by the n_times attribute. The n_timesteps dimension will be the n_times attribute. The n_features dimension will be the number of channels in the eyetracking or EEG data. For example, if the raw data has 1492 samples, and the n_times parameter is 100, then the X_train and Y_train arrays will have shape (14, 100, 3) and (14, 100, 129), respectively. X_train contains only the eyetracking data, and Y_train contains only the EEG data.