Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Errors when trying to processa and analyze ppg_signal using ppg_processa and ppg_analyze #957

Open
youngjaeheo2002 opened this issue Jan 27, 2024 · 6 comments
Labels
wontfix This will not be worked on

Comments

@youngjaeheo2002
Copy link

youngjaeheo2002 commented Jan 27, 2024

Maybe someone could tell me what I'm doing wrong or maybe it's a bug...

I tried to run tihs piece of code.

 ppg_signal = ppg['ch2'].values
        ppg_signal = nk.ppg_clean(ppg_signal =ppg_signal,sampling_rate = 64,method = 'elgendi')

        df,info = nk.ppg_process(ppg_signal,sampling_rate =64)
        results = nk.ppg_analyze(data = df, sampling_rate = 64)

and I got these errors in the files

/home/heoyoun1/ENV/lib/python3.10/site-packages/neurokit2/hrv/hrv_nonlinear.py:474: NeuroKitWarning: DFA_alpha2 related indices will not be calculated. The maximum duration of the windows provided for the long-term correlation is smaller than the minimum duration of windows. Refer to the `scale` argument in `nk.fractal_dfa()` for more information.
  warn(
/home/heoyoun1/ENV/lib/python3.10/site-packages/neurokit2/complexity/entropy_multiscale.py:349: RuntimeWarning: invalid value encountered in scalar divide
  mse = np.trapz(mse) / len(mse)
/home/heoyoun1/ENV/lib/python3.10/site-packages/neurokit2/complexity/optim_complexity_k.py:134: RuntimeWarning: divide by zero encountered in divide
  normalization = (n - 1) / (np.floor((n - k_subrange) / k).astype(int) * k)
/home/heoyoun1/ENV/lib/python3.10/site-packages/neurokit2/complexity/optim_complexity_k.py:135: RuntimeWarning: invalid value encountered in multiply
  sets = (np.nansum(np.abs(np.diff(sig_values)), axis=1) * normalization) / k

Intel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD.
---------------------------------------------------------------------------
LinAlgError                               Traceback (most recent call last)
Cell In[19], [line 48](vscode-notebook-cell:?execution_count=19&line=48)
     [45](vscode-notebook-cell:?execution_count=19&line=45) ppg_signal = nk.ppg_clean(ppg_signal =ppg_signal,sampling_rate = 64,method = 'elgendi')
     [47](vscode-notebook-cell:?execution_count=19&line=47) df,info = nk.ppg_process(ppg_signal,sampling_rate =64)
---> [48](vscode-notebook-cell:?execution_count=19&line=48) results = nk.ppg_analyze(data = df, sampling_rate = 64)
     [49](vscode-notebook-cell:?execution_count=19&line=49) '''
     [50](vscode-notebook-cell:?execution_count=19&line=50) df, info = nk.ppg_process(data,sampling_rate = 100)
     [51](vscode-notebook-cell:?execution_count=19&line=51) nk.ppg_analyze(data = df,sampling_rate = 100)
     [52](vscode-notebook-cell:?execution_count=19&line=52) '''
     [53](vscode-notebook-cell:?execution_count=19&line=53) break   

File [~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113), in ppg_analyze(data, sampling_rate, method)
    [111](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:111)     duration = len(data) / sampling_rate
    [112](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:112) if duration >= 10:
--> [113](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113)     features = ppg_intervalrelated(data, sampling_rate=sampling_rate)
    [114](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:114) else:
    [115](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:115)     features = ppg_eventrelated(data)

File [~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64), in ppg_intervalrelated(data, sampling_rate)
     [62](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:62) if len(rate_cols) == 1:
     [63](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:63)     intervals.update(_ppg_intervalrelated_formatinput(data))
---> [64](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64)     intervals.update(*_ppg_intervalrelated_hrv(data, sampling_rate))
     [65](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:65) else:
     [66](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:66)     raise ValueError(
...
File [~/ENV/lib/python3.10/site-packages/numpy/linalg/linalg.py:124](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/numpy/linalg/linalg.py:124), in _raise_linalgerror_lstsq(err, flag)
    [123](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/numpy/linalg/linalg.py:123) def _raise_linalgerror_lstsq(err, flag):
--> [124](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/numpy/linalg/linalg.py:124)     raise LinAlgError("SVD did not converge in Linear Least Squares")

LinAlgError: SVD did not converge in Linear Least Squares

Also i'll print out the data that was used as input

this is ppg_signal:

[0.29799772 0.29818196 0.29840656 0.29855292 0.29873463 0.29871444
 0.29880278 0.29889109 0.29895167 0.29921666 0.29933526 0.29942106
 0.29959015 0.29955229 0.2995296  0.29951193 0.2995296  0.29948164
 0.29959774 0.29969362 0.29990058 0.29991571 0.30004947 0.30011762
 0.30015294 0.30019333 0.30035735 0.3005441  0.30070309 0.30080405
 0.30091509 0.30104885 0.30117251 0.30135169 0.30145263 0.30148292
 0.30150561 0.30145263 0.30150311 0.3014501  0.30162171 0.30160405
 0.30168733 0.30180846 0.30182361 0.30184381 0.30184128 0.30186398
 0.30189176 0.30193718 0.30199017 0.30213402 0.30215925 0.30220467
 0.30219711 0.30216178 0.30206841 0.30209364 0.30227029 0.30229554
 0.30230058 0.30231824 0.30220217 0.30223749 0.30220217 0.30242424
 0.30248482 0.30254034 0.30257063 0.30203308 0.30012769 0.29769237
 0.29610498 0.2957037  0.29645828 0.29768731 0.2989769  0.29991571
 0.30058195 0.3009807  0.30124822 0.30145263 0.30154347 0.30161918
 0.30180846 0.30189933 0.30206335 0.30208354 0.3022072  0.30227282
 0.30242171 0.30236116 0.30241414 0.30245706 0.30234853 0.30241161
 0.302452   0.30243434 0.30238135 0.30235359 0.30238385 0.30229807
 0.30228038 0.3020886  0.30204569 0.30185894 0.30181855 0.30182865
 0.30177313 0.30185894 0.30177313 0.30166463 0.3014274  0.30136178
 0.30138198 0.30131887 0.30124822 0.30107913 0.30093275 0.30084694
 0.30062234 0.30049868 0.3005214  0.30048101 0.30056176 0.30043053
 0.30023875 0.30011762 0.29984253 0.29969615 0.29943369 0.2992747
 0.29922422 0.29912328 0.29901225 0.29904001 0.29890372 0.2987523
 0.29873463 0.29862863 0.29856808 0.29848984 0.29857311 0.29859331
 0.2985075  0.2983788  0.29835861 0.29827784 0.29812895 0.29805324
 0.2980482  0.29793717 0.29787912 0.29787912 0.29779835 0.29765198
 0.29764692 0.29764945 0.29763683 0.29759897 0.29754852 0.29745008
 0.29749047 0.29759897 0.29754852 0.29754345 0.29757121 0.29745261
 0.29739456 0.29743495 0.29762673 0.29771254 0.29783873 0.2978337
 0.2978463  0.29774536 0.29786649 0.29779331 0.29789931 0.29801288
 0.29797502 0.29789425 0.2978236  0.2977302  0.29761666 0.29766965
 0.29749047 0.29745008 0.2974955  0.29751823 0.29746524 0.29748037
 0.29741729 0.29732391 0.29741476 0.29741729 0.29741223 0.29750056
 0.29750309 0.29743495 0.29750309 0.29744252 0.29732642 0.29734408
 0.29733148 0.29734158 0.29722801 0.29710938 0.29704124 0.29705133
 0.29702107 0.29707153 0.29707153 0.29703117 0.29697562 0.29698322
 0.29696302 0.29691001 0.2970362  0.29698068 0.29699835 0.29699582
 0.29696049 0.29686206 0.29697312 0.29697815 0.29708162 0.29731632
 0.29725071 0.29736177 0.29729109 0.29707659 0.29734661 0.2974728
 0.29756871 0.2976116  0.29764945 0.29754345 0.29751066 0.2974728
 0.29750056 0.29735418 0.29738194 0.29744755 0.29747533 0.29762423
 0.2976015  0.29765198 0.29766712 0.29758888 0.2977075  0.29771003
 0.29777815 0.29779835 0.29800278 0.29814914 0.29817437 0.29825767
 0.29831569 0.2982829  0.29831569 0.2982728  0.29840656 0.29838133
 0.29841413 0.29848984 0.2985176  0.29864883 0.29864379 0.29869425
 0.2987296  0.29868921 0.29876239 0.29889868 0.29893654 0.29903495
 0.29921666 0.29918133 0.29913085 0.2990627  0.29924441 0.2993908
 0.29957502 0.29954726 0.29949931 0.29946651 0.29950184 0.29945135
 0.29942866 0.29959015 0.29959015 0.29956745 0.29946902 0.29939584
 0.29925451 0.29919646 0.29897943 0.29893401 0.2988381  0.29890119
 0.2987523  0.29877755 0.29867658 0.29854789 0.29841666 0.29823242
 0.2982829  0.29809109 0.29797502 0.29791191 0.29780341 0.29780088
 0.2977403  0.29758888 0.297387   0.29734408 0.29714977 0.29701854
 0.29699331 0.29690497 0.2968444  0.29674093 0.29667531 0.29668794
 0.29645828 0.29655418 0.29644567 0.2962589  0.2961731  0.29627659
 0.29631695 0.29636743 0.29642548 0.29627406 0.2962564  0.29614787
 0.29626649 0.29632958 0.29646081 0.29658447 0.29666522 0.29653905
 0.29660213 0.29661476 0.29667028 0.29667531 0.29678131 0.29698068
 0.29684946 0.29672832 0.29679141 0.29661726 0.29652138 0.29655924
 0.29648353 0.29643808 0.29650876 0.29635987 0.29643305 0.296375
 0.29634471 0.29644567 0.29639519 0.29640023 0.29643808 0.29643558
 0.29655165 0.29657437 0.29655671 0.29649613 0.296481   0.29642042
 0.29631192 0.29644314 0.29642295 0.29633211 0.29628919 0.29629929
 0.2962791  0.29628666 0.29628163 0.29630435 0.29631445 0.29634471
 0.29631948 0.29637247 0.29635734 0.29645071 0.29644061 0.29651379
 0.29648603 0.29644314 0.2963422  0.29630685 0.29640276 0.29652138
 0.29662989 0.29680654 0.29687975 0.29688225 0.29684693 0.29682926
 0.29696555 0.29702107 0.29712958 0.29723558 0.29709425 0.29704377
 0.29700088 0.29689741 0.29696302 0.29683179 0.29672326 0.29687215
 0.29685199 0.29696806 0.29692011 0.29692264 0.2968217  0.29688731
 0.29687215 0.29695796 0.29696049 0.29704124 0.29708919 0.29710688
 0.29718006 0.29717249 0.29717753 0.29697815 0.29711191 0.29708162
 0.29714977 0.29714724 0.2971548  0.29717753 0.29723558 0.2972482
 0.29723052 0.29738953 0.29743495 0.29753085 0.29758384 0.29769741
 0.29775545 0.29779584 0.29800528 0.29821222 0.29832328 0.29852769
 0.29855798 0.29855292 0.29873969 0.2989769  0.29928733 0.29949678
 0.29951444 0.29965576 0.29972897 0.29978449 0.29988039 0.29999646
 0.30018323 0.30032959 0.30045326 0.30047848 0.30033969 0.30037251
 0.30036998 0.30034473 0.30036998 0.3002867  0.3004053  0.30042044
 0.30054159 0.30054663 0.3005441  0.30050121 0.30048355 0.30051383
 0.30058448 0.30060215 0.30066776 0.30074853 0.30076873 0.30086713
 0.30078889 0.30077123 0.30069048 0.30066776 0.30064    0.3005542
 0.30057439 0.3005113  0.30048605 0.30051634 0.30048101 0.30035735
 0.30046082 0.30033969 0.30031446 0.30024379 0.30030687 0.30030183
 0.30024632 0.30026651 0.3004053  0.30042803 0.30043559 0.30037251
 0.30021856 0.30015547 0.30011256 0.30030183 0.30012265 0.30006208
 0.29992075 0.29979962 0.29966082 0.29959268 0.29944632 0.29945892
 0.29934788 0.29932769 0.29918133 0.29908037 0.29891634 0.29867155
 0.29845451 0.29829553 0.29794977 0.29780088 0.29762423 0.29738447
 0.29731129 0.29723558 0.29696049 0.29687468 0.29677122 0.29673336
 0.29680654 0.29687975 0.29692011 0.29700341 0.29692264 0.29687975
 0.29678637 0.29674346 0.29668288 0.29657941 0.29656931 0.29648603
 0.29649613 0.2964911  0.29642042 0.29646837 0.29646584 0.29651632
 0.29641032 0.29645828 0.29643808 0.29640782 0.29628919 0.29636996
 0.29640529 0.2965037  0.29642548 0.29641792 0.29635734 0.29622358
 0.29619329 0.29633461 0.29647847 0.29664502 0.29657184 0.29667281
 0.29665765 0.29669803 0.29668794 0.29672073 0.2968116  0.2969302
 0.29684946 0.29676365 0.29670057 0.29660466 0.2965971  0.29653148
 0.29646837 0.29645577 0.29644061 0.29653905 0.29651885 0.29645324
 0.29638006 0.29632958 0.2963851  0.2963649  0.29647594 0.29645577
 0.29644567 0.29653148 0.29644818 0.296481   0.29661979 0.29629425
 0.29630435 0.29616806 0.29620592 0.29617059 0.29609235 0.29606963
 0.29611001 0.29607722 0.29604693 0.29607972 0.29603177 0.29599645
 0.29599898 0.29597122 0.29609235 0.29603683 0.29608982 0.29618825
 0.29615543 0.29608982 0.29610748 0.29615293 0.29621095 0.29639772
 0.29662232 0.29663495 0.29664755 0.29663495 0.29669047 0.29688225
 0.29674599 0.29679897 0.29696806 0.29699582 0.29695546 0.29682926
 0.29682926 0.29670307 0.29670813 0.29668794 0.29667531 0.29680907
 0.29686712 0.29683179 0.29686459 0.2968444  0.29698825 0.29709929
 0.29713714 0.29725324 0.29721791 0.29731382 0.29737437 0.29745261
 0.29745008 0.297493   0.29745514 0.29750056 0.29745261 0.29745514
 0.29743748 0.29739962 0.2975056  0.29737943 0.29745765 0.29741729
 0.29746018 0.29741979 0.29760656 0.29735671 0.297493   0.29754598
 0.29755861 0.29758637 0.297493   0.29738194 0.2974097  0.29753336
 0.29777312 0.29773779 0.29768984 0.29753336 0.2975788  0.29760656
 0.29763179 0.29768227 0.29775039 0.29775292 0.2977277  0.29752579
 0.2974728  0.29740719 0.29721285 0.29706902 0.29685702 0.29701348
 0.29688225 0.29688984 0.2969176  0.29695293 0.29691254 0.29676365
 0.29663999 0.29658194 0.29657184 0.29645071 0.29651632 0.29651379
 0.29637753 0.29636237 0.29622358]

I've also tried to not clean the data before hand tried using ppg_clean as well.

Copy link

welcome bot commented Jan 27, 2024

Hi 👋 Thanks for reaching out and opening your first issue here! We'll try to come back to you as soon as possible. ❤️ kenobi

@youngjaeheo2002 youngjaeheo2002 changed the title G Getting Errors when trying to processa and analyze ppg_signal using ppg_processa and ppg_analyze Jan 27, 2024
@youngjaeheo2002
Copy link
Author

I also tried to run this

data = nk.ppg_simulate(duration = 10,sampling_rate = 64)


        df,info = nk.ppg_process(data,sampling_rate =64)
        results = nk.ppg_analyze(data = df, sampling_rate = 64)

and I got this error in my notebook

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[20], [line 50](vscode-notebook-cell:?execution_count=20&line=50)
     [46](vscode-notebook-cell:?execution_count=20&line=46) data = nk.ppg_simulate(duration = 10,sampling_rate = 64)
     [49](vscode-notebook-cell:?execution_count=20&line=49) df,info = nk.ppg_process(data,sampling_rate =64)
---> [50](vscode-notebook-cell:?execution_count=20&line=50) results = nk.ppg_analyze(data = df, sampling_rate = 64)
     [51](vscode-notebook-cell:?execution_count=20&line=51) '''
     [52](vscode-notebook-cell:?execution_count=20&line=52) df, info = nk.ppg_process(data,sampling_rate = 100)
     [53](vscode-notebook-cell:?execution_count=20&line=53) nk.ppg_analyze(data = df,sampling_rate = 100)
     [54](vscode-notebook-cell:?execution_count=20&line=54) '''
     [55](vscode-notebook-cell:?execution_count=20&line=55) break   

File [~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113), in ppg_analyze(data, sampling_rate, method)
    [111](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:111)     duration = len(data) / sampling_rate
    [112](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:112) if duration >= 10:
--> [113](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:113)     features = ppg_intervalrelated(data, sampling_rate=sampling_rate)
    [114](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:114) else:
    [115](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_analyze.py:115)     features = ppg_eventrelated(data)

File [~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64), in ppg_intervalrelated(data, sampling_rate)
     [62](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:62) if len(rate_cols) == 1:
     [63](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:63)     intervals.update(_ppg_intervalrelated_formatinput(data))
---> [64](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:64)     intervals.update(*_ppg_intervalrelated_hrv(data, sampling_rate))
     [65](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:65) else:
     [66](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/ppg/ppg_intervalrelated.py:66)     raise ValueError(
...
    [333](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/complexity/fractal_dfa.py:333)         "NeuroKit error: the window cannot contain more data points than the time series. Decrease 'scale'."
    [334](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/complexity/fractal_dfa.py:334)     )
    [336](https://vscode-remote+ssh-002dremote-002bcedar-002ealliancecan-002eca.vscode-resource.vscode-cdn.net/home/heoyoun1/projects/def-alim/heoyoun1/ApneaProject/muse_feature_extraction/~/ENV/lib/python3.10/site-packages/neurokit2/complexity/fractal_dfa.py:336) return scale

ValueError: NeuroKit error: the window cannot contain more data points than the time series. Decrease 'scale'.

@saurabh-kataria
Copy link

I have similar issues. Cannot analyze my ppg signals unfortunately

@DerAndereJohannes
Copy link
Collaborator

Hi! How long is your signal? ppg_analyze defaults to event-related processing if the signal is below a certain threshold which requires you to create epochs beforehand. It looks like you are trying to apply interval-related processing on it so you may have to explicitly state this.

Can you try something like this? There may be warnings, but it should complete and print out results:

import neurokit2 as nk

SAMPLING_RATE = 64

data = nk.ppg_simulate(duration=20, sampling_rate=SAMPLING_RATE)

df, info = nk.ppg_process(data, sampling_rate=SAMPLING_RATE)

results = nk.ppg_analyze(df, sampling_rate=SAMPLING_RATE, method="interval-related")

print(results)

@saurabh-kataria
Copy link

saurabh-kataria commented Oct 24, 2024

My signal is 8 second long which gives me epoch error.

---> 67 epochs = _eventrelated_sanitizeinput(epochs, what="ppg", silent=silent)
69 # Extract features and build dataframe
70 data = {} # Initialize an empty dict

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/epochs/eventrelated_utils.py:19, in _eventrelated_sanitizeinput(epochs, what, silent)
17 epochs = _df_to_epochs(epochs) # Convert df back to dict
18 else:
---> 19 raise ValueError(
20 "It seems that you are trying to pass a single epoch to an eventrelated function."
21 + 'If this is what you want, please wrap it in a dict: {"0": epoch} '
22 )
24 if not isinstance(epochs, dict):
25 raise ValueError(

So I now double my signal and get SVD error
processed, info = nk.ppg_process(np.repeat(x,2), sampling_rate=40)
features_dict = nk.ppg_analyze(processed, sampling_rate=40, method='interval-related')

/scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/hrv/hrv_nonlinear.py:529: NeuroKitWarning: DFA_alpha2 related indices will not be calculated. The maximum duration of the windows provided for the long-term correlation is smaller than the minimum duration of windows. Refer to the scale argu
ment in nk.fractal_dfa() for more information.
warn(
/scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/complexity/entropy_multiscale.py:349: RuntimeWarning: invalid value encountered in scalar divide
mse = np.trapz(mse) / len(mse)
/scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/complexity/optim_complexity_k.py:134: RuntimeWarning: divide by zero encountered in divide
normalization = (n - 1) / (np.floor((n - k_subrange) / k).astype(int) * k)
/scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/complexity/optim_complexity_k.py:135: RuntimeWarning: invalid value encountered in multiply
sets = (np.nansum(np.abs(np.diff(sig_values)), axis=1) * normalization) / k

Intel MKL ERROR: Parameter 6 was incorrect on entry to DGELSD.

LinAlgError Traceback (most recent call last)
Cell In[21], line 1
----> 1 features_dict = nk.ppg_analyze(processed, sampling_rate=40, method='interval-related')

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/ppg/ppg_analyze.py:93, in ppg_analyze(data, sampling_rate, method)
91 # Interval-related analysis
92 elif method in ["interval-related", "interval", "resting-state"]:
---> 93 features = ppg_intervalrelated(data, sampling_rate=sampling_rate)
95 # Auto
96 elif method in ["auto"]:

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/ppg/ppg_intervalrelated.py:65, in ppg_intervalrelated(data, sampling_rate)
63 if len(rate_cols) == 1:
64 intervals.update(_ppg_intervalrelated_formatinput(data))
---> 65 intervals.update(*_ppg_intervalrelated_hrv(data, sampling_rate))
66 else:
67 raise ValueError(
68 "NeuroKit error: ppg_intervalrelated(): Wrong input,"
69 "we couldn't extract heart rate. Please make sure"
70 "your DataFrame contains a PPG_Rate column."
71 )

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/ppg/ppg_intervalrelated.py:135, in _ppg_intervalrelated_hrv(data, sampling_rate)
132 peaks = np.where(data["PPG_Peaks"].values)[0]
133 peaks = {"PPG_Peaks": peaks}
--> 135 results = hrv(peaks, sampling_rate=sampling_rate)
137 return results.astype("float").to_dict("records")

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/hrv/hrv.py:107, in hrv(peaks, sampling_rate, show, **kwargs)
105 out.append(hrv_time(peaks, sampling_rate=sampling_rate))
106 out.append(hrv_frequency(peaks, sampling_rate=sampling_rate))
--> 107 out.append(hrv_nonlinear(peaks, sampling_rate=sampling_rate))
109 # Compute RSA if rsp data is available
110 if isinstance(peaks, pd.DataFrame):
File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/hrv/hrv_nonlinear.py:300, in hrv_nonlinear(peaks, sampling_rate, show, **kwargs)
297 out["RCMSEn"], _ = entropy_multiscale(rri, dimension=2, tolerance=tolerance, method="RCMSEn")
299 out["CD"], _ = fractal_correlation(rri, delay=1, dimension=2, **kwargs)
--> 300 out["HFD"], _ = fractal_higuchi(rri, k_max=10, **kwargs)
301 out["KFD"], _ = fractal_katz(rri)
302 out["LZC"], _ = complexity_lempelziv(rri, **kwargs)

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/complexity/fractal_higuchi.py:93, in fractal_higuchi(signal, k_max, show, **kwargs)
90 k_values = np.arange(1, k_max + 1)
91 else:
92 # Compute Higuchi
---> 93 slope, intercept, info = _complexity_k_slope(k_max, signal)
94 k_values = info["k_values"]
95 average_values = info["average_values"]

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/neurokit2/complexity/optim_complexity_k.py:154, in _complexity_k_slope(kmax, signal, k_number)
151 average_values = vectorized_Lk(k_values, signal)
153 # Slope of best-fit line through points (slope equal to FD)
--> 154 slope, intercept = -np.polyfit(np.log(k_values), np.log(average_values), 1)
155 return slope, intercept, {"k_values": k_values, "average_values": average_values}

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/numpy/lib/polynomial.py:669, in polyfit(x, y, deg, rcond, full, w, cov)
667 scale = NX.sqrt((lhs*lhs).sum(axis=0))
668 lhs /= scale
--> 669 c, resids, rank, s = lstsq(lhs, rhs, rcond)
670 c = (c.T/scale).T # broadcast scale coefficients
672 # warn on rank reduction, which indicates an ill conditioned matrix

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/numpy/linalg/linalg.py:2326, in lstsq(a, b, rcond)
2323 if n_rhs == 0:
2324 # lapack can't handle n_rhs = 0 - so allocate the array one larger in that axis
2325 b = zeros(b.shape[:-2] + (m, n_rhs + 1), dtype=b.dtype)
-> 2326 x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
2327 if m == 0:
2328 x[...] = 0

File /scratch/skatar6/anaconda3/envs/tmp4/lib/python3.9/site-packages/numpy/linalg/linalg.py:124, in _raise_linalgerror_lstsq(err, flag)
123 def _raise_linalgerror_lstsq(err, flag):
--> 124 raise LinAlgError("SVD did not converge in Linear Least Squares")

LinAlgError: SVD did not converge in Linear Least Squares

Copy link

stale bot commented Jan 31, 2025

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix This will not be worked on label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants