def test_eda_eventrelated(): eda = nk.eda_simulate(duration=15, scr_number=3) eda_signals, info = nk.eda_process(eda, sampling_rate=1000) epochs = nk.epochs_create( eda_signals, events=[5000, 10000, 15000], sampling_rate=1000, epochs_start=-0.1, epochs_end=1.9, ) eda_eventrelated = nk.eda_eventrelated(epochs) no_activation = np.where(eda_eventrelated["EDA_SCR"] == 0)[0][0] assert int( pd.DataFrame(eda_eventrelated.values[no_activation]).isna().sum()) == 4 assert len(eda_eventrelated["Label"]) == 3 # Test warning on missing columns with pytest.warns(nk.misc.NeuroKitWarning, match=r".*does not have an `EDA_Phasic`.*"): first_epoch_key = list(epochs.keys())[0] first_epoch_copy = epochs[first_epoch_key].copy() del first_epoch_copy["EDA_Phasic"] nk.eda_eventrelated({**epochs, first_epoch_key: first_epoch_copy}) with pytest.warns(nk.misc.NeuroKitWarning, match=r".*does not have an `SCR_Amplitude`.*"): first_epoch_key = list(epochs.keys())[0] first_epoch_copy = epochs[first_epoch_key].copy() del first_epoch_copy["SCR_Amplitude"] nk.eda_eventrelated({**epochs, first_epoch_key: first_epoch_copy}) with pytest.warns(nk.misc.NeuroKitWarning, match=r".*does not have an `SCR_RecoveryTime`.*"): first_epoch_key = list(epochs.keys())[0] first_epoch_copy = epochs[first_epoch_key].copy() del first_epoch_copy["SCR_RecoveryTime"] nk.eda_eventrelated({**epochs, first_epoch_key: first_epoch_copy}) with pytest.warns(nk.misc.NeuroKitWarning, match=r".*does not have an `SCR_RiseTime`.*"): first_epoch_key = list(epochs.keys())[0] first_epoch_copy = epochs[first_epoch_key].copy() del first_epoch_copy["SCR_RiseTime"] nk.eda_eventrelated({**epochs, first_epoch_key: first_epoch_copy})
def test_eda_eventrelated(): eda = nk.eda_simulate(duration=15, scr_number=3) eda_signals, info = nk.eda_process(eda, sampling_rate=1000) epochs = nk.epochs_create(eda_signals, events=[5000, 10000, 15000], sampling_rate=1000, epochs_start=-0.1, epochs_end=1.9) eda_eventrelated = nk.eda_eventrelated(epochs) no_activation = np.where(eda_eventrelated["EDA_SCR"] == 0)[0][0] assert int(pd.DataFrame(eda_eventrelated.values [no_activation]).isna().sum()) == 4 assert len(eda_eventrelated["Label"]) == 3
def test_eda_eventrelated(): eda = nk.eda_simulate(duration=15, scr_number=3) eda_signals, info = nk.eda_process(eda, sampling_rate=1000) epochs = nk.epochs_create(eda_signals, events=[5000, 10000, 15000], sampling_rate=1000, epochs_start=-0.1, epochs_end=1.9) eda_eventrelated = nk.eda_eventrelated(epochs) no_activation = np.where(eda_eventrelated["EDA_Activation"] == 0)[0][0] assert int( pd.DataFrame(eda_eventrelated.values[no_activation]).isna().sum()) == 4 assert len(eda_eventrelated["Label"]) == 3 assert len(eda_eventrelated.columns) == 6 assert all(elem in [ "EDA_Activation", "EDA_Peak_Amplitude", "EDA_Peak_Amplitude_Time", "EDA_RiseTime", "EDA_RecoveryTime", "Label" ] for elem in np.array(eda_eventrelated.columns.values, dtype=str))