Skip to content

Commit 0d6a997

Browse files
committed
hrv - fixed standardization order
1 parent 9acf790 commit 0d6a997

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/data_analysis/heart_rate_variability/exploring_heart_rate_variability.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,16 @@
122122
window (-> resampled-ppi
123123
:ppi
124124
(dtype/sub-buffer start-idx window-size))
125-
window-standardized (stats/standardize window)
125+
;; Filter first, then standardize for FFT normalization
126126
window-filtered (.bandPassFilter bw
127-
(double-array window-standardized)
127+
(double-array window)
128128
4
129129
0.04 ; Lower cutoff at 0.04 Hz to remove baseline drift
130130
0.4)
131+
window-standardized (stats/standardize window-filtered)
131132
;; Apply Hann window to reduce spectral leakage
132133
hann-window (-> (Hanning. window-size) .getWindow)
133-
window-windowed (map * window-filtered hann-window)
134+
window-windowed (map * window-standardized hann-window)
134135
fft (DiscreteFourier. (double-array window-windowed))
135136
_ (.transform fft)
136137
whole-magnitude (.getMagnitude fft true)]

0 commit comments

Comments
 (0)