Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrequencyDomainAnalysis class added: Plot graph and get features #29

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

PremchandGat
Copy link

Created a new class freq_domain. This class has three methods "getFeatures", "plot" and "getGraphDataPoints".

#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')
  1. getFeatures: This method returns the dictionary of LF, HF, Ratio between LF and HF, LFnu, HFnu, VLF, and Total power.
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}

  1. plot: This method creates a chart between freq and PSD.
#Plot chart
obj.plot()

Graph

  1. 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])}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant