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

Invalid cutoff frequencies #1

Open
dpankros opened this issue Apr 5, 2024 · 0 comments
Open

Invalid cutoff frequencies #1

dpankros opened this issue Apr 5, 2024 · 0 comments

Comments

@dpankros
Copy link

dpankros commented Apr 5, 2024

We are doing a project and trying to reproduce your results from the original paper associated with this code. When we get to extract_rri in data/nch/dataloader.py, the line:

    filtered, _, _ = st.filter_signal(signal=signal, ftype="FIR", band="bandpass", order=int(0.3 * FREQ),
                                      frequency=[3, 45], sampling_rate=FREQ, )

fails because the upper bound of the resampling filter window (45) is greater than or equal to the nyquist rate (32Hz in this case; FREQ is defined as 64). How did you get this to work or what change do you recommend that would provide consistent results? Thanks.

Relevant stack trace:

  File ".../data/nch/dataloader.py", line 55, in extract_rri
    filtered, _, _ = st.filter_signal(signal=signal, ftype="FIR", band="bandpass", order=int(0.3 * FREQ),
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/biosppy/signals/tools.py", line 425, in filter_signal
    b, a = get_filter(
           ^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/biosppy/signals/tools.py", line 326, in get_filter
    b = ss.firwin(numtaps=order, cutoff=frequency, pass_zero=False, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/scipy/_lib/deprecation.py", line 213, in inner_f
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.11/site-packages/scipy/signal/_fir_filter_design.py", line 409, in firwin
    raise ValueError("Invalid cutoff frequency: frequencies must be "
ValueError: Invalid cutoff frequency: frequencies must be greater than 0 and less than fs/2.
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