Source code for neurokit2.eog.eog_intervalrelated
# -*- coding: utf-8 -*-
import numpy as np
import pandas as pd
# =============================================================================
# Internals
# =============================================================================
def _eog_intervalrelated_formatinput(data, output={}):
# Sanitize input
colnames = data.columns.values
if len([i for i in colnames if "EOG_Rate" in i]) == 0:
raise ValueError(
"NeuroKit error: eog_intervalrelated(): Wrong input,"
"we couldn't extract EOG rate. Please make sure"
"your DataFrame contains an `EOG_Rate` column."
)
if len([i for i in colnames if "EOG_Blinks" in i]) == 0:
raise ValueError(
"NeuroKit error: eog_intervalrelated(): Wrong input,"
"we couldn't extract EOG blinks. Please make sure"
"your DataFrame contains an `EOG_Blinks` column."
)
signal = data["EOG_Rate"].values
n_blinks = len(np.where(data["EOG_Blinks"] == 1)[0])
output["EOG_Peaks_N"] = n_blinks
output["EOG_Rate_Mean"] = np.mean(signal)
return output