Replies: 1 comment
-
import neurokit2 as nk
import matplotlib.pyplot as plt
ecg = nk.ecg_simulate(duration=15, sampling_rate=1000, heart_rate=80, noise = 0.05)
qrs_epochs = nk.ecg_segment(ecg, rpeaks=None, sampling_rate=1000)
qrs_epochs["1"]
638 rows × 3 columns ```It does not have 2 columns of signal, but one index (the time) and the signal. Hope that helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
According to the documents, the return of ecg_segment() should be like
{
index_1: dataframe_1,
index_2: dataframe_2,
...
index_n: dataframe_n
}
And the dataframe above should be like
Signal Index Label
0 -0.347692 0.000000 -43
1 -0.346690 0.000000 -42
2 -0.345688 0.000000 -41
3 -0.344687 0.000000 -40
4 -0.343685 0.000000 -39
... ... ... ...
796 0.449838 0.175201 753
797 0.450840 0.173778 754
798 0.451842 0.171683 755
799 0.452844 0.168599 756
800 0.453846 0.165006 757
[801 rows x 3 columns]
But in my code, when I print the return of this function, the result is not I expect like
{'1': Signal Index Label
-0.362282 -0.068727 386 1
-0.361281 -0.071331 387 1
-0.360280 -0.075279 388 1
-0.359279 -0.080850 389 1
-0.358278 -0.088321 390 1
... ... ... ...
0.470684 0.016181 1218 1
0.471685 0.018712 1219 1
0.472686 0.020572 1220 1
0.473688 0.021617 1221 1
0.474689 0.021800 1222 1
[837 rows x 3 columns], '2': Signal Index Label
-0.362282 -0.024333 1120 2
-0.361281 -0.023250 1121 2
-0.360280 -0.020961 1122 2
-0.359279 -0.017749 1123 2
-0.358278 -0.013920 1124 2
... ... ... ...
0.470684 -0.012553 1952 2
0.471685 -0.007514 1953 2
0.472686 -0.002372 1954 2
0.473688 0.002745 1955 2
0.474689 0.007706 1956 2
[837 rows x 3 columns], '3': Signal Index Label
-0.362282 0.003646 1859 3
-0.361281 0.009091 1860 3
-0.360280 0.013710 1861 3
-0.359279 0.017185 1862 3
-0.358278 0.019518 1863 3
... ... ... ...
0.470684 -0.074716 2691 3
0.471685 -0.074068 2692 3
0.472686 -0.073069 2693 3
0.473688 -0.071811 2694 3
0.474689 -0.070389 2695 3
[837 rows x 3 columns], '4': Signal Index Label
-0.362282 -0.083960 2620 4
-0.361281 -0.085052 2621 4
-0.360280 -0.086684 2622 4
-0.359279 -0.088842 2623 4
-0.358278 -0.091368 2624 4
... ... ... ...
0.470684 -0.146104 3452 4
0.471685 -0.143141 3453 4
0.472686 -0.139778 3454 4
0.473688 -0.136200 3455 4
0.474689 -0.132591 3456 4
[837 rows x 3 columns], '5': Signal Index Label
-0.362282 -0.157791 3389 5
-0.361281 -0.161455 3390 5
-0.360280 -0.165148 3391 5
-0.359279 -0.168777 3392 5
-0.358278 -0.172245 3393 5
... ... ... ...
0.470684 -0.071297 4221 5
0.471685 -0.070350 4222 5
0.472686 -0.069044 4223 5
0.473688 -0.067412 4224 5
0.474689 -0.065551 4225 5
[837 rows x 3 columns], '6': Signal Index Label
-0.362282 -0.051251 4139 6
-0.361281 -0.051414 4140 6
-0.360280 -0.051924 4141 6
-0.359279 -0.052788 4142 6
-0.358278 -0.054012 4143 6
... ... ... ...
0.470684 0.081000 4971 6
0.471685 0.085161 4972 6
0.472686 0.088976 4973 6
0.473688 0.092293 4974 6
0.474689 0.095058 4975 6
[837 rows x 3 columns], '7': Signal Index Label
-0.362282 0.051321 4874 7
-0.361281 0.049419 4875 7
-0.360280 0.047611 4876 7
-0.359279 0.045922 4877 7
-0.358278 0.044377 4878 7
... ... ... ...
0.470684 0.080012 5706 7
0.471685 0.075071 5707 7
0.472686 0.069237 5708 7
0.473688 0.062884 5709 7
0.474689 0.056382 5710 7
[837 rows x 3 columns], '8': Signal Index Label
-0.362282 0.010795 5615 8
-0.361281 0.005519 5616 8
-0.360280 -0.000402 5617 8
-0.359279 -0.006598 5618 8
-0.358278 -0.012700 5619 8
... ... ... ...
0.470684 -0.055848 6447 8
0.471685 -0.054374 6448 8
0.472686 -0.052740 6449 8
0.473688 -0.051294 6450 8
0.474689 -0.050383 6451 8
[837 rows x 3 columns], '9': Signal Index Label
-0.362282 -0.044441 6373 9
-0.361281 -0.045785 6374 9
-0.360280 -0.045988 6375 9
-0.359279 -0.045201 6376 9
-0.358278 -0.043634 6377 9
... ... ... ...
0.470684 -0.079015 7205 9
0.471685 -0.082239 7206 9
0.472686 -0.085554 7207 9
0.473688 -0.088828 7208 9
0.474689 -0.091928 7209 9
[837 rows x 3 columns], '10': Signal Index Label
-0.362282 -0.098939 7134 10
-0.361281 -0.099188 7135 10
-0.360280 -0.099477 7136 10
-0.359279 -0.099804 7137 10
-0.358278 -0.100167 7138 10
... ... ... ...
0.470684 -0.065222 7966 10
0.471685 -0.065839 7967 10
0.472686 -0.066438 7968 10
0.473688 -0.066985 7969 10
0.474689 -0.067447 7970 10
[837 rows x 3 columns], '11': Signal Index Label
-0.362282 -0.067424 7882 11
-0.361281 -0.067652 7883 11
-0.360280 -0.067633 7884 11
-0.359279 -0.067314 7885 11
-0.358278 -0.066683 7886 11
... ... ... ...
0.470684 0.038891 8714 11
0.471685 0.037591 8715 11
0.472686 0.036268 8716 11
0.473688 0.034927 8717 11
0.474689 0.033582 8718 11
[837 rows x 3 columns], '12': Signal Index Label
-0.362282 0.026439 8620 12
-0.361281 0.026306 8621 12
-0.360280 0.026154 8622 12
-0.359279 0.025978 8623 12
-0.358278 0.025772 8624 12
... ... ... ...
0.470684 0.049031 9452 12
0.471685 0.049093 9453 12
0.472686 0.049481 9454 12
0.473688 0.050287 9455 12
0.474689 0.051601 9456 12
[837 rows x 3 columns], '13': Signal Index Label
-0.362282 0.017697 9364 13
-0.361281 0.014394 9365 13
-0.360280 0.011896 9366 13
-0.359279 0.010292 9367 13
-0.358278 0.009519 9368 13
... ... ... ...
0.470684 0.006695 10196 13
0.471685 0.006575 10197 13
0.472686 0.006800 10198 13
0.473688 0.007351 10199 13
0.474689 0.008208 10200 13
[837 rows x 3 columns], '14': Signal Index Label
-0.362282 0.024189 10118 14
-0.361281 0.020386 10119 14
-0.360280 0.015918 10120 14
-0.359279 0.011043 10121 14
-0.358278 0.006018 10122 14
... ... ... ...
0.470684 -0.112950 10950 14
0.471685 -0.116716 10951 14
0.472686 -0.120453 10952 14
0.473688 -0.123971 10953 14
0.474689 -0.127077 10954 14
[837 rows x 3 columns], '15': Signal Index Label
-0.362282 -0.091655 10875 15
-0.361281 -0.092006 10876 15
-0.360280 -0.092695 10877 15
-0.359279 -0.093731 10878 15
-0.358278 -0.095066 10879 15
... ... ... ...
0.470684 -0.073150 11707 15
0.471685 -0.074615 11708 15
0.472686 -0.075689 11709 15
0.473688 -0.076428 11710 15
0.474689 -0.076891 11711 15
[837 rows x 3 columns], '16': Signal Index Label
-0.362282 -0.107819 11628 16
-0.361281 -0.108235 11629 16
-0.360280 -0.108140 11630 16
-0.359279 -0.107602 11631 16
-0.358278 -0.106690 11632 16
... ... ... ...
0.470684 -0.074242 12460 16
0.471685 -0.072825 12461 16
0.472686 -0.071309 12462 16
0.473688 -0.069785 12463 16
0.474689 -0.068341 12464 16
[837 rows x 3 columns], '17': Signal Index Label
-0.362282 -0.043677 12380 17
-0.361281 -0.041294 12381 17
-0.360280 -0.038814 12382 17
-0.359279 -0.036311 12383 17
-0.358278 -0.033860 12384 17
... ... ... ...
0.470684 0.011094 13212 17
0.471685 0.017552 13213 17
0.472686 0.023655 13214 17
0.473688 0.028963 13215 17
0.474689 0.033035 13216 17
[837 rows x 3 columns], '18': Signal Index Label
-0.362282 -0.017754 13132 18
-0.361281 -0.017104 13133 18
-0.360280 -0.016538 13134 18
-0.359279 -0.016030 13135 18
-0.358278 -0.015552 13136 18
... ... ... ...
0.470684 0.021305 13964 18
0.471685 0.020191 13965 18
0.472686 0.019159 13966 18
0.473688 0.018323 13967 18
0.474689 0.017797 13968 18
[837 rows x 3 columns], '19': Signal Index Label
-0.362282 NaN 13878 19
-0.361281 NaN 13879 19
-0.360280 NaN 13880 19
-0.359279 NaN 13881 19
-0.358278 NaN 13882 19
... ... ... ...
0.470684 NaN 14710 19
0.471685 NaN 14711 19
0.472686 NaN 14712 19
0.473688 NaN 14713 19
0.474689 NaN 14714 19
[837 rows x 3 columns]}
Here is my code:
import neurokit2 as nk
import matplotlib.pyplot as plt
ecg = nk.ecg_simulate(duration=15, sampling_rate=1000, heart_rate=80, noise = 0.05)
qrs_epochs = nk.ecg_segment(ecg, rpeaks=None, sampling_rate=1000, show=True)
print(qrs_epochs)
plt.show()
So my question is: why the 'Signal' column in my result of print() seems to have 2 columns of data????It's so weird to me
Beta Was this translation helpful? Give feedback.
All reactions