Skip to content

ZeroDivisionError at 01_spindles_detection.ipynb #41

Description

@Yifeng-J

I download code and run 01_spindles_detection.ipynb , then I got an error:

ZeroDivisionError                         Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_28896/14777483.py in <module>
      1 # Apply the detection using yasa.spindles_detect
----> 2 sp = yasa.spindles_detect(data, sf)
      3 
      4 # Display the results using .summary()
      5 sp.summary()

S:\Anaconda\envs\yasa_env\lib\site-packages\yasa\detection.py in spindles_detect(data, sf, ch_names, hypno, include, freq_sp, freq_broad, duration, min_distance, thresh, multi_only, remove_outliers, verbose)
    675             _, mcorr = moving_transform(x=data_sigma[i, :], y=data_broad[i, :],
    676                                         sf=sf, window=.3, step=.1,
--> 677                                         method='corr', interp=True)
    678         if do_rms:
    679             _, mrms = moving_transform(x=data_sigma[i, :], sf=sf,

S:\Anaconda\envs\yasa_env\lib\site-packages\yasa\others.py in moving_transform(x, y, sf, window, step, method, interp)
    192     if method in ['covar', 'corr']:
    193         for i in range(idx.size):
--> 194             out[i] = func(x[beg[i]:end[i]], y[beg[i]:end[i]])
    195     else:
    196         for i in range(idx.size):

S:\Anaconda\envs\yasa_env\lib\site-packages\yasa\others.py in func(x, y)
    183     elif method == 'corr':
    184         def func(x, y):
--> 185             return _corr(x, y)
    186 
    187     else:

ZeroDivisionError: division by zero

Then I change sp = yasa.spindles_detect(data, sf) to sp = yasa.spindles_detect(data, sf, thresh={'rel_pow': 0.2, 'corr': None, 'rms': 1.5}) and the code can sucessfully run.

I want to know why would I encounter this problem, hope your help.

Metadata

Metadata

Assignees

Labels

bug 💥Something isn't workinginvalid 🚩This doesn't seem right

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions