Analyze Electrooculography EOG data (eye blinks, saccades, etc.)

[26]:
# This is temporary to load the dev version of NK, needs to be removed once it's in master
import os
os.chdir('D:/Dropbox/RECHERCHE/N/NeuroKit/')
# -----------------------
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import neurokit2 as nk

plt.rcParams['figure.figsize'] = [14, 8]  # Increase plot size

Explore the EOG signal

Let’s load the example dataset corresponding to a vertical EOG signal.

[47]:
eog_signal = pd.read_csv("data/eog_100hz.csv")
eog_signal = nk.as_vector(eog_signal)  # Extract the only column as a vector
nk.signal_plot(eog_signal)
../_images/examples_eog_4_0.png

Let’s zoom in to some areas where clear blinks are present.

[48]:
nk.signal_plot(eog_signal[100:1700])
../_images/examples_eog_6_0.png

Clean the signal

We can now filter the signal to remove some noise and trends.

[49]:
eog_cleaned = nk.eog_clean(eog_signal, sampling_rate=100, method='neurokit')

Let’s visualize the same chunk and compare the clean version with the original signal.

[50]:
nk.signal_plot([eog_signal[100:1700], eog_cleaned[100:1700]])
../_images/examples_eog_11_0.png