spindles dection issue #102
Replies: 3 comments 10 replies
-
Hi @chensnbetter . I just tried replicating this issue but everything seemed to work fine for me. The first thing I did was trim the code down to the essentials needed for the spindle detection and ran this: import mne
import pandas as pd
import yasa
raw_fname = "./yasa_example_night_young.edf"
hypno_fname = "./yasa_example_night_young_hypno.csv"
raw = mne.io.read_raw_edf(raw_fname, preload=True)
raw.drop_channels(['ROC-A1', 'LOC-A2', 'EMG1-EMG2', 'EKG-R-EKG-L'])
raw.resample(100)
raw.filter(0.3, 45)
hypno = pd.read_csv(hypno_fname, squeeze=True)
hypno_up = yasa.hypno_upsample_to_data(hypno, sf_hypno=1/30, data=raw)
sp = yasa.spindles_detect(raw, hypno=hypno_up, include=(2, 3)) That worked well for me, spindles were detected. Then I thought maybe some of the other functions might have accidentally been modifying Could you try re-running this with the trimmed down code? Make sure you're up to date on YASA (I'm using YASA |
Beta Was this translation helpful? Give feedback.
-
Strangely, why can I detect slow waves successfully? |
Beta Was this translation helpful? Give feedback.
-
Opened an issue here: #107 Let's move the conversation there |
Beta Was this translation helpful? Give feedback.
-
When trying to detect spindles, it always shows that no spindles were found in data.
import mne
raw = mne.io.read_raw_edf('C://Users//ASUS//Desktop//yasa_example_night_young.edf', preload=True)
raw
print(raw.ch_names)
raw.drop_channels(['ROC-A1', 'LOC-A2', 'EMG1-EMG2', 'EKG-R-EKG-L'])
chan = raw.ch_names
print(chan)
print(raw.info['sfreq'])
raw.resample(100)
sf = raw.info['sfreq']
sf
raw.filter(0.3, 45)
data = raw.get_data(units="uV")
print(data.shape)
import pandas as pd
hypno = pd.read_csv("C://Users//ASUS//Desktop//yasa_example_night_young_hypno.csv", squeeze=True)
hypno
import yasa
yasa.plot_hypnogram(hypno);
yasa.sleep_statistics(hypno, sf_hyp=1/30)
counts, probs = yasa.transition_matrix(hypno)
probs.round(3)
import numpy as np
np.diag(probs.loc[2:, 2:]).mean().round(3)
hypno_up = yasa.hypno_upsample_to_data(hypno, sf_hypno=1/30, data=raw)
print(len(hypno_up))
yasa.plot_spectrogram(data[chan.index("C4-A1")], sf, hypno_up);
yasa.bandpower(raw)
yasa.bandpower(raw, relative=False, bands=[(1, 9, "Slow"), (9, 30, "Fast")])
bandpower = yasa.bandpower(raw, hypno=hypno_up, include=(2, 3, 4))
bandpower.to_csv("bandpower.csv")
sp = yasa.spindles_detect(raw, hypno=hypno_up, include=(2, 3))
It didn't go well while doing it with data other than the sample data of yasa. So I tried it with the sample data of yasa, and the same error appears.
Beta Was this translation helpful? Give feedback.
All reactions