Repository navigation
Commit 577a18b
authored
Use the last RR interval in compute_hr (#601)
`compute_hr` loops over `range(len(qrs_inds) - 2)` and then copies the
rate at the last beat forward (`heart_rate[qrs_inds[-1]:] =
heart_rate[qrs_inds[-1]]`). So the interval between the last two beats
is never used:
- `compute_hr(14, [0, 2, 6, 12], fs=60)` gives 900 bpm after sample 12
(from the 2-sample interval before it) instead of 600 bpm (from the last
interval, 6 samples).
- `compute_hr(10, [2, 6], fs=1)` returns only NaN, although the
`len(qrs_inds) < 2` check implies two beats are enough.
The loop now runs over every RR interval, and the last one fills up to
the end of the signal. Everything before the last beat is unchanged. For
record 100 with the reference annotations, the only differences are the
8 samples after the last beat.
Two tests are added in `TestComputeHr`, and both fail on `main`. `ruff
check` is clean and `pytest -m "not network"` passes.
Related to #185, but that report was mostly caused by non-beat
annotations (see the comments there), so this doesn't close it.3 files changed
Lines changed: 43 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | | - | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | | - | |
41 | | - | |
42 | | - | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
177 | 208 | | |
178 | 209 | | |
179 | 210 | | |
| |||
0 commit comments