Ejemplo n.º 1
0
    def __init__(self, **kwargs):
        super(TemperatureGraph, self).__init__(**kwargs)

        plot = LinePlot(color=ORANGE)
        plot.points = state.temp_history.points
        self.add_plot(plot)
        self.temp_plot = plot

        plot = LinePlot(color=GREEN)
        plot.points = state.temp_history.points
        self.add_plot(plot)

        self.target_temp_plot = plot
        Clock.schedule_interval(self.update, UPDATE_INTERVAL)
    def __init__(self, **kwargs):
        super(case, self).__init__(**kwargs)
        box = FloatLayout()
        graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
            x_ticks_major=25, y_ticks_major=1,
            y_grid_label=True, x_grid_label=True, padding=5,
            x_grid=True, y_grid=True, xmin=-0, xmax=20, ymin=0, ymax=10)
        plot = LinePlot()
        # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]

        # data = np.array([[0,0], [1,1],[2,2]])

        data = collections.deque(maxlen = 20)
        time = collections.deque(maxlen = 20)

        d = (0,1,2,3,4,5,6,7,8,9)
        t = (0,1,2,3,4,5,6,7,8,9)

        data.append(d)
        time.append(t)

        toplot = np.vstack((time,data)).T

        print toplot

        plot.points = tuple(map(tuple, toplot))

        graph.add_plot(plot)
        box.add_widget(graph)

        self.add_widget(box)
Ejemplo n.º 3
0
    def addGraph(self,datapoint,xData,yData,dt):
        points = [t for t in zip((xData).astype(int),yData)];
        ymin = int(min(yData))
        ymax = int(max(yData))
        xmin = int(min(xData))
        xmax = int(max(xData))

        if self.setMinMax :
            if self.ids.graph.ymin > ymin:
                self.ids.graph.ymin = ymin
            if self.ids.graph.ymax < ymax:
                self.ids.graph.ymax = ymax
            if self.ids.graph.xmin > xmin:
                self.ids.graph.xmin = xmin
            if self.ids.graph.xmax < xmax:
                self.ids.graph.xmax = xmax  
        else:
            self.ids.graph.ymin = ymin
            self.ids.graph.ymax = ymax
            self.ids.graph.xmin = xmin
            self.ids.graph.xmax = xmax  
            self.setMinMax = True

        plot = LinePlot(color=self.color)
        plot.points = points
        self.ids.graph.add_plot(plot)
        index = random.randint(0,3)
        btn1 = ToggleButton(text=datapoint,background_color=self.color)
        btn1.bind(state=partial(self.on_press,datapoint))
        cp = ColorPicker(color=self.color)
        cp.bind(color=partial(self.on_color,datapoint))
        self.plotdata[datapoint] = {'color':self.color,'button':btn1,'plot':plot,'colorpick':cp,'points':points}
        self.color[index]=self.color[index] - (random.random());
        self.ids.hBox.add_widget(btn1)
        self.ids.hBoxColor.add_widget(cp)
Ejemplo n.º 4
0
    def __init__(self, **kwargs):
        super(PowerGraph, self).__init__(**kwargs)

        plot = LinePlot(color=BLUE)
        plot.points = state.power_history.points
        self.add_plot(plot)

        self.plot = plot
        Clock.schedule_interval(self.update, UPDATE_INTERVAL)
