def test_emg_activation(): emg = nk.emg_simulate(duration=10, burst_number=3) cleaned = nk.emg_clean(emg) emg_amplitude = nk.emg_amplitude(cleaned) activity_signal, info = nk.emg_activation(emg_amplitude) assert set(activity_signal.columns.to_list()) == set(list(info.keys())) assert len(info['EMG_Onsets']) == len(info['EMG_Offsets']) for i, j in zip(info['EMG_Onsets'], info['EMG_Offsets']): assert i < j
def test_emg_clean(): sampling_rate=1000 emg = nk.emg_simulate(duration=20, sampling_rate=sampling_rate) emg_cleaned = nk.emg_clean(emg, sampling_rate=sampling_rate) assert emg.size == emg_cleaned.size # Comparison to biosppy (https://github.com/PIA-Group/BioSPPy/blob/e65da30f6379852ecb98f8e2e0c9b4b5175416c3/biosppy/signals/emg.py) original, _, _ = biosppy.tools.filter_signal(signal=emg, ftype='butter', band='highpass', order=4, frequency=100, sampling_rate=sampling_rate) emg_cleaned_biosppy = nk.signal_detrend(original, order=0) assert np.allclose((emg_cleaned - emg_cleaned_biosppy).mean(), 0, atol=1e-6)