Exemplo n.º 1
0
def update():
    global curve, waves, wavesx, wavesy, y, x, xT, ri, r, EEG_n, counter, instant, headset, time, fs, win_size

    EEG_new = br.readEEG2(fs, time, channels, headset)
    EEG_n_new = br.normalizeEEG(EEG_new)
    y2 = EEG_n_new.transpose()

    #--------------------------------------------------------
    #Rhythms Bar Graphic
    if EEG_n.shape[0] < w - 1:
        EEG_n = np.r_[EEG_n, EEG_n_new]
    else:
        EEG_n = np.r_[EEG_n, EEG_n_new]
        EEG_n = EEG_n[-w:, :]

    ri = br.rhythmsAllWaves(fs, dx, EEG_n)
    #ri = br.rhythmsBasicWaves(fs,dx,EEG_n)
    r = br.normalizeRhythms(ri)

    for i in range(len(r)):
        graph["%s" % (str(i))].setOpts(x=[i], height=[r[i]])

    #--------------------------------------------------------
    #Waves Diagram
    xr_new, yr_new = br.wavesDiagram(r, Deg)

    if instant < 3:
        waves.append(
            plt2.plot(xr_new,
                      yr_new,
                      pen=(255, 255, 102),
                      fillLevel=0,
                      fillBrush=(102, 255, 102, 40)))
        #plt2.plot(x_p, y_p, pen=None, symbol='o', symbolPen=(51,153,255), symbolBrush=(153,255,204))
        wavesx.append(xr_new)
        wavesy.append(yr_new)
        instant += 1
    else:
        wavesx.append(xr_new)
        wavesy.append(yr_new)
        for k in range(1, len(waves)):
            waves[k].setData(wavesx[k], wavesy[k])
        wavesx = wavesx[-len(waves):]
        wavesy = wavesy[-len(waves):]

    #--------------------------------------------------------
    #EEG Plot

    if np.ceil(counter) < win_size:
        y = np.c_[y, y2]
        x = xT[:y.shape[1]]
    else:
        y = np.c_[y, y2]
        y = y[:, int(time * fs):]

    for i in range(channels):
        curve[i].setData(x, y[i])
    counter = counter + time
Exemplo n.º 2
0
def update():
    global curve, waves, wavesx, wavesy, y, x, xT, ri, r, EEG_n, counter,instant, headset, time,fs, win_size

    EEG_new = br.readEEG2(fs,time,channels,headset)
    EEG_n_new = br.normalizeEEG(EEG_new )
    y2 = EEG_n_new.transpose()

    
    #--------------------------------------------------------
    #Rhythms Bar Graphic
    if EEG_n.shape[0] < w-1:
        EEG_n = np.r_[EEG_n,EEG_n_new]
    else:
        EEG_n = np.r_[EEG_n,EEG_n_new]
        EEG_n = EEG_n[-w:,:]

    ri = br.rhythmsAllWaves(fs,dx,EEG_n)
    #ri = br.rhythmsBasicWaves(fs,dx,EEG_n)
    r =  br.normalizeRhythms(ri)

    for i in range(len(r)):
        graph["%s" %(str(i))].setOpts(x=[i], height=[r[i]])

    #--------------------------------------------------------
    #Waves Diagram
    xr_new,yr_new = br.wavesDiagram(r,Deg)

    if instant < 3:
        waves.append(plt2.plot(xr_new, yr_new, pen=(255,255,102), fillLevel=0, fillBrush=(102,255,102,40)))
        #plt2.plot(x_p, y_p, pen=None, symbol='o', symbolPen=(51,153,255), symbolBrush=(153,255,204))
        wavesx.append(xr_new)
        wavesy.append(yr_new)
        instant += 1
    else:
        wavesx.append(xr_new)
        wavesy.append(yr_new)
        for k in range(1,len(waves)):
            waves[k].setData(wavesx[k],wavesy[k])
        wavesx = wavesx[-len(waves):]
        wavesy = wavesy[-len(waves):]
              
    #--------------------------------------------------------
    #EEG Plot
    
    if np.ceil(counter) < win_size:
        y = np.c_[y,y2]
        x = xT[:y.shape[1]]
    else:
        y = np.c_[y,y2]
        y = y[:,int(time*fs):]

    for i in range(channels):
        curve[i].setData(x,y[i])
    counter = counter + time
Exemplo n.º 3
0
channels = 14
win_size = 5
color = [(255, 102, 102), (255, 178, 102), (255, 255, 102), (178, 255, 102),
         (102, 255, 102), (102, 255, 178), (102, 255, 255), (102, 178, 255)]
#Deg = [90., 45., 330., 300., 240., 210., 150., 120.]
Deg = [90., 45., 0., 315., 270., 225., 180., 135.]
f_min = 0.8
w = (1 / f_min) * fs

EEG, headset = br.readEEG(fs, time, channels)
EEG_n = br.normalizeEEG(EEG)

y = EEG_n.transpose()
x = np.linspace(0, time, fs * time)

ri = br.rhythmsAllWaves(fs, dx, EEG)
#ri = br.rhythmsBasicWaves(fs,dx,EEG)
r = br.normalizeRhythms(ri)

xr, yr = br.wavesDiagram(r, Deg)

#Main Window
win = pg.GraphicsWindow(title="EEG Data System")
win.resize(1000, 600)

win.setWindowTitle('EEG Data System')

# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)

#--------------------------------------------------------
Exemplo n.º 4
0
time = 0.4
channels = 14
win_size = 5
color = [(255,102,102),(255,178,102),(255, 255, 102),(178, 255, 102),(102, 255, 102),(102, 255, 178),(102,255,255),(102,178,255)]
#Deg = [90., 45., 330., 300., 240., 210., 150., 120.]
Deg = [90., 45., 0. ,315., 270. , 225., 180., 135.]
f_min = 0.8
w = (1/f_min)*fs

EEG,headset = br.readEEG(fs,time,channels)
EEG_n = br.normalizeEEG(EEG)

y = EEG_n.transpose()
x = np.linspace(0,time,fs*time)

ri = br.rhythmsAllWaves(fs,dx,EEG)
#ri = br.rhythmsBasicWaves(fs,dx,EEG)
r =  br.normalizeRhythms(ri)

xr,yr = br.wavesDiagram(r,Deg)

#Main Window
win = pg.GraphicsWindow(title="EEG Data System")
win.resize(1000,600)

win.setWindowTitle('EEG Data System')

# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)

#--------------------------------------------------------