diff --git a/neurokit/bio/bio_ecg.py b/neurokit/bio/bio_ecg.py index 91ecac9..aa89c9e 100644 --- a/neurokit/bio/bio_ecg.py +++ b/neurokit/bio/bio_ecg.py @@ -902,9 +902,13 @@ def compute_features(variable, prefix, response): # Compute differences between features and baseline keys = [key for key in ECG_Response.keys() if '_Baseline' in key] # Find keys + keys = [key for key in keys if 'ECG_HRV_' in key] keys = [s.replace('_Baseline', '') for s in keys] # Remove baseline part for key in keys: - ECG_Response["ECG_HRV_" + key + "_Diff"] = ECG_Response[key] - ECG_Response[key + "_Baseline"] + try: + ECG_Response["ECG_HRV_" + key + "_Diff"] = ECG_Response[key] - ECG_Response[key + "_Baseline"] + except KeyError: + ECG_Response["ECG_HRV_" + key + "_Diff"] = np.nan