Skip to content

Commit de2a28e

Browse files
committed
mths - wip
1 parent 5cd5329 commit de2a28e

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

src/dsp/mths.clj

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@
280280
:high-cutoff high-cutoff})
281281
:standardize stats/standardize}))
282282

283-
;; ## Power Spectrum Analysis: Extracting Heart Rate
283+
;; ## Power Spectrum Analysis: Extracting Heart Rate - DRAFT
284+
;;
285+
;; 🛠 NOTE: This is stil work-in-progress. In visualizing, we need to scale the frequency domain exist correctly.
284286
;;
285287
;; Now comes the key step: **extracting heart rate from the camera signal**.
286288
;;
@@ -397,7 +399,7 @@
397399
(kind/fragment
398400
[(kind/hiccup
399401
[:div
400-
[:h4 "1. Raw Windowed Signal (after preprocessing)"]
402+
[:h4 "1. Raw windowed signal (after preprocessing)"]
401403
[:p "Each row is a time sample, showing how the signal varies across windows (columns) and channels."]])
402404

403405
(-> windows
@@ -406,7 +408,7 @@
406408

407409
(kind/hiccup
408410
[:div
409-
[:h4 "2. After Hanning Window"]
411+
[:h4 "2. After Hanning window"]
410412
[:p "Notice how the edges of each window are tapered to zero. This reduces spectral leakage in the FFT."]])
411413

412414
(-> hanninged-windows
@@ -415,22 +417,29 @@
415417

416418
(kind/hiccup
417419
[:div
418-
[:h4 "3. Power Spectrum"]
420+
[:h4 "3. Power spectrum"]
419421
[:p "Each row is a frequency bin. Bright bands indicate strong frequency components. "
420422
"The dominant frequency (brightest band in the 0.65-4 Hz range) corresponds to the heart rate."]])
421423

422424
(-> power-spectrum
423425
plotly/imshow)
424426

425-
(kind/md "### 4. Power Spectrum Time Series\n\nEach plot shows how the power spectrum evolves over time.")
427+
(kind/md "4. Slicing the power spectrum along time\n\nEach plot shows how the power spectrum at one window.")
426428

427429
(-> power-spectrum
428430
(tensor/slice 1)
429431
(->> (map (fn [s]
430432
(-> s
431433
ds-tensor/tensor->dataset
432434
(tc/rename-columns [:R :G :B])
433-
plot-signal)))
435+
(plotly/base {:=x :x
436+
:=mark-opacity 0.7})
437+
(plotly/layer-line {:=y :R
438+
:=mark-color "red"})
439+
(plotly/layer-line {:=y :G
440+
:=mark-color "green"})
441+
(plotly/layer-line {:=y :B
442+
:=mark-color "blue"}))))
434443
(into [:div {:style {:max-height "600px"
435444
:overflow-y "auto"}}])
436445
kind/hiccup))]))

0 commit comments

Comments
 (0)