<jupyter_start><jupyter_text>Analyze Electrooculography (EOG) This example can be referenced by [citing the package](https://neuropsychology.github.io/NeuroKit/cite_us.html).This example shows how to use NeuroKit to analyze EOG data.<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import neurokit2 as nk
# This "decorative" cell should be hidden from the docs once this is implemented:
# https://github.com/microsoft/vscode-jupyter/issues/1182 
plt.rcParams['figure.figsize'] = [15, 5]  # Bigger images
plt.rcParams['font.size']= 14<jupyter_output><empty_output><jupyter_text>Explore the EOG signal Let's load the example dataset corresponding to a vertical EOG signal.<jupyter_code>eog_signal = nk.data('eog_100hz.csv')

nk.signal_plot(eog_signal)<jupyter_output><empty_output><jupyter_text>Let's zoom in to some areas where clear blinks are present.<jupyter_code>nk.signal_plot(eog_signal[100:1700])<jupyter_output><empty_output><jupyter_text>Clean the signal We can now filter the signal to remove some noise and trends.<jupyter_code>eog_cleaned = nk.eog_clean(eog_signal, sampling_rate=100, method='neurokit')<jupyter_output><empty_output><jupyter_text>Let's visualize the same chunk and compare the clean version with the original signal.<jupyter_code>nk.signal_plot([eog_signal[100:1700], eog_cleaned[100:1700]], 
               labels=["Raw Signal", "Cleaned Signal"])<jupyter_output><empty_output><jupyter_text>Detect and visualize eye blinks We will nor run a peak detection algorithm to detect peaks location.<jupyter_code>blinks = nk.eog_findpeaks(eog_cleaned, sampling_rate=100, method="mne")
blinks
events = nk.epochs_create(eog_cleaned, blinks, sampling_rate=100, epochs_start=-0.3, epochs_end=0.7)
data = nk.epochs_to_array(events)  # Convert to 2D array
data = nk.standardize(data)  # Rescale so that all the blinks are on the same scale

# Plot with their median (used here as a robust average)  
plt.plot(data, linewidth=0.4)
plt.plot(np.median(data, axis=1), linewidth=3, linestyle='--', color="black")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1039272030651341, 'fraction_numerical': 0.02490421455938697, 'mean_word_length': 6.912878787878788, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '255813', 'license': 'MIT', 'n_tokens_mistral': 767, 'n_tokens_neox': 712, 'n_words': 181, 'path': 'docs/examples/eog_analyze/eog_analyze.ipynb', 'repo_name': 'danibene/NeuroKit', 'size': '2088'}