stress si: segment at gaps like cvhr does - #70
Conversation
baevsky stress index had no way to tell a charging/off-wrist hole from real physiology - it just slid a window over the raw nn array. a straddling window picks up the pre/post-gap RR jump as MxDMn, same bug class cvhr_apnea already fixed. add optional nnTimesMs + maxGapSec, segment first, no-times callers unchanged.
There was a problem hiding this comment.
Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 6 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
Warning Review limit reachedNext included review available in 23 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideMakes Baevsky stress index gap-aware by segmenting timestamped RR data before applying 256-beat sliding windows, preventing cross-gap RR jumps from inflating MxDMn while preserving untimed behavior; adds a regression test covering the charging-hole case. Sequence diagram for gap-safe stress index calculationsequenceDiagram
participant Caller
participant baevskyStressIndex
participant Segmentation
participant Windowing
participant SI as _siOfSegment
Caller->>baevskyStressIndex: baevskyStressIndex(nnMs, nnTimesMs, maxGapSec)
baevskyStressIndex->>baevskyStressIndex: Filter RR intervals
alt Valid nnTimesMs supplied
baevskyStressIndex->>Segmentation: Detect timestamp gaps over maxGapSec
Segmentation-->>baevskyStressIndex: Per-segment RR ranges
else No valid timestamps
baevskyStressIndex->>Segmentation: Use one implicit segment
end
loop Each segment and sliding window
baevskyStressIndex->>Windowing: Create 256-beat window
Windowing->>SI: _siOfSegment(segWin, minRangeMs)
SI-->>Windowing: Window stress statistics
Windowing-->>baevskyStressIndex: Collect statistics
end
baevskyStressIndex-->>Caller: Median StressIndex or absent metric
Flow diagram for gap-aware Baevsky stress indexflowchart TD
A[RR intervals and optional timestamps] --> B[Filter RR intervals to 300-2000 ms]
B --> C{Valid timestamps with gap over maxGapSec?}
C -- No --> D[Use one implicit segment]
C -- Yes --> E[Split into segments at gaps]
D --> F[Apply 256-beat sliding windows]
E --> F
F --> G[Compute _siOfSegment for each window]
G --> H[Aggregate window statistics and median]
H --> I[Return StressIndex or absent metric]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
baevsky stress index had no gap-awareness - it just slides a 256-beat window over the raw nn array. a straddling window across a charging/off-wrist hole picks up the pre/post-gap RR jump as MxDMn, same failure mode cvhr_apnea.dart already fixed (its header even documents the 80.0/h -> 53.3/h bug this caused there).
adds optional nnTimesMs + maxGapSec (default 30s, same as cvhr) to baevskyStressIndex, segments at gaps before sliding the window, concatenates per-segment window stats before the median. no-times callers are byte-identical (single implicit segment).
test added mirroring cvhr's own gap regression test.
Summary by Sourcery
Segment Baevsky stress-index calculations at recording gaps before computing sliding-window statistics.
New Features:
Bug Fixes:
Tests: