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

ValueError when Running rsp_rvt #996

Open
rcmdnk opened this issue Jun 7, 2024 · 1 comment
Open

ValueError when Running rsp_rvt #996

rcmdnk opened this issue Jun 7, 2024 · 1 comment

Comments

@rcmdnk
Copy link

rcmdnk commented Jun 7, 2024

When running rsp_process on my sample, I encountered the following error:

ValueError: Number of samples, -1, must be non-negative.

This error occurs during the RVT calculation, and I discovered that fr_phase has the same values around the corresponding indexes in _rsp_rvt_harrison
. By applying the following patch to _rsp_rvt_find_min, the error is resolved:

--- a/neurokit2/rsp/rsp_rvt.py
+++ b/neurokit2/rsp/rsp_rvt.py
@@ -325,7 +325,7 @@ def _rsp_rvt_find_min(increase_inds, fr_phase, smaller_index, silent):
     n_min = increase_inds[bigger_n_max]
     fr_min = fr_phase[n_min].squeeze()
     # Sometime fr_min is the same as n_max and it caused problems
-    if fr_phase[smaller_index].squeeze() < fr_min:
+    if fr_phase[smaller_index].squeeze() <= fr_min:
         if not silent:
             warn(
                 "rsp_rvt(): The next bigger increasing index has a bigger value than the chosen decreasing index, "

But the code contains the following comment:

# Sometime fr_min is the same as n_max and it caused problems
  • What specific problems occur when fr_min is the same as n_max?
  • Should I avoid this calculation if this condition arises, or can the above patch be applied?
Copy link

welcome bot commented Jun 7, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant