-
When trying to generate spectrograms, I always end up with a 15h plot instead of an 8h one (see the plot attached). input_fname=easygui.fileopenbox(msg="EDF file")
raw=mne.io.read_raw_edf(input_fname,preload=True,verbose=False)
print(raw.info['sfreq'])
raw.resample(100)
sf=raw.info['sfreq']
print(sf)
raw.filter(0.1,45)
data=raw.get_data(units="uV")
#Transform tuple to np.array to get a 1D array
from typing import Iterable
C3=raw['C3']
def flatten(items):
"""Yield items from any nested iterable."""
for x in items:
if isinstance(x,Iterable) and not isinstance(x,(str,bytes)):
for sub_x in flatten(x):
yield sub_x
else:
yield x
C3=list(flatten(C3))
C3=np.array(C3)
#Spectrogram plot
yasa.plot_spectrogram(C3,sf);
plt.show() I also tried to select my electrode by using If anyone can help elucidate this bit of an issue, that'd be much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'm not sure what's happening with the extra steps to flatten the data, and skeptical something there might be causing this. Have you looked at the length of the final array you have before plotting it to make sure it's as long as you think it should be? Can you try using just this to extract the one-dimensional array of C3 data and plot it? C3 = raw.get_data(picks=["C3"], units="uV")[0]
yasa.plot_spectrogram(C3, sf)
plt.show() If that doesn't work, could you help with some more troubleshooting by showing the length of the file? Maybe the output from |
Beta Was this translation helpful? Give feedback.
I'm not sure what's happening with the extra steps to flatten the data, and skeptical something there might be causing this. Have you looked at the length of the final array you have before plotting it to make sure it's as long as you think it should be? Can you try using just this to extract the one-dimensional array of C3 data and plot it?
If that doesn't work, could you help with some more troubleshooting by showing the length of the file? Maybe the output from
print(raw.times[0], raw.times[-1])
?