Open PremchandGat opened 1 year ago
#Import modules: from freqAnalysis import freq_domain from hrv.rri import RRi #Dummy data: rri = RRi([1016, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192, 1168, 1632, 1192]) #create object: obj = freq_domain(rri=rri, fs=4, method='welch', interp_method='cubic', detrend='linear')
features = obj.getFeatures() print(features)
output: {'lf': 0.023100473006951762, 'hf': 37404.08157812515, 'lf_hf_ratio': 6.175923063022486e-07, 'lfnu': 6.175919248822274e-05, 'hfnu': 99.99993824080751, 'total_power': 37411.41202473894, 'vlf': 7.307346140781096}
plot: This method creates a chart between freq and PSD.
#Plot chart obj.plot()
getGraphDataPoints: This method returns data points of the x-axis and y-axis of the chart(frequency and power spectral density[PSD] array).
dataPoints = obj.getGraphDataPoints() print(dataPoints)
Output: {'freq': array([0.00000000e+00, 9.76562500e-04, 1.95312500e-03, ..., 1.99804688e+00, 1.99902344e+00, 2.00000000e+00]), 'psd': array([3.17379998e+02, 6.31607217e+02, 6.22232520e+02, ..., 1.67977878e-01, 1.70170084e-01, 8.54533116e-02])}
Created a new class freq_domain. This class has three methods "getFeatures", "plot" and "getGraphDataPoints".
plot: This method creates a chart between freq and PSD.
getGraphDataPoints: This method returns data points of the x-axis and y-axis of the chart(frequency and power spectral density[PSD] array).