Ejemplo n.º 5
0
Archivo: vis.py Proyecto: mrtysn/lstm
	def update(self):
		global t, x

		ch, prob = onestep()
		for _y in range(lstm_size):
			widget = self.cells[_y].children[-1]
			self.cells[_y].remove_widget(widget)
			box = LstmCell(size_hint=(1.0/time_window, 1))
			box.paint_z(z[t][_y])
			box.paint_i(i[t][_y])
			box.paint_f(f[t][_y])
			box.paint_o(o[t][_y])
			box.paint_h(h[t][_y])
			box.paint_c(c[t][_y])
			#box.set_char(ch)
			self.cells[_y].add_widget(box)
		widget = self.characterArea.children[-1]
		self.characterArea.remove_widget(widget)
		ch = ' ' + ch + "\n" + str(round(prob, 2))
		self.characterArea.add_widget(MyLabel(text=ch, size_hint=(1.0/time_window, 1)))

		if dispEquations:
			myStr = ""
			for _y in range(lstm_size):
				myStr += 'z[t] = tanh([' + str(round(Wz[0][0], 2)) + ', ' + str(round(Wz[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Rz[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + ' + str(round(bz, 2)) +') = tanh('+ str(round(z_, 2)) +') = ' + str(round(z[t], 2)) + "\n"
				myStr += 'i[t] = sig([' + str(round(Wi[0][0], 2)) + ', ' + str(round(Wi[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Ri[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bi, 2)) +') = sig('+ str(round(i_, 2)) +') = ' + str(round(i[t], 2)) + "\n"
				myStr += 'f[t] = sig([' + str(round(Wf[0][0], 2)) + ', ' + str(round(Wf[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Rf[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bf, 2)) +') = sig('+ str(round(f_, 2)) +') = ' + str(round(f[t], 2)) + "\n"
				myStr += 'c[t] = '+ str(round(i[t], 2)) +' * '+ str(round(z[t], 2)) +' + '+ str(round(f[t], 2)) +' * ' + str(round(c[t-1], 2)) + ' = ' + str(round(i[t] * z[t], 2)) + ' + ' + str(round(f[t] * c[t-1], 2)) + ' = ' + str(round(c[t], 2)) + "\n"
				myStr += 'o[t] = sig([' + str(round(Wo[0][0], 2)) + ', ' + str(round(Wo[0][1], 2)) + '] · [' + str(int(x[0])) + ', ' + str(int(x[1])) + '].T + [' + str(round(Ro[0][0], 2)) + '] · [' + str(round(h[t-1], 2)) + '] + '+ str(round(bo, 2)) +') = sig('+ str(round(o_, 2)) +') = ' + str(round(o[t], 2)) + "\n"
				myStr += 'h[t] = tanh(' + str(round(c[t], 2)) + ') * ' + str(round(o[t], 2)) + ' = ' + str(round(tanh(c[t]) , 2)) + ' * ' + str(round(o[t], 2)) + ' = ' + str(round(h[t], 2)) + "\n"
				myStr += 'y[t] = [' + str(round(Wy[0][0], 2)) + ', ' + str(round(Wy[1][0], 2)) + '] · ' + str(round(h[t], 2)) + ' + [' + str(round(by[0], 2)) + ', ' + str(round(by[1], 2)) + '].T = [' + str(round(y[t][0], 2)) + ', ' + str(round(y[t][1], 2)) + '].T' + "\n"
				myStr += 'Input: [' + str(int(x[0])) + ', ' + str(int(x[1])) + '] --> Output: [' + str(int(x_next[0])) + ', ' + str(int(x_next[1])) + ']'
			self.equationArea.text = myStr

		for _y in range(lstm_size):
			self.graphs[_y].xmin = t - time_window
			self.graphs[_y].xmax = t

			for plot in self.graphs[_y].plots:
				self.graphs[_y].remove_plot(plot)

			ix = 1
			for v in (z, i, f, o, c, h):
				colors = [int(u) for u in bin(ix)[2:]]
				while len(colors) < 3:
					colors.insert(0, 0)
				ix += 1
				plot = LinePlot(color = colors, line_width = 2)
				plot.points = [(u, v[u][_y]) for u in range(max(0, t-time_window), t+1)]
				self.graphs[_y].add_plot(plot)

		t += 1
		return
Ejemplo n.º 6
0
	def build(self):
		root = FloatLayout(orientation='horizontal')
		btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'right':1})#,'y':0})
		btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
		root.add_widget(btnRight)
		root.add_widget(btnLeft)
#		scrollV = ScrollView(size_hint=(None,None),size=(800,400))
#		scrollV.do_scroll_y=False
		graph = Graph()
		plot = LinePlot(mode='line_strip', color=[1,0,0,1])
		plot.points = [(x[i],y[i]) for i in xrange(len(x))]
		graph.add_plot(plot)
		graph.x_ticks_major=1
		graph.xmin=xmin
		graph.xmax=xmax
		graph.ymin=ymin
		graph.ymax=ymax
		graph.y_ticks_major=25
		graph.y_grid_label=True
		graph.x_grid_label=True
		graph.xlabel='X axis'
		graph.ylabel='Y axis'
		graph.y_grid = True
		graph.x_grid = True
		def moveRight(obj):
			global xmin
			global xmax
			xmin=xmin+.5
			xmax=xmax+.5
			graph.xmin=xmin
			graph.xmax=xmax
			#graph.remove_plot(plot)
			#graph.add_plot(plot)
			#graph._redraw_size(xmin,ymin,xmax,ymax)
		btnRight.bind(on_release=moveRight)
		def moveLeft(obj):
			global xmin
			global xmax
			xmin=xmin-.5
			xmax=xmax-.5
			graph.xmin=xmin
			graph.xmax=xmax
		btnLeft.bind(on_release=moveLeft)
		root.add_widget(graph)
#		graph.bind(minimum_height=graph.setter('height'))
#		scrollV.add_widget(graph)
		return root
Ejemplo n.º 7
0
    def __init__(self, **kwargs):
        super(case, self).__init__(**kwargs)
        box = FloatLayout()
        graph = Graph(xlabel='X',
                      ylabel='Y',
                      x_ticks_minor=5,
                      x_ticks_major=25,
                      y_ticks_major=1,
                      y_grid_label=True,
                      x_grid_label=True,
                      padding=5,
                      x_grid=True,
                      y_grid=True,
                      xmin=-0,
                      xmax=20,
                      ymin=0,
                      ymax=10)
        plot = LinePlot()
        # plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]

        # data = np.array([[0,0], [1,1],[2,2]])

        data = collections.deque(maxlen=20)
        time = collections.deque(maxlen=20)

        d = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
        t = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

        data.append(d)
        time.append(t)

        toplot = np.vstack((time, data)).T

        print toplot

        plot.points = tuple(map(tuple, toplot))

        graph.add_plot(plot)
        box.add_widget(graph)

        self.add_widget(box)
Ejemplo n.º 8
0
    def __init__(self, **kwargs):
        super(FourthScreen, self).__init__(**kwargs)

	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        self.add_widget(btnRight)
        self.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source='Momona.mp4')
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        self.add_widget(graph)
        self.add_widget(video)
Ejemplo n.º 9
0
    def playVideo(self,FourthScreen):
	#get data for patient
	with open('choosePatient.txt','r') as f:
      	    patientName=f.read()
#      	data = data.split(',')
      	fileName ='videos/' + patientName + ".mp4"
	
	dataMatrix1 = genfromtxt('DemoEEGFile.txt')
	x = dataMatrix1[:,0]
	x = x - 5.539
	y = dataMatrix1[:,1]
	
	xmin = math.trunc(x[0])
	ymin = math.trunc(min(y))#math.trunc(y[0])
	xmax = xmin+1
	xGlobalmax = math.trunc(x[len(x)-1])
	ymax = math.trunc(max(y))#math.trunc(y[len(y)-1])
	# create buttons
        btnRight = Button(text='Scroll', size_hint=(.05,1),pos_hint={'x':0.45})#,'y':0})
        btnLeft = Button(text='Scroll', size_hint=(.05,1),pos_hint={'left':1})			
        FourthScreen.add_widget(btnRight)
        FourthScreen.add_widget(btnLeft)
        
	# create graph
        graph = Graph()
        plot = LinePlot(mode='line_strip',color=[1,0,0,1])
        plot.points = [(x[i],y[i]) for i in xrange(len(x))]
        graph.add_plot(plot)
        graph.x_ticks_major=.5
        graph.xmin=xmin
        graph.xmax=xmax
        graph.ymin=ymin
        graph.ymax=ymax
        graph.y_ticks_major=10
        graph.xlabel='Time (min)'
        graph.ylabel='Brain Wave Amplitude (mV)'
        graph.y_grid = True
        graph.x_grid = True
        graph.size_hint=(0.4,0.9)
        graph.x_grid_label=True
        graph.y_grid_label=True

        # create video player
        video = VideoPlayer(source=fileName)
        video.play=False
        video.size_hint=(0.5,0.9)
        video.pos_hint={'right':1,'top':1}       

        graph.pos_hint={'x':0.05,'top':1}
        def moveRight(obj):
	    global xmin
            global xmax
            global xGlobalmax
            xmin=xmin+.5
            xmax=xmax+.5
            graph.xmin=xmin
            graph.xmax=xmax
            
            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)

        btnRight.bind(on_release=moveRight)
        def moveLeft(obj):
            global xmin
            global xmax
            global xGlobalmax
            xmin=xmin-.5
            xmax=xmax-.5
            graph.xmin=xmin
            graph.xmax=xmax

            percent = 1-(xGlobalmax-xmin)/xGlobalmax
            video.seek(percent)
        btnLeft.bind(on_release=moveLeft)
        FourthScreen.add_widget(graph)
        FourthScreen.add_widget(video)