def loadExperimentBind4 (prefix, x, y): startcount = 1 * 10000 # (learning time in s * FSV) listB = brainsim.loadBrain (prefix + str (x) + "-" + str(y) + "-BReport.txt") listG = brainsim.loadBrain (prefix + str (x) + "-" + str(y) + "-GReport.txt") listT = brainsim.loadBrain (prefix + str (x) + "-" + str(y) + "-TReport.txt") listS = brainsim.loadBrain (prefix + str (x) + "-" + str(y) + "-SReport.txt") cntB, spikesB = countSpikes (listB, startcount) cntG, spikesG = countSpikes (listG, startcount) cntT, spikesT = countSpikes (listT, startcount) cntS, spikesS = countSpikes (listS, startcount) return (spikesB,spikesG,spikesT,spikesS)
def genSpikePlotXY(prefix, num): listX = brainsim.loadBrain(prefix + str(num) + '-XReport.txt') listY = brainsim.loadBrain(prefix + str(num) + '-YReport.txt') c = numpy.linspace(0.0, len(listX), len(listX), endpoint=False) d = numpy.linspace(0.0, len(listY), len(listY), endpoint=False) pyplot.subplot(211) pyplot.title("Neuron X") pyplot.plot(c,listX) pyplot.subplot(212) pyplot.title("Neuron Y") pyplot.plot(d,listY) pyplot.show()
def plotVoltage(): global parameters sp=np.linspace(0.0,parameters['ENDSIM'],parameters['ENDSIM']*parameters['FSV']) lB=brainsim.loadBrain('vb-exp-BReport.txt') lG=brainsim.loadBrain('vb-exp-GReport.txt') lT=brainsim.loadBrain('vb-exp-TReport.txt') lS=brainsim.loadBrain('vb-exp-SReport.txt') lI=brainsim.loadBrain('vb-exp-IReport.txt') plt.subplot(511) plt.plot(sp,lB,'b') plt.subplot(512) plt.plot(sp,lG,'b') plt.subplot(513) plt.plot(sp,lT,'b') plt.subplot(514) plt.plot(sp,lS,'b') plt.subplot(515) plt.plot(sp,lI,'b') plt.show()
def plotUse(): global parameters sp=np.linspace(0.0,parameters['ENDSIM'], 1 + parameters['ENDSIM'] * parameters['FSV']) lB=brainsim.loadBrain('vb-exp-BUseReport.txt') lG=brainsim.loadBrain('vb-exp-GUseReport.txt') lT=brainsim.loadBrain('vb-exp-TUseReport.txt') lS=brainsim.loadBrain('vb-exp-SUseReport.txt') plt.subplot(221) plt.title('Blue Use') plt.plot(sp,lB,'g') plt.subplot(222) plt.title('Green Use') plt.plot(sp,lG,'g') plt.subplot(223) plt.title('Triangle Use') plt.plot(sp,lT,'g') plt.subplot(224) plt.title('Square Use') plt.plot(sp,lS,'g') plt.show()
def run (): exp = 99 listX = brainsim.loadBrain ("vb-exp" + str (exp) + "-XReport.txt") listY = brainsim.loadBrain ("vb-exp" + str (exp) + "-YReport.txt") cntX, spikesX = countSpikes (listX) cntY, spikesY = countSpikes (listY) print cntX print cntY print spikesX print spikesY print "SIGNAL CORRELATION: ", scipy.correlate (spikesX, spikesY) print "MAX: ", scipy.correlate (spikesX, spikesY).argmax() print "Total spike correlation (Brian func.): ", totalCorrelation(spikesX,spikesY,cntX,cntY) from matplotlib import pyplot pyplot.subplot (211) pyplot.plot (numpy.linspace (0.0, len (listX), len (listX)), listX) pyplot.subplot (212) pyplot.plot (numpy.linspace (0.0, len (listY), len (listY)), listY) pyplot.show ()
def show3DPlot(): from mpl_toolkits.mplot3d import Axes3D from matplotlib import cm from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter import matplotlib.pyplot as plt import numpy as np import scipy as sp import brainsim from countspikes import countSpikes fig = plt.figure() ax = fig.gca(projection='3d') vals=np.array(range(0,10)) X = map(lambda x: float(x)/100, vals) Y = map(lambda x: float(x)/10, vals[::-1]) # ISYN X, Y = np.meshgrid(X, Y) #R = np.sqrt(X**2 + Y**2) #Z = np.sin(R) listX=brainsim.loadBrain("vb-exp77-XReport.txt") listY=brainsim.loadBrain("vb-exp77-YReport.txt") cntX,spikesX=countSpikes(listX) cntY,spikesY=countSpikes(listY) Z=np.array(spikecorr) Z=np.array([Z, Z, Z, Z, Z, Z, Z, Z, Z, Z]) surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet, linewidth=0, antialiased=False) ax.set_zlim3d(np.argmin(Z), np.argmax(Z)) ax.w_zaxis.set_major_locator(LinearLocator(10)) ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f')) fig.colorbar(surf, shrink=0.5, aspect=5) plt.show()
'ENDSIM':2, 'FSV':10000, 'BRAINNAME':"vb-exp1", 'TAU_NOISE':0.020} #0.020 # parameters['CONN_INTERNAL']=i/100 # parameters['CONN_LATERAL']=i/100 parameters['ESYN_MAXCONDUCTANCE']=esynval parameters['ISYN_MAXCONDUCTANCE']=isynval esynval=esynval+0.01 isynval=isynval-0.1 # parameters['TAU_NOISE']=(trials-i)/trials parameters['BRAINNAME']='vb-exp'+str(int(ii)) brainsim.simBrain(parameters) listX = brainsim.loadBrain(parameters['BRAINNAME']+'-XReport.txt') listY = brainsim.loadBrain(parameters['BRAINNAME']+'-YReport.txt') nsamples=len(listX) t = numpy.linspace(0.0, parameters['ENDSIM'], nsamples, endpoint=False) A=numpy.array(listX).astype(float) B=numpy.array(listY).astype(float) # Purely spike correlation cntX,spikesX = countSpikes(listX) cntY,spikesY = countSpikes(listY) print "cntX,spikesX: ", cntX, spikesX print "cntY,spikesY: ", cntY, spikesY sxcorr = scipy.correlate(spikesX, spikesY) spikecorr.append(sxcorr[sxcorr.argmax()])
def loadExperimentXYI (prefix, esynval, isynval): listX = brainsim.loadBrain (prefix + str (esynval) + "-" + str(isynval) + "-XReport.txt") listY = brainsim.loadBrain (prefix + str (esynval) + "-" + str(isynval) + "-YReport.txt") cntX, spikesX = countSpikes (listX) cntY, spikesY = countSpikes (listY) return (listX,cntX,spikesX),(listY,cntY,spikesY)
lS=brainsim.loadBrain('vb-exp-SReport.txt') lI=brainsim.loadBrain('vb-exp-IReport.txt') plt.subplot(511) plt.plot(sp,lB,'b') plt.subplot(512) plt.plot(sp,lG,'b') plt.subplot(513) plt.plot(sp,lT,'b') plt.subplot(514) plt.plot(sp,lS,'b') plt.subplot(515) plt.plot(sp,lI,'b') plt.show() brainsim.simBrain(parameters) lB=brainsim.loadBrain('vb-exp-BReport.txt') lG=brainsim.loadBrain('vb-exp-GReport.txt') lT=brainsim.loadBrain('vb-exp-TReport.txt') lS=brainsim.loadBrain('vb-exp-SReport.txt') _,spikesB=brainalyze.countSpikes(lB,10000*(parameters['ENDSIM']/2)) _,spikesG=brainalyze.countSpikes(lG,10000*(parameters['ENDSIM']/2)) _,spikesT=brainalyze.countSpikes(lT,10000*(parameters['ENDSIM']/2)) _,spikesS=brainalyze.countSpikes(lS,10000*(parameters['ENDSIM']/2)) cBT=brainalyze.corr(spikesB,spikesT)/(brainalyze.corr(spikesT,spikesS)/1) cGT=brainalyze.corr(spikesG,spikesT)/(brainalyze.corr(spikesT,spikesS)/1) cBS=brainalyze.corr(spikesB,spikesS)/(brainalyze.corr(spikesS,spikesT)/1) cGS=brainalyze.corr(spikesG,spikesS)/(brainalyze.corr(spikesS,spikesT)/1) #cBS=cBS+10 #cGS=cGS+10 #cBS=(cBS/cGS)*cBT
#while x < len(rates): # while y < len(rates): # parameters['RATE1']=rates[x] # parameters['RATE2']=rates[y] # parameters['BRAINNAME']='vb-exp'+str(rates[x])+'-'+str(rates[y]) # brainsim.simBrain(parameters) # y=y+1 # y=0 #reset # x=x+1 x=0 y=0 while x < len(rates): while y < len(rates): print rates[x],rates[y] lB=brainsim.loadBrain('vb-exp'+str(rates[x])+'-'+str(rates[y])+'-BReport.txt') lG=brainsim.loadBrain('vb-exp'+str(rates[x])+'-'+str(rates[y])+'-GReport.txt') lT=brainsim.loadBrain('vb-exp'+str(rates[x])+'-'+str(rates[y])+'-TReport.txt') lS=brainsim.loadBrain('vb-exp'+str(rates[x])+'-'+str(rates[y])+'-SReport.txt') _,spikesB=brainalyze.countSpikes(lB,10000*(parameters['ENDSIM']/2)) _,spikesG=brainalyze.countSpikes(lG,10000*(parameters['ENDSIM']/2)) _,spikesT=brainalyze.countSpikes(lT,10000*(parameters['ENDSIM']/2)) _,spikesS=brainalyze.countSpikes(lS,10000*(parameters['ENDSIM']/2)) cBT=brainalyze.corr(spikesB,spikesT)/(brainalyze.corr(spikesT,spikesS)/1) cGT=brainalyze.corr(spikesG,spikesT)/(brainalyze.corr(spikesT,spikesS)/1) cBS=brainalyze.corr(spikesB,spikesS)/(brainalyze.corr(spikesS,spikesT)/1) cGS=brainalyze.corr(spikesG,spikesS)/(brainalyze.corr(spikesS,spikesT)/1) # Blue Triangle and Green Square if cBT > cGT and cGS > cBS: store[x][y]=(abs(cBT - cGT) + abs(cGS - cBS))/2 else:
def loadExperiment (prefix, exp): listX = brainsim.loadBrain (prefix + str (exp) + "-XReport.txt") listY = brainsim.loadBrain (prefix + str (exp) + "-YReport.txt") cntX, spikesX = countSpikes (listX) cntY, spikesY = countSpikes (listY) return (listX,cntX,spikesX),(listY,cntY,spikesY)