Skip to content

Commit 9acf790

Browse files
committed
hrv - windowing before fft
1 parent e98b9e0 commit 9acf790

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/data_analysis/heart_rate_variability/exploring_heart_rate_variability.clj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
(:import [com.github.psambit9791.jdsp.signal CrossCorrelation]
5050
[com.github.psambit9791.jdsp.signal.peaks FindPeak]
5151
[com.github.psambit9791.jdsp.filter Butterworth]
52-
[com.github.psambit9791.jdsp.transform DiscreteFourier]))
52+
[com.github.psambit9791.jdsp.transform DiscreteFourier]
53+
[com.github.psambit9791.jdsp.windows Hanning]))
5354

5455
;; ## My pulse-to-pulse intervals
5556

@@ -127,7 +128,10 @@
127128
4
128129
0.04 ; Lower cutoff at 0.04 Hz to remove baseline drift
129130
0.4)
130-
fft (DiscreteFourier. (double-array window-filtered))
131+
;; Apply Hann window to reduce spectral leakage
132+
hann-window (-> (Hanning. window-size) .getWindow)
133+
window-windowed (map * window-filtered hann-window)
134+
fft (DiscreteFourier. (double-array window-windowed))
131135
_ (.transform fft)
132136
whole-magnitude (.getMagnitude fft true)]
133137
{:t (* w hop-size (/ 1.0 sampling-rate))

0 commit comments

Comments
 (0)