Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 24 2017 19:45

    EtienneCmb on screenshot

    Fix canvas names (compare)

  • Aug 24 2017 18:51

    EtienneCmb on screenshot

    Fix factor visibility Add screenshot GUI tooltips (compare)

  • Aug 24 2017 18:33

    EtienneCmb on screenshot

    Remove screenshot menu Screenshot configuration for Sl… (compare)

  • Aug 24 2017 17:57

    EtienneCmb on develop

    Use master figure Bump to version v0.3.1 Merge branch 'release/v0.3.1' i… (compare)

  • Aug 24 2017 17:57

    EtienneCmb on screenshot

    Merge branch 'release/v0.3.1' i… Remove brain GUI components rel… Add UiScreenshot class and 12 more (compare)

Raphael Vallat
@raphaelvallat
Regarding your second point, no, it is no possible to sequentially add several channels. Visbrain was designed for visualization, not preprocessing. I recommend that you filter your channels to the desired output in MNE before calling Visbrain. (see https://www.nmr.mgh.harvard.edu/mne/stable/generated/mne.io.Raw.html#mne.io.Raw.filter)
apavlo89
@apavlo89

Hello Vallat. This question is on viewing signal on yasa. I've loaded a 2-minute file and i get this

I use the code fig, ax = plt.subplots(1, 1, figsize=(16, 4))
plt.plot(times, data, lw=1.5, color='k')
plt.xlabel('Time (seconds)')
plt.ylabel('Amplitude (uV)')
plt.xlim([times.min(), times.max()])
plt.title('EEG data')
sns.despine()

the error that i get is x and y must have same first dimension, but have shapes (9696800,) and (68, 142600)

apavlo89
@apavlo89
I am sure it has something to do with the values 1, 1 which have to be altered from the example but I do not understand what they correspond to
apavlo89
@apavlo89
also my recording has more than 1 channel. Would this plot command plot all channels or does it work for single-channel only?
Raphael Vallat
@raphaelvallat

Hi @apavlo89! Can you try the following:

plt.figure(figsize=(16, 4))
plt.plot(data[0, :], lw=1.5, color='k')

and see if that works?

I think there is something wrong with the way you load the data here. Your times vector has a length of 9696800, but your data is a 2D matrix with 68 channels (?) and 142600 points (and 142600 * 68 = 9696800). Do you have 68 channels? What is the sampling frequency of your data? Can you show me how you create the times vector, and how you load data? Thanks

apavlo89
@apavlo89

Load data as a CNT Raw file

raw = mne.io.read_raw_cnt('C:/location/HighREEG_rr.cnt', montage=None, eog='auto', misc=(), ecg=(), emg=(), data_format='auto', date_format='mm/dd/yy', preload=True, stim_channel=None, verbose=None)

Load data

data = raw._data * 1e6
sf = raw.info['sfreq']

chan = raw.ch_names
times = np.arange(data.size) / sf

it is 68 channels
sampling frequency is 1000

but i downsample it to 100 Hz

data = resample(data, up=0.5, down=1., verbose=False)
sf = 100
times = np.arange(data.size) / sf

apavlo89
@apavlo89
also if I wanted to only plot specific channels (instead of the 68, choose only 'C3', 'C4', 'CPz' ,'CP3', 'CP3', 'CP4', 'CPz') how would I go about it?
I tried the plt.figure(figsize=(16, 4))
plt.plot(data[0, :], lw=1.5, color='k')
Figure_1.png
comes out with this
apavlo89
@apavlo89
is there a way to reduce time shown in window
like when you use raw.plot(block=True, lowpass = 40) function
you can decrease timeline so that you can view smaller epochs of the data
apavlo89
@apavlo89
ok when i resample to 100hz its now 68, 71300
apavlo89
@apavlo89
the error becomes: x and y must have same first dimension, but have shapes (4848400,) and (68, 71300)
Raphael Vallat
@raphaelvallat
Can you please try with: times = np.arange(data.shape[1]) / sf
Btw, it seems that you are not resampling to 100 Hz but 500 Hz, in: data = resample(data, up=0.5, down=1., verbose=False) (= divide 1000 by a factor of 2)
apavlo89
@apavlo89
could you explain what the 1 does in times = np.arange(data.shape[1]) / sf
anws I've put times = np.arange(data.shape[1]) / sf
and tried to re-run this code
fig, ax = plt.subplots(1, 1, figsize=(16, 4))
plt.plot(times, data, lw=1.5, color='k')
plt.xlabel('Time (seconds)')
plt.ylabel('Amplitude (uV)')
plt.xlim([times.min(), times.max()])
plt.title('EEG data')
sns.despine()
x and y must have same first dimension, but have shapes (71300,) and (68, 71300)
same thing
apavlo89
@apavlo89
i get similar error when trying to load an edf file of a night recording with two channels using a different system
this whole recording edf file gives x and y must have same first dimension, but have shapes (5166080,) and (2, 5166080)
apavlo89
@apavlo89
as for the resampling bit, does up=0.5 do 1000*0.5? If so I've now changed up=0.5 to 0.1
Raphael Vallat
@raphaelvallat
Please use plt.plot(times, data[0, :], lw=1.5, color='k')
This will plot the first channel
You have 68 channels in total
To plot the 2nd channel, use plt.plot(times, data[1, :], lw=1.5, color='k')
The issue is thhat you're loading multi-channel data, not single channel data
Therefore, your NumPy array has two dimensions, or, in mathematical words, is a matrix and not a vector
Your first dimension is the number of channels (68), your second dimension is the number of samples (71300)
And yes, indeed for the resampling
apavlo89
@apavlo89
fantastic you are a rockstar
it is now working
apavlo89
@apavlo89
now for the last bit, I can't get the overlay to work
channel that i want is 29
ValueError: x and y must have same first dimension, but have shapes (142600,) and (14260,)
apavlo89
@apavlo89
I guess the spindle detection now has to be for single yes?
I've done the following modifications
apavlo89
@apavlo89

sp = yasa.spindles_detect(data[29,:], sf, hypno=None,
freq_sp=(11, 16), duration=(0.5, 2), freq_broad=(1, 30),
min_distance=500, downsample=True,
thresh={'rel_pow': 0.2, 'corr': 0.65, 'rms': 1.5},
remove_outliers=True)

Let's get a bool vector

bool_spindles = yasa.get_bool_vector(data[29,:], sf, sp)

Raphael Vallat
@raphaelvallat
You can also apply the spindles detection on several channels at once using yasa.spindles_detect_multi()! And your error is likely caused by a sampling frequency error, the length of x is 10 times (1000Hz) the length of y (100Hz). You should use: yasa.get_bool_vector(data[29,:], sf=1000, sp) to get the bool vector sampled at 1000Hz too. Hope this helps!
apavlo89
@apavlo89
I got it to work!
apavlo89
@apavlo89
Thank you very much!
Everything working as intended!