Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Created an issue, rather than discussion: #219 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When trying to use YASA to perform single-channel sleep spindles detection (with my own data samples), I get a very similar issue as #104 where the spindles detection returns nonetype and marks the relative power and moving RMS thresholds to 0. I have no nans or zeros in the data array that I'm inputting, so I don't understand why the normalizing in STFT_power returns nans. This error only occurs with some data samples I have and works fine with others (there doesn't seem to be any stark differences in the samples of data I'm using so I don't understand why the detection fails for some samples only). I'm using YASA 0.6.5, numpy 1.26.4 and am running the code on a Mac, Python version 3.12.7 (but get the same issue with 3.9). I tried downgrading my YASA version to 0.6.2 as issue #104 was solved in that version, but ran into the same issue.
Here is the snippet of code I have:
import yasa
import pandas as pd
test_spindles_list = []
ch = 0
eeg_ch = raw_eeg[ch, :]
hypno_ch = hypno_per_channel[ch]
sp = yasa.spindles_detect(
eeg_ch,
sf=500,
ch_names=[channel_names[ch]],
hypno=hypno_ch,
verbose=True, remove_outliers=True)
df = sp.summary()
df["Channel"] = channel_names[ch]
test_spindles_list.append(df)
Here is the output:
29-Jul-25 21:44:24 | INFO | Number of unique values in hypno = 6
29-Jul-25 21:44:24 | INFO | Number of samples in data = 15107383
29-Jul-25 21:44:24 | INFO | Sampling frequency = 500.00 Hz
29-Jul-25 21:44:24 | INFO | Data duration = 30214.77 seconds
29-Jul-25 21:44:24 | INFO | Trimmed standard deviation of Fp1 = 91.1886 uV
29-Jul-25 21:44:24 | INFO | Peak-to-peak amplitude of Fp1 = 6414.5999 uV
/opt/homebrew/lib/python3.11/site-packages/yasa/spectral.py:714: RuntimeWarning: invalid value encountered in divide
np.divide(Sxx, sum_pow, out=Sxx)
29-Jul-25 21:44:30 | INFO | Moving RMS threshold = 2.321
29-Jul-25 21:44:30 | INFO | N supra-theshold relative power = 0
29-Jul-25 21:44:30 | INFO | N supra-theshold moving corr = 0
29-Jul-25 21:44:30 | INFO | N supra-theshold moving RMS = 1373830
29-Jul-25 21:44:30 | WARNING | No spindle were found in channel Fp1.
29-Jul-25 21:44:30 | WARNING | No spindles were found in data. Returning None.
Spindle detection failed on channel Fp1: 'NoneType' object has no attribute 'summary'
Beta Was this translation helpful? Give feedback.
All reactions