Recovering index into original data from rpeaks array
sunshineinsandiego opened this issue · 2 comments
Hi - I'm trying to recover the indices corresponding to the identified R-peak locations in my raw_ecg_data
. From the docs, it appears rpeaks
is an array with the time locations of each R-peak in ms.
For example, if my `rpeaks' array looks like this:
rpeaks = [37, 142, 159, ..., 18752]
Then I assume the detected R-peaks occur 37ms, 142ms, 159ms...18752ms from the start of the signal.
If my sampling_rate
is 100hz, then locating the R-peaks in my original data should be a simple as dividing the rpeaks
array by 1/sampling_rate
.
For this example, it would be:
rpeaks = [37, 142, 159, ..., 18752]
sampling_rate = 100
rpeak_indices = rpeaks / (1/sampling_rate)
rpeak_indices = [3700, 14200, 15900,...1875200] # R-peak locations in original raw_ecg_data
And I would be able to locate the actual value or amplitude for each R-peak in my raw_ecg_data
as follows:
Rpeak_1 = raw_ecg_data[3700]
Rpeak_2 = raw_ecg_data[14200]
...
Rpeak_1 = raw_ecg_data[1875200]
Does this seem accurate? Thanks!
Hello @sunshineinsandiego !
Thank you for reaching out. The function ecg.ecg
returns an array rpeaks
, which corresponds to the indices of the R-peaks location.
This means that you could obtain the actual value or amplitude for each R-peak in your raw_ecg_data
simply by doing:
raw_ecg_data[rpeaks]
Did this answer your question?
Yes, got it! Thanks much!