def generate(time: int, rate: int): ecg1 = nk.ecg_simulate(duration=time, sampling_rate= rate, method = "ecgsyn") # duration - ile sekund #sampling rate - ile punktów na sekunde ecg2 = nk.ecg_simulate(duration=time, sampling_rate= rate, method = "ecgsyn") ecg3 = nk.ecg_simulate(duration=time, sampling_rate= rate, method="ecgsyn") ecg4 = nk.ecg_simulate(duration=time, sampling_rate= rate, method="daubechies") emg1 = nk.emg_simulate(duration=time, sampling_rate= rate, random_state=1, burst_number=3) emg2 = nk.emg_simulate(duration=time, sampling_rate= rate, random_state=2, burst_number=3) emg3 = nk.emg_simulate(duration=time, sampling_rate= rate, random_state=3, burst_number=3) emg4 = nk.emg_simulate(duration=time, sampling_rate= rate, random_state=4, burst_number=3) # sa jeszcze analogicznie fajne wykresy dla ppg, rsp i eda nk.signal_plot(ecg1, sampling_rate=rate) nk.signal_plot(ecg2, sampling_rate=rate) data = pd.DataFrame({'ecg1': ecg1, 'ecg2': ecg2, 'emg1': emg1, }) return data
def test_signal_plot(): # Test with array signal = nk.signal_simulate(duration=10, sampling_rate=1000) nk.signal_plot(signal, sampling_rate=1000) fig = plt.gcf() for ax in fig.get_axes(): handles, labels = ax.get_legend_handles_labels() assert labels == ['Signal'] assert len(labels) == len(handles) == len([signal]) assert ax.get_xlabel() == 'Time (s)' plt.close(fig) # Test with dataframe data = pd.DataFrame({ "Signal2": np.cos(np.linspace(start=0, stop=20, num=1000)), "Signal3": np.sin(np.linspace(start=0, stop=20, num=1000)), "Signal4": nk.signal_binarize(np.cos(np.linspace(start=0, stop=40, num=1000))) }) nk.signal_plot(data, sampling_rate=None) fig = plt.gcf() for ax in fig.get_axes(): handles, labels = ax.get_legend_handles_labels() assert labels == list(data.columns.values) assert len(labels) == len(handles) == len(data.columns) assert ax.get_xlabel() == 'Samples' plt.close(fig) # Test with list signal = nk.signal_binarize(nk.signal_simulate(duration=10)) phase = nk.signal_phase(signal, method="percents") nk.signal_plot([signal, phase]) fig = plt.gcf() for ax in fig.get_axes(): handles, labels = ax.get_legend_handles_labels() assert labels == ['Signal1', 'Signal2'] assert len(labels) == len(handles) == len([signal, phase]) assert ax.get_xlabel() == 'Samples' plt.close(fig)
# Generate synthetic signals ecg = nk.ecg_simulate(duration=10, heart_rate=70) ppg = nk.ppg_simulate(duration=10, heart_rate=70) rsp = nk.rsp_simulate(duration=10, respiratory_rate=15) eda = nk.eda_simulate(duration=10, scr_number=3) emg = nk.emg_simulate(duration=10, burst_number=2) # Visualise biosignals data = pd.DataFrame({ "ECG": ecg, "PPG": ppg, "RSP": rsp, "EDA": eda, "EMG": emg }) nk.signal_plot(data, subplots=True) # Save it data = pd.DataFrame({ "ECG": nk.ecg_simulate(duration=10, heart_rate=70, noise=0), "PPG": nk.ppg_simulate(duration=10, heart_rate=70, powerline_amplitude=0), "RSP": nk.rsp_simulate(duration=10, respiratory_rate=15, noise=0), "EDA": nk.eda_simulate(duration=10, scr_number=3, noise=0), "EMG": nk.emg_simulate(duration=10, burst_number=2, noise=0) }) plot = data.plot(subplots=True,
samples = 8 * (normal1 + normal2) #facteur 8 seulement pour scaler entre 0 et 3.3 # La valeur en Voltage d'une personne qui a une systolique normal (120), est autour de 2.8 , pour une systolique eleve(140), on est autour de 3.2 , une sytolique basse (100) est autour de 2.3 #la valeur en Voltage d'une personne qui a une diastolique normal (80) est autour de 1.8 , pour une diastolique eleve(90), on est atour de 2.10, une diastolique basse (60) est autour de 1.4 #prolongement du signal de pression selon le temps de signal voulu for i in range(0,int(t)): for y in samples: ech_array.append(y) elif "re" in signaltype: t_sin = np.arange(t*f) ech_array = 1.65 * np.sin(respiration * (2 * np.pi * t_sin) / f) + 1.65 # le plus 1 est pour ne pas avoir de valeur negative elif "pe" in signaltype: ech_array = genPespiration(pespiration,step,f,t) else : ValueError("The f**k is that signal type ?? give me a valid one , you gave me {}".format(signaltype)) # # Visualize ecg = pd.DataFrame({"{}".format(signaltype): ech_array}) nk.signal_plot(ecg) # plt.show() generateVHDLsamples(ech_array,signaltype)