Project Python
Project Python
71762104013 Dinesh K
Methodology:
import numpy as np
import scipy.signal as signal
import matplotlib.pyplot as plt
fs = 100
t = np.linspace(0, 300, fs*300)
resp_signal = 0.5 * np.sin(2 * np.pi * 0.25 * t) + 0.05 *
np.random.randn(len(t))
plt.figure(figsize=(15, 8))
plt.subplot(3, 1, 1)
plt.plot(t, resp_signal)
plt.title('Noisy Respiratory Signal')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.subplot(3, 1, 2)
plt.plot(t, filtered_signal)
plt.plot(peak_times, filtered_signal[peaks], 'rx')
plt.title('Filtered Signal with Detected Breaths')
plt.xlabel('Time (s)')
plt.ylabel('Amplitude')
plt.subplot(3, 1, 3)
plt.plot(time_midpoints, respiratory_rates, marker='o')
plt.title('Respiratory Rate Over Time')
plt.xlabel('Time (s)')
plt.ylabel('Respiratory Rate (breaths per minute)')
plt.tight_layout()
plt.show()
Interpretation of Results:
Conclusion: