def check():
		global direction
		global inspikes
		global outspikes
		global outspikes2
		global outvolts
		print "Learning..."
		#-----------------------------------------------------
		def printWeights():
		    global direction
		    global inspikes
		    global outspikes
		    global outspikes2
		    global outvolts
		    global prj
		    print "outspikes:", outspikes
		    adjust=0.02
		    negadjust=0.02
		    nmax=inspikes.index(max(inspikes))
		    if (outspikes[0]<outspikes[1]) and (direction==dirs[1]):
			print 'correct 0'
		    elif (outspikes[0]>outspikes[1]) and (direction==dirs[0]): 
			print 'correct 3'
		    elif (outspikes[0]>=outspikes[1]) and (direction==dirs[1]):
			print 'wrong 0'
		    elif (outspikes[0]<=outspikes[1]) and (direction==dirs[0]):
			print 'wrong 3' 
		    else:
			print 'no 5'
		    print
		printWeights()
		#-----------------------------------------------------
		for p in prj:
		    currentWeight = p.getWeights()[0]
		    print direction, ntrial, p, currentWeight
	    def learn():
		global direction
		global inspikes
		global outspikes
		global outspikes2
		global outvolts
		print "Learning..."
		#-----------------------------------------------------
		def updateWeights():
		    global direction
		    global inspikes
		    global outspikes
		    global outspikes2
		    global outvolts
		    global prj
		    print "outspikes:", outspikes
		    print "Updating..."
		    adjust=0.02
		    negadjust=0.02
		    nmax=inspikes.index(max(inspikes))
		    if (outspikes[0]<outspikes[1]) and (direction==dirs[1]):
			prj[2*nmax+1].setWeights(prj[2*nmax+1].getWeights()[0]+adjust)
			print 'correct 0'
			print "Updated to:", prj[2*nmax+1].getWeights()
		    elif (outspikes[0]>outspikes[1]) and (direction==dirs[0]): 
			prj[2*nmax+0].setWeights(prj[2*nmax+0].getWeights()[0]+adjust)
			print 'correct 3'
			print "Updated to:", prj[2*nmax+0].getWeights()
		    elif (outspikes[0]>=outspikes[1]) and (direction==dirs[1]):
			print 'wrong 0'
			prj[2*nmax+0].setWeights(max(0,prj[2*nmax+0].getWeights()[0]-negadjust))
			print "Updated to:", prj[2*nmax+0].getWeights()
		    elif (outspikes[0]<=outspikes[1]) and (direction==dirs[0]):
			prj[2*nmax+1].setWeights(max(0,prj[2*nmax+1].getWeights()[0]-negadjust))
			print 'wrong 3' 
			print "Updated to:", prj[2*nmax+1].getWeights()
		    else:
			print 'no 5'
		    print
		updateWeights()
		#-----------------------------------------------------
		for p in prj:
		    currentWeight = p.getWeights()[0]
		    print direction, ntrial, p, currentWeight