Skip to content

Bug with trimming padded array in fft_resample #5397

@Pezz89

Description

@Pezz89

Calling:
raw, events = raw.resample(128, events=events, npad=10)

Results in the following error:

Traceback (most recent call last):
  File "./pyaepsin.py", line 359, in <module>
    main(**args)
  File "./pyaepsin.py", line 178, in main
    raw, events = raw.resample(128, events=events, npad=10)
  File "<string>", line 2, in resample
  File "/Users/sam/Work/SOTON/Initial_work/TRF_Verification/mne-python/mne/utils.py", line 724, in verbose
    return function(*args, **kwargs)
  File "/Users/sam/Work/SOTON/Initial_work/TRF_Verification/mne-python/mne/io/base.py", line 1522, in resample
    window=window, n_jobs=n_jobs, pad=pad))
  File "<string>", line 2, in resample
  File "/Users/sam/Work/SOTON/Initial_work/TRF_Verification/mne-python/mne/utils.py", line 724, in verbose
    return function(*args, **kwargs)
  File "/Users/sam/Work/SOTON/Initial_work/TRF_Verification/mne-python/mne/filter.py", line 1600, in resample
    cuda_dict, pad)
ValueError: could not broadcast input array from shape (0) into shape (100224)

Due to incorrect handling of array trimming when trimming the end of the array is 0 samples long in cuda.py (line 378-383):

    # now let's trim it back to the correct size (if there was padding)
    if (to_removes > 0).any():
        keep = np.ones((new_len), dtype='bool')
        keep[:to_removes[0]] = False
        keep[-to_removes[1]:] = False
        y = np.compress(keep, y)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions