Source code for neurokit2.eog.eog_eventrelated
# -*- coding: utf-8 -*-
from warnings import warn
import numpy as np
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_rate,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
from ..misc import NeuroKitWarning
# =============================================================================
# Internals
# =============================================================================
def _eog_eventrelated_features(epoch, output={}):
# Sanitize input
if "EOG_Blinks" not in epoch:
warn(
"Input does not have an `EOG_Blinks` column." " Unable to process blink features.",
category=NeuroKitWarning,
)
return output
if "EOG_Rate" not in epoch:
warn(
"Input does not have an `EOG_Rate` column." " Will skip computation of EOG rate.",
category=NeuroKitWarning,
)
return output
# Detect whether blink exists after onset of stimulus
blinks_presence = len(np.where(epoch["EOG_Blinks"][epoch.index > 0] == 1)[0])
if blinks_presence > 0:
output["EOG_Blinks_Presence"] = 1
else:
output["EOG_Blinks_Presence"] = 0
return output