# -*- coding: utf-8 -*-
from ..epochs.eventrelated_utils import (
_eventrelated_addinfo,
_eventrelated_rate,
_eventrelated_sanitizeinput,
_eventrelated_sanitizeoutput,
)
# =============================================================================
# Internals
# =============================================================================
def _ecg_eventrelated_phase(epoch, output={}):
# Sanitize input
colnames = epoch.columns.values
if len([i for i in colnames if "ECG_Phase_Atrial" in i]) == 0:
print(
"NeuroKit warning: ecg_eventrelated(): input does not"
"have an `ECG_Phase_Artrial` or `ECG_Phase_Ventricular` column."
"Will not indicate whether event onset concurs with cardiac"
"phase."
)
return output
# Indication of atrial systole
output["ECG_Phase_Atrial"] = epoch["ECG_Phase_Atrial"][epoch.index > 0].iloc[0]
output["ECG_Phase_Completion_Atrial"] = epoch["ECG_Phase_Completion_Atrial"][epoch.index > 0].iloc[0]
# Indication of ventricular systole
output["ECG_Phase_Ventricular"] = epoch["ECG_Phase_Ventricular"][epoch.index > 0].iloc[0]
output["ECG_Phase_Completion_Ventricular"] = epoch["ECG_Phase_Completion_Ventricular"][epoch.index > 0].iloc[0]
return output
def _ecg_eventrelated_quality(epoch, output={}):
# Sanitize input
colnames = epoch.columns.values
if len([i for i in colnames if "ECG_Quality" in i]) == 0:
print(
"NeuroKit warning: ecg_eventrelated(): input does not"
"have an `ECG_Quality` column. Quality of the signal"
"is not computed."
)
return output
# Average signal quality over epochs
output["ECG_Quality_Mean"] = epoch["ECG_Quality"].mean()
return output