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:
- raw
mne.io.Raw An instance of
mne.io.Raw, with EEG, eyegaze, and pupil channels.- downsample
int 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_units
int The number of units to pass into the initial LSTM layer. Defaults to 50.
- n_times
int 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.
- raw
- Attributes:
- raw
mne.io.Raw The original input
mne.io.Rawinstance.- downsample
int The factor by which the data was downsampled.
- n_units
int The number of units in the initial LSTM layer.
- n_times
int The number of timepoints passed into the LSTM model at once.
- model
eoglearn.model.Model The Keras LSTM model instance.
Xnp.ndarrayReturn an array of the raw eye-tracking data.
Ynp.ndarrayReturn an array of the raw EEG data.
- X_train
np.ndarray The eyetracking data (
X)reshaped to fit into the LSTM model.- Y_train
np.ndarray The EEG data (
Y) reshaped to fit into the LSTM model.downsampled_sfreqfloatReturn the sampling frequency after downsampling.
- scaler_X
sklearn.preprocessing.StandardScaler The StandardScaler instance used to scale the eyetracking data.
- scaler_Y
sklearn.preprocessing.StandardScaler The StandardScaler instance used to scale the EEG data.
- noise_picks: list
Channels that contain the noise channels.
denoised_neuralnp.ndarrayReturn the MEEG signal without EOG artifact.
- raw
Methods
Compute the denoised M/EEG neural data.
fit_model([epochs, validation_split, ...])Fit the EOGDenoiser model using the input Raw object.
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 the training and validation loss.
predict(data[, predict_kwargs])Return Model predictions.
Return the predicted EOG data.
Return a model instance given a raw instance.
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_kwargs
dict A dictionary of keyword arguments to pass into the
fitmethod of the KerasSequentialmodel. Defaults toNone, which will usedict(epochs=50, validation_split=0.2, batch_size=1, verbose=2).
- fitting_kwargs
- 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:
- montage
mne.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.
- show
bool Whether to show the plot or not. Defaults to True.
- montage
- Returns:
- fig
matplotlib.figure.Figure The resulting figure object for the topomap plot.
- fig
- plot_loss()¶
Plot the training and validation loss.
- Returns:
- fig
matplotlib.figure.Figure The resulting figure showing the loss functions.
- fig
- predict(data, predict_kwargs=None)¶
Return Model predictions.
- Parameters:
- data
np.ndarray The data to predict. Must be the same shape as
self.X_train.- predict_kwargs
dict A dictionary of keyword arguments to pass into the
predictmethod of the KerasSequentialmodel. Defaults toNone.
- data
- Returns:
- predictions
np.ndarray The predicted data.
- predictions
Notes
This method is a wrapper for the
predictmethod of the KerasSequentialmodel.
- predict_eog()¶
Return the predicted EOG data.
- Returns:
- predicted_eog
np.ndarray The predicted EOG data, scaled back to the original units and shape, i.e.
(n_samples, n_meeg_channels)of the inputRawobject. The predictions are saved to thepredicted_eog_attribute.
- predicted_eog
- setup_model()¶
Return a model instance given a raw instance.
- Returns:
- model
eoglearn.model.Model a model instance.
- model
- train_test_split()¶
Split Eyetrack and EEG data into training and testing sets.
Notes
The
X_trainandY_trainattributes will be reshaped into 3D arrays of shape(n_samples, n_timesteps, n_features). Then_samplesdimension will be the number of samples in the raw data divided by then_timesattribute. Then_timestepsdimension will be then_timesattribute. Then_featuresdimension will be the number of channels in the eyetracking or EEG data. For example, if the raw data has 1492 samples, and then_timesparameter is 100, then theX_trainandY_trainarrays will have shape(14, 100, 3)and(14, 100, 129), respectively.X_traincontains only the eyetracking data, andY_traincontains only the EEG data.