diff --git a/.gitignore b/.gitignore index 51cbe85..bec39c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] - +.idea # C extensions *.so diff --git a/ChrisCabot/cabot1.py b/ChrisCabot/cabot1.py new file mode 100644 index 0000000..52226cd --- /dev/null +++ b/ChrisCabot/cabot1.py @@ -0,0 +1,540 @@ +""" +Bug: it doesn't print if you run 1000 or 2000 ms. + +This does the full thing: it views from the retina, through V1, +to pyramid detection, then sets a fact on. It also has the planning in. +So, it does the commands that are activated. This can be set in the +short version in runNoCallBack, or all can be tested with the RunCallBack +version. +""" + +#imports for PyNN +from pyNN.utility import get_script_args + +#imports for image reading +import numpy +from PIL import Image +#Other NEAL files and functions + +from visionClass import visionArea + +INPUT_NEURONS_HEIGHT = 50 +INPUT_NEURONS_WIDTH = 50 + +DELAY = 1.0 +output_filename='cabot1_out.dat' +SIM_LENGTH = 300.0 +#SIM_LENGTH = 2000.0 #For the full plan test + +CA_HEIGHT = 10 +CA_WIDTH = 10 + + +#------set up object to fact connections---------- +#-every neuron of the left 20 of the object turns on the left flag +def leftObjectTurnsLeftFactOn (): + synWeight = 3.0 + connector = [] + for cRow in range (0,INPUT_NEURONS_HEIGHT): + for cCol in range (0,int(INPUT_NEURONS_WIDTH*0.4)): + fromNeuron=cRow*INPUT_NEURONS_WIDTH+cCol + toNeuron = cCol % 5 + connector = connector + [(fromNeuron,toNeuron,synWeight,DELAY)] + return connector + +#-every neuron of the right 20 of the object turns on the left flag +def rightObjectTurnsLeftFactOn (): + synWeight = 3.0 + connector = [] + for cRow in range (0,INPUT_NEURONS_HEIGHT): + for cCol in range (int(INPUT_NEURONS_WIDTH*0.6),INPUT_NEURONS_WIDTH): + fromNeuron=cRow*INPUT_NEURONS_WIDTH+cCol + toNeuron = cCol % 5 + connector = connector + [(fromNeuron,toNeuron,synWeight,DELAY)] + return connector + +#-every neuron of the object turns on the fact +def objectTurnsObjectFactOn (): + synWeight = 3.0 + connector = [] + for cRow in range (0,INPUT_NEURONS_HEIGHT): + for cCol in range (0,int(INPUT_NEURONS_WIDTH)): + fromNeuron=cRow*INPUT_NEURONS_WIDTH+cCol + toNeuron = cCol % 5 + connector = connector + [(fromNeuron,toNeuron,synWeight,DELAY)] + return connector + + + +#----------------functions for setting plan connections +def setStandardOscillatorConnector(oscPart1,oscPart2,weight): + connect(oscPart1,oscPart2,weight, DELAY) + +def setPlanConnections(): + weight = 6.0 + synWeight = 6.0 + inhibitW = -5.25 + synWeightCoeff = 0.25 + + #connections for goals + setStandardOscillatorConnector(goalTL_1,goalTL_2,weight) + setStandardOscillatorConnector(goalTL_2,goalTL_1,weight) + setStandardOscillatorConnector(goalTR_1,goalTR_2,weight) + setStandardOscillatorConnector(goalTR_2,goalTR_1,weight) + setStandardOscillatorConnector(goalBack_1,goalBack_2,weight) + setStandardOscillatorConnector(goalBack_2,goalBack_1,weight) + setStandardOscillatorConnector(goalForward_1,goalForward_2,weight) + setStandardOscillatorConnector(goalForward_2,goalForward_1,weight) + setStandardOscillatorConnector(goal_move_left1_1,goal_move_left1_2,weight) + setStandardOscillatorConnector(goal_move_left1_2,goal_move_left1_1,weight) + setStandardOscillatorConnector(goal_move_left2_1,goal_move_left2_2,weight) + setStandardOscillatorConnector(goal_move_left2_2,goal_move_left2_1,weight) + setStandardOscillatorConnector(goal_move_right1_1,goal_move_right1_2,weight) + setStandardOscillatorConnector(goal_move_right1_2,goal_move_right1_1,weight) + setStandardOscillatorConnector(goal_move_right2_1,goal_move_right2_2,weight) + setStandardOscillatorConnector(goal_move_right2_2,goal_move_right2_1,weight) + setStandardOscillatorConnector(goal_pyramid_1,goal_pyramid_2,weight) + setStandardOscillatorConnector(goal_pyramid_2,goal_pyramid_1,weight) + + + #connect compound goals to second part of goals + setStandardOscillatorConnector(goal_move_left1_1,goal_move_left2_1,synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_move_left1_2,goal_move_left2_1,synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_move_right1_1,goal_move_right2_1,synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_move_right1_2,goal_move_right2_1,synWeightCoeff*synWeight) + + #connections for modules + setStandardOscillatorConnector(moduleTL_1,moduleTL_2,weight) + setStandardOscillatorConnector(moduleTL_2,moduleTL_1,weight) + setStandardOscillatorConnector(moduleTR_1,moduleTR_2,weight) + setStandardOscillatorConnector(moduleTR_2,moduleTR_1,weight) + setStandardOscillatorConnector(moduleBack_1,moduleBack_2,weight) + setStandardOscillatorConnector(moduleBack_2,moduleBack_1,weight) + setStandardOscillatorConnector(moduleForward_1,moduleForward_2,weight) + setStandardOscillatorConnector(moduleForward_2,moduleForward_1,weight) + + #connections between modules and goals + setStandardOscillatorConnector(goalTL_1,moduleTL_2,weight) + setStandardOscillatorConnector(goalTL_2,moduleTL_1,weight) + setStandardOscillatorConnector(goalTL_1,moduleTL_1,weight) + setStandardOscillatorConnector(goalTL_2,moduleTL_2,weight) + setStandardOscillatorConnector(goalTR_1,moduleTR_2,weight) + setStandardOscillatorConnector(goalTR_2,moduleTR_1,weight) + setStandardOscillatorConnector(goalTR_1,moduleTR_1,weight) + setStandardOscillatorConnector(goalTR_2,moduleTR_2,weight) + setStandardOscillatorConnector(goalBack_1,moduleBack_2,weight) + setStandardOscillatorConnector(goalBack_2,moduleBack_1,weight) + setStandardOscillatorConnector(goalBack_1,moduleBack_1,weight) + setStandardOscillatorConnector(goalBack_2,moduleBack_2,weight) + setStandardOscillatorConnector(goalForward_1,moduleForward_2,weight) + setStandardOscillatorConnector(goalForward_2,moduleForward_1,weight) + setStandardOscillatorConnector(goalForward_1,moduleForward_1,weight) + setStandardOscillatorConnector(goalForward_2,moduleForward_2,weight) + setStandardOscillatorConnector(goal_move_left1_1,moduleTL_2,weight) + setStandardOscillatorConnector(goal_move_left1_2,moduleTL_1,weight) + setStandardOscillatorConnector(goal_move_left1_1,moduleTL_1,weight) + setStandardOscillatorConnector(goal_move_left1_2,moduleTL_2,weight) + setStandardOscillatorConnector(goal_move_left2_1,moduleForward_2,weight) + setStandardOscillatorConnector(goal_move_left2_2,moduleForward_1,weight) + setStandardOscillatorConnector(goal_move_left2_1,moduleForward_1,weight) + setStandardOscillatorConnector(goal_move_left2_2,moduleForward_2,weight) + setStandardOscillatorConnector(goal_move_right1_1,moduleTR_2,weight) + setStandardOscillatorConnector(goal_move_right1_2,moduleTR_1,weight) + setStandardOscillatorConnector(goal_move_right1_1,moduleTR_1,weight) + setStandardOscillatorConnector(goal_move_right1_2,moduleTR_2,weight) + setStandardOscillatorConnector(goal_move_right2_1,moduleForward_2,weight) + setStandardOscillatorConnector(goal_move_right2_2,moduleForward_1,weight) + setStandardOscillatorConnector(goal_move_right2_1,moduleForward_1,weight) + setStandardOscillatorConnector(goal_move_right2_2,moduleForward_2,weight) + + #connections between goal_pyramid (find the pyramid) and modules. + #very weak and passive, since pyramid could be either left or right + setStandardOscillatorConnector(goal_pyramid_1, moduleTR_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_1, moduleTR_2, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_2, moduleTR_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_2, moduleTR_2, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_1, moduleTL_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_1, moduleTL_2, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_2, moduleTL_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(goal_pyramid_2,moduleTL_2,synWeightCoeff*synWeight) + + #facts have stronger weights and more bias, excite the **_1 lead to spike + synWeightCoeff = 0.75 + chrisWeight = 1.0 + setStandardOscillatorConnector(leftFactAPop,moduleTL_1,chrisWeight) + setStandardOscillatorConnector(leftFactBPop,moduleTL_1,chrisWeight) + setStandardOscillatorConnector(rightFactAPop,moduleTR_1,chrisWeight) + setStandardOscillatorConnector(rightFactBPop,moduleTR_1,chrisWeight) + + #facts inhibit modules + chrisInhib = -3.0 + setStandardOscillatorConnector(leftFactAPop,moduleTR_1,chrisInhib) + setStandardOscillatorConnector(leftFactAPop,moduleTR_2,chrisInhib) + setStandardOscillatorConnector(rightFactAPop,moduleTL_1,chrisInhib) + setStandardOscillatorConnector(rightFactAPop,moduleTL_2,chrisInhib) + + #to and from actions + setStandardOscillatorConnector(moduleTL_1, TL, synWeight) + setStandardOscillatorConnector(moduleTL_2, TL, synWeight) + setStandardOscillatorConnector(TL,moduleTL_1, inhibitW) + setStandardOscillatorConnector(TL,moduleTL_2, inhibitW) + setStandardOscillatorConnector(TL,goalTL_1, inhibitW) + setStandardOscillatorConnector(TL,goalTL_2, inhibitW) + + setStandardOscillatorConnector(moduleTR_1, TR, synWeight) + setStandardOscillatorConnector(moduleTR_2, TR, synWeight) + setStandardOscillatorConnector(TR,moduleTR_1, inhibitW) + setStandardOscillatorConnector(TR,moduleTR_2, inhibitW) + setStandardOscillatorConnector(TR,goalTR_1, inhibitW) + setStandardOscillatorConnector(TR,goalTR_2, inhibitW) + + setStandardOscillatorConnector(moduleBack_1, back, synWeight) + setStandardOscillatorConnector(moduleBack_2, back, synWeight) + setStandardOscillatorConnector(back,moduleBack_1, inhibitW) + setStandardOscillatorConnector(back,moduleBack_2, inhibitW) + setStandardOscillatorConnector(back,goalBack_1, inhibitW) + setStandardOscillatorConnector(back,goalBack_2, inhibitW) + + setStandardOscillatorConnector(moduleForward_1, forward, synWeight) + setStandardOscillatorConnector(moduleForward_2, forward, synWeight) + setStandardOscillatorConnector(forward,moduleForward_1, inhibitW) + setStandardOscillatorConnector(forward,moduleForward_2, inhibitW) + setStandardOscillatorConnector(forward,goalForward_1, inhibitW) + setStandardOscillatorConnector(forward,goalForward_2, inhibitW) + + #action left and forward for move left + synWeightCoeff=0.75 + setStandardOscillatorConnector(TL, goal_move_left2_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(TL, goal_move_left2_2, synWeightCoeff*synWeight) + setStandardOscillatorConnector(TL, goal_move_left1_1, inhibitW) + setStandardOscillatorConnector(TL, goal_move_left1_2, inhibitW) + setStandardOscillatorConnector(forward, goal_move_left2_1, inhibitW) + setStandardOscillatorConnector(forward, goal_move_left2_2, inhibitW) + + setStandardOscillatorConnector(TR, goal_move_right2_1, synWeightCoeff*synWeight) + setStandardOscillatorConnector(TR, goal_move_right2_2, synWeightCoeff*synWeight) + setStandardOscillatorConnector(TR, goal_move_right1_1, inhibitW) + setStandardOscillatorConnector(TR, goal_move_right1_2, inhibitW) + setStandardOscillatorConnector(forward, goal_move_right2_1, inhibitW) + setStandardOscillatorConnector(forward, goal_move_right2_2, inhibitW) + + #actions turn off facts too (thanks Ian) + setStandardOscillatorConnector(TR, rightFactAPop, inhibitW) + setStandardOscillatorConnector(TR, rightFactBPop, inhibitW) + setStandardOscillatorConnector(TL, leftFactAPop, inhibitW) + setStandardOscillatorConnector(TL, leftFactBPop, inhibitW) + + #actions turn off pyramid goals sJA + setStandardOscillatorConnector(TL, goal_pyramid_1, inhibitW) + setStandardOscillatorConnector(TL, goal_pyramid_2, inhibitW) + #eja + setStandardOscillatorConnector(TR, goal_pyramid_1, inhibitW) + setStandardOscillatorConnector(TR, goal_pyramid_2, inhibitW) + +#-------------Print out neuron by neuron the firing times +def print_spikes(of, label, pop): + print "\n\n%s\n" % label + of.write("\n%s\n" % label) + outDat = pop.get_data() + for seg in outDat.segments: + print(seg.spiketrains) + of.write("\n%s\n" % str(seg.spiketrains)) + +#------Image Stuff +def openImageFile(): + try: +#pyramid im = Image.open("ed_3screenshot.jpg") +#stalactite im = Image.open("ed_screenshot826.jpg") #stalactite + im = Image.open("pyr1.jpg") + except: + print "fail to open image" + + im = im.crop((0,0,600,600)) + #print im.size + + #shrink it + size = (INPUT_NEURONS_WIDTH,INPUT_NEURONS_HEIGHT) + im.thumbnail(size) + + #get the pixels + pixels = im.load() + + ##convert rgb to grey scale + inputMatrix = numpy.zeros((50,50)) + for inpRow in range (0,50): + for inpCol in range (0,50): + rgb = pixels[inpCol,inpRow] + for i in range (0,3): + inputMatrix[inpCol,inpRow] += rgb[i] + inputMatrix[inpCol,inpRow]/=3 + + ##set result image array + resultImage = numpy.zeros((50,50)) + THRESHOLD = 50 + resultImageArray = [] + for outRow in range (0,50): + for outColumn in range (0,50): + if inputMatrix[outColumn,outRow] < THRESHOLD : + #print outRow, outColumn + pixelOn = (outRow*INPUT_NEURONS_WIDTH)+outColumn + resultImageArray = resultImageArray + [pixelOn] + + return resultImageArray + +#stimulus +def setInputs(): + pulse0 =DCSource(amplitude=55,start=0.0,stop=10.0) + ML_Assembly = Assembly(goal_move_left1_1[0,1,2,3,4]) + pulse0.inject_into(ML_Assembly) + pulse1 =DCSource(amplitude=55,start=100.0,stop=110.0) + TP_Assembly = Assembly(goal_pyramid_1[0,1,2,3,4]) + pulse1.inject_into(TP_Assembly) + pulse2 =DCSource(amplitude=55,start=200.0,stop=210.0) + back_Assembly = Assembly(goalBack_1[0,1,2,3,4]) + pulse2.inject_into(back_Assembly) + +def setInputs2(): + pulse0 =DCSource(amplitude=55,start=0.0,stop=10.0) + TR_Assembly = Assembly(goalTR_1[0,1,2,3,4]) + pulse0.inject_into(TR_Assembly) + pulse1 =DCSource(amplitude=55,start=100.0,stop=110.0) + TL_Assembly = Assembly(goalTL_1[0,1,2,3,4]) + pulse1.inject_into(TL_Assembly) + pulse2 =DCSource(amplitude=55,start=200.0,stop=210.0) + forward_Assembly = Assembly(goalForward_1[0,1,2,3,4]) + pulse2.inject_into(forward_Assembly) + pulse3 =DCSource(amplitude=55,start=300.0,stop=310.0) + back_Assembly = Assembly(goalBack_1[0,1,2,3,4]) + pulse3.inject_into(back_Assembly) + pulse4 =DCSource(amplitude=55,start=400.0,stop=410.0) + move_left1_Assembly = Assembly(goal_move_left1_1[0,1,2,3,4]) + pulse4.inject_into(move_left1_Assembly) + pulse5 = DCSource(amplitude=55, start=500.0, stop=510.0) + move_right1_Assembly = Assembly(goal_move_right1_1[0,1,2,3,4]) + pulse5.inject_into(move_right1_Assembly) + pulse6 = DCSource(amplitude=55, start=600.0, stop=610.0) + move_left1_Assembly = Assembly(goal_move_left1_1[0,1,2,3,4]) + pulse6.inject_into(move_left1_Assembly) + pulse7 = DCSource(amplitude=55, start=700.0, stop=710.0) + pulse7.inject_into(TR_Assembly) + pulse8 = DCSource(amplitude=55, start=800.0, stop=810.0) + pulse8.inject_into(TL_Assembly) + pulse9 =DCSource(amplitude=55,start=900.0,stop=910.0) + forward_Assembly = Assembly(goalForward_1[0,1,2,3,4]) + pulse9.inject_into(forward_Assembly) + pulse10 =DCSource(amplitude=55, start=1000.0,stop=1010.0) + pulse10.inject_into(TR_Assembly) + pulse11 =DCSource(amplitude=55,start=1100.0,stop=1110.0) + pulse11.inject_into(TL_Assembly) + pulse12 =DCSource(amplitude=55,start=1200.0,stop=1210.0) + TP_Assembly = Assembly(goal_pyramid_1[0,1,2,3,4]) + pulse12.inject_into(TP_Assembly) + pulse13 =DCSource(amplitude=55,start=1300.0,stop=1310.0) + pulse13.inject_into(TP_Assembly) + pulse14 =DCSource(amplitude=55,start=1400.0,stop=1410.0) + pulse14.inject_into(TR_Assembly) + pulse15 =DCSource(amplitude=55,start=1500.0,stop=1510.0) + pulse15.inject_into(TL_Assembly) + + +def runNoCallBack(): + #set up clamped input from image + # pulseVis = DCSource(amplitude=0.0038, start=0.0, stop=SIM_LENGTH) + # pulseVis = DCSource(amplitude=0.38, start=0.0, stop=SIM_LENGTH) + pulseVis = DCSource(amplitude=58, start=0.0, stop=SIM_LENGTH) + inputAssembly = Assembly(vision.getInputPopulation()[imagePixels]) + pulseVis.inject_into(inputAssembly) + + #pulseGoal = DCSource(amplitude=0.0038, start=0.0, stop=10) + #goalInputAssembly = Assembly(goal_move_left1_1[0,1,2,3,4]) + #goalInputAssembly = Assembly(goal_pyramid_1[0,1,2,3,4]) + #pulseGoal.inject_into(goalInputAssembly) + + run(SIM_LENGTH) + +#------------Main Body--------------- +simulator_name = get_script_args(1)[0] +exec("from pyNN.%s import *" % simulator_name) + +setup(timestep=DELAY,min_delay=DELAY,max_delay=DELAY,debug=0) + +#----------------create neurons +#input neurons +cInputNeurons = INPUT_NEURONS_HEIGHT * INPUT_NEURONS_WIDTH + +vision = visionArea() +vision.allocateVisionNeurons() + +#create fact neurons (for vision) +# fact_cell_params = {'a': 0.05, 'd': 0,'i_offset' : 2} +fact_cell_params = {} +leftFactAPop = Population(5,IF_curr_exp(**fact_cell_params)) +leftFactBPop = Population(5,IF_curr_exp(**fact_cell_params)) +rightFactAPop = Population(5,IF_curr_exp(**fact_cell_params)) +rightFactBPop = Population(5,IF_curr_exp(**fact_cell_params)) +pyramidFactAPop = Population(5,IF_curr_exp(**fact_cell_params)) +pyramidFactBPop = Population(5,IF_curr_exp(**fact_cell_params)) +stalactiteFactAPop = Population(5,IF_curr_exp(**fact_cell_params)) +stalactiteFactBPop = Population(5,IF_curr_exp(**fact_cell_params)) + + +##create plan neurons +# cell_params = {'a' : 0.05} +cell_params = {} +goalTL_1 = Population(5,IF_curr_exp(**cell_params)) +goalTL_2 = Population(5,IF_curr_exp(**cell_params)) + +goalTR_1 = Population(5, IF_curr_exp(**cell_params)) +goalTR_2 = Population(5, IF_curr_exp(**cell_params)) + +goalBack_1 = Population(5,IF_curr_exp(**cell_params)) +goalBack_2 = Population(5,IF_curr_exp(**cell_params)) + +goalForward_1 = Population(5, IF_curr_exp(**cell_params)) +goalForward_2 = Population(5, IF_curr_exp(**cell_params)) + +goal_move_left1_1 = Population(5, IF_curr_exp(**cell_params)) +goal_move_left1_2 = Population(5, IF_curr_exp(**cell_params)) + +goal_move_left2_1 = Population(5, IF_curr_exp(**cell_params)) +goal_move_left2_2 = Population(5, IF_curr_exp(**cell_params)) + +goal_move_right1_1 = Population(5, IF_curr_exp(**cell_params)) +goal_move_right1_2 = Population(5, IF_curr_exp(**cell_params)) + +goal_move_right2_1 = Population(5, IF_curr_exp(**cell_params)) +goal_move_right2_2 = Population(5, IF_curr_exp(**cell_params)) + + +goal_pyramid_1 = Population(5, IF_curr_exp(**cell_params)) +goal_pyramid_2 = Population(5, IF_curr_exp(**cell_params)) + + +#FACTS see facts in vision + +#modules +moduleTL_1 = Population(5,IF_curr_exp(**cell_params)) +moduleTL_2 = Population(5,IF_curr_exp(**cell_params)) +moduleTR_1 = Population(5, IF_curr_exp(**cell_params)) +moduleTR_2 = Population(5, IF_curr_exp(**cell_params)) +moduleBack_1 = Population(5,IF_curr_exp(**cell_params)) +moduleBack_2 = Population(5,IF_curr_exp(**cell_params)) +moduleForward_1 = Population(5, IF_curr_exp(**cell_params)) +moduleForward_2 = Population(5, IF_curr_exp(**cell_params)) + + +#output/actions +TL = Population(1, IF_curr_exp(**cell_params)) +TR = Population(1, IF_curr_exp(**cell_params)) +back = Population(1, IF_curr_exp(**cell_params)) +forward = Population(1, IF_curr_exp(**cell_params)) + +#---------setup connections +vision.makeVisionSynapses() + +#setup fact connections +synWeight = 5.0 +connect(leftFactAPop, leftFactBPop, weight=synWeight, delay=DELAY) +connect(leftFactBPop, leftFactAPop, weight=synWeight, delay=DELAY) +connect(rightFactAPop, rightFactBPop, weight=synWeight, delay=DELAY) +connect(rightFactBPop, rightFactAPop, weight=synWeight, delay=DELAY) +connect(pyramidFactAPop, pyramidFactBPop, weight=synWeight, delay=DELAY) +connect(pyramidFactBPop, pyramidFactAPop, weight=synWeight, delay=DELAY) +connect(stalactiteFactAPop, stalactiteFactBPop, weight=synWeight, delay=DELAY) +connect(stalactiteFactBPop, stalactiteFactAPop, weight=synWeight, delay=DELAY) + + +#-------connect objects to facts +synapseArray = leftObjectTurnsLeftFactOn() +Projection(vision.getPyramidPopulation(),leftFactAPop,FromListConnector(synapseArray),StaticSynapse()) +Projection(vision.getStalactitePopulation(),leftFactAPop,FromListConnector(synapseArray),StaticSynapse()) + +synapseArray = rightObjectTurnsLeftFactOn() +Projection(vision.getPyramidPopulation(),rightFactAPop,FromListConnector(synapseArray),StaticSynapse()) +Projection(vision.getStalactitePopulation(),rightFactAPop,FromListConnector(synapseArray),StaticSynapse()) + +synapseArray = objectTurnsObjectFactOn() +Projection(vision.getPyramidPopulation(),pyramidFactAPop,FromListConnector(synapseArray),StaticSynapse()) +Projection(vision.getStalactitePopulation(),stalactiteFactAPop,FromListConnector(synapseArray),StaticSynapse()) + + +print "Plan Connections" +setPlanConnections() + +#turn on the inputs +setInputs() + +#-------------------setup recording +#inpPop.record(['spikes','v']) +vision.setVisionRecording() +leftFactAPop.record(['spikes','v']) +rightFactAPop.record(['spikes','v']) +pyramidFactAPop.record(['spikes','v']) +stalactiteFactAPop.record(['spikes','v']) +back.record('spikes') +forward.record('spikes') +TR.record('spikes') +TL.record('spikes') + +#comment - open file +of = open(output_filename, 'w') + +#print inpPop[0].get_parameters() + +#open image file +imagePixels = openImageFile() +#print imagePixels + +runNoCallBack() + +#--------------print results + +print "left fact" +outAss = Assembly(leftFactAPop[0,1]) +outDat = outAss.get_data() +for seg in outDat.segments: + print(seg.spiketrains) +# print(seg.analogsignalarrays) + +print "right fact" +outAss = Assembly(rightFactAPop[0,1]) +outDat = outAss.get_data() +for seg in outDat.segments: + print(seg.spiketrains) +# print(seg.analogsignalarrays) + +print "pyramid fact" +outAss = Assembly(pyramidFactAPop[0,1]) +outDat = outAss.get_data() +for seg in outDat.segments: + print(seg.spiketrains) + +print "stalactite fact" +outAss = Assembly(stalactiteFactAPop[0,1]) +outDat = outAss.get_data() +for seg in outDat.segments: + print(seg.spiketrains) + +#print "pyramid" +#outAss = Assembly(pyramidPop[821,520]) +#outDat = outAss.get_data() +#for seg in outDat.segments: +# print(seg.spiketrains) +#print "stalactite" +#outAss = Assembly(stalactitePop[821,520]) +#outDat = outAss.get_data() +#for seg in outDat.segments: +# print(seg.spiketrains) + + + +print_spikes(of,"Pop Back", back) +print_spikes(of,"Pop Forward", forward) +print_spikes(of,"Pop Turn Right", TR) +print_spikes(of,"Pop Turn Left", TL) + +#vision.printVisionNets() + + +end() + diff --git a/ChrisCabot/cabot1_out.dat b/ChrisCabot/cabot1_out.dat new file mode 100644 index 0000000..dd19586 --- /dev/null +++ b/ChrisCabot/cabot1_out.dat @@ -0,0 +1,177 @@ + +Pop Back + +[] + +Pop Forward + +[] + +Pop Turn Right + +[] + +Pop Turn Left + +[] diff --git a/ChrisCabot/objRecConnections.py b/ChrisCabot/objRecConnections.py new file mode 100644 index 0000000..6794312 --- /dev/null +++ b/ChrisCabot/objRecConnections.py @@ -0,0 +1,197 @@ +DELAY = 1.0 + +INPUT_NEURONS_HEIGHT = 50 +INPUT_NEURONS_WIDTH = 50 + +CA_HEIGHT = 10 +CA_WIDTH = 10 + +#----------------setup connections----------------- +#setup CAs in the pyramid and stalactite net +def connectCA (CANum): + CASize = CA_WIDTH*CA_HEIGHT + CARow = CANum/5 + CACol = CANum%5 + synWeight = 3.0 + numSynapses = 10 + connector = [] + for cRow in range (0,CA_HEIGHT): + for cCol in range (0,CA_WIDTH): + fromNeuron=cRow*INPUT_NEURONS_WIDTH+cCol + fromNeuron=fromNeuron+(CARow*CA_HEIGHT*INPUT_NEURONS_WIDTH) + fromNeuron = fromNeuron + (CACol*CA_WIDTH) + for cSynapse in range (0,numSynapses): + toCol = cCol + cSynapse + 1 + toRow = cRow + if (toCol>=CA_WIDTH) : + toCol = toCol - 10 + toRow = toRow + 1 + if (toRow>=CA_HEIGHT) : + toRow = toRow - 10 + toNeuron=toRow*INPUT_NEURONS_WIDTH+toCol + toNeuron=toNeuron+(CARow*CA_HEIGHT*INPUT_NEURONS_WIDTH) + toNeuron = toNeuron + (CACol*CA_WIDTH) + connector = connector + [(fromNeuron,toNeuron,synWeight,DELAY)] + + return connector + +#add connections up 5 and over one both ways (15) +def connectHEdgeBottomToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*10,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + for toRow in range(fromRow-5,fromRow): + for toCol in range (fromCol-1,fromCol + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections down left (7:30) 5 and over one both ways (15) +def connectSEdgeLeftToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (5,totalNeurons-(INPUT_NEURONS_WIDTH*10)): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol < 5: + continue + for rowChange in range(1,6): + toRow = fromRow+rowChange + for toCol in range (fromCol-rowChange-1,fromCol-rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#bedge +#add connections down right (4:30) 5 and over one both ways (15) +def connectBEdgeRightToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (0,totalNeurons-(INPUT_NEURONS_WIDTH*10)): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol > 45: + continue + for rowChange in range(1,6): + toRow = fromRow+rowChange + for toCol in range (fromCol+rowChange-1,fromCol+rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections down 5 and over one both ways (15) +def connectAndAngleToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (0,totalNeurons-(INPUT_NEURONS_WIDTH*10)): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + for toRow in range(fromRow+1,fromRow+6): + for toCol in range (fromCol-1,fromCol + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections up right (1:30) 5 and over one both ways (15) +def connectLessThanAngleToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*5,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol > 45: + continue + for rowChange in range(-5,0): + toRow = fromRow+rowChange + for toCol in range (fromCol-rowChange-1,fromCol-rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections up left (half ten) 5 and over one both ways (15) +def connectGreaterThanAngleToPyramid (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*5,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol < 6: + continue + for rowChange in range(-5,0): + toRow = fromRow+rowChange + for toCol in range (fromCol+rowChange-1,fromCol+rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + + +#add connections down 5 and over one both ways (15) +def connectHEdgeTopToStalactite (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (0,totalNeurons-(INPUT_NEURONS_WIDTH*10)): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + for toRow in range(fromRow+1,fromRow+6): + for toCol in range (fromCol-1,fromCol + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections up left (half ten) 5 and over one both ways (15) +def connectSEdgeRightToStalactite (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*5,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol < 6: + continue + for rowChange in range(-5,0): + toRow = fromRow+rowChange + for toCol in range (fromCol+rowChange-1,fromCol+rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + + +#add connections up right (1:30) 5 and over one both ways (15) +def connectBEdgeLeftToStalactite(): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*5,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + if fromCol > 45: + continue + for rowChange in range(-5,0): + toRow = fromRow+rowChange + for toCol in range (fromCol-rowChange-1,fromCol-rowChange + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector + +#add connections up 5 and over one both ways (15) +def connectOrAngleToStalactite (): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + synWeight = 10.0 + connector = [] + for cNeuron in range (INPUT_NEURONS_WIDTH*10,totalNeurons): + fromRow = cNeuron/50 + fromCol = cNeuron % 50 + for toRow in range(fromRow-5,fromRow): + for toCol in range (fromCol-1,fromCol + 2): + toNeuron = toRow*50+toCol + connector = connector + [(cNeuron,toNeuron,synWeight,DELAY)] + return connector diff --git a/ChrisCabot/pyr1.jpg b/ChrisCabot/pyr1.jpg new file mode 100755 index 0000000..329d34d Binary files /dev/null and b/ChrisCabot/pyr1.jpg differ diff --git a/ChrisCabot/retinaConnections.py b/ChrisCabot/retinaConnections.py new file mode 100755 index 0000000..a6d6c61 --- /dev/null +++ b/ChrisCabot/retinaConnections.py @@ -0,0 +1,267 @@ +""" +All 6 retinal detector connecting functions. +""" + + +INPUT_NEURONS_HEIGHT = 50 +INPUT_NEURONS_WIDTH = 50 + +DELAY = 1.0 + + +#----------setup connections for input to 1 3x3 on centre off surround detector +def set3x3OnConnections(X,Y): + excite = 25.0 + inhib = -2.0 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + inhib1 = (INPUT_NEURONS_WIDTH*(X-1))+Y-1 + inhib2 = (INPUT_NEURONS_WIDTH*(X-1))+Y + inhib3 = (INPUT_NEURONS_WIDTH*(X-1))+Y+1 + inhib4 = (INPUT_NEURONS_WIDTH*(X))+Y-1 + inhib6 = (INPUT_NEURONS_WIDTH*(X))+Y+1 + inhib7 = (INPUT_NEURONS_WIDTH*(X+1))+Y-1 + inhib8 = (INPUT_NEURONS_WIDTH*(X+1))+Y + inhib9 = (INPUT_NEURONS_WIDTH*(X+1))+Y+1 + connector = [ + (retinaNumber, retinaNumber, excite, DELAY), + (inhib1, retinaNumber, inhib, DELAY), + (inhib2, retinaNumber, inhib, DELAY), + (inhib3, retinaNumber, inhib, DELAY), + (inhib4, retinaNumber, inhib, DELAY), + (inhib6, retinaNumber, inhib, DELAY), + (inhib7, retinaNumber, inhib, DELAY), + (inhib8, retinaNumber, inhib, DELAY), + (inhib9, retinaNumber, inhib, DELAY), + ] + return connector; + +#----------setup connections for input to 1 3x3 off centre on surround detector +def set3x3OffConnections(X,Y): + excite = 4.0 + inhib = -25.0 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + surround1 = (INPUT_NEURONS_WIDTH*(X-1))+Y-1 + surround2 = (INPUT_NEURONS_WIDTH*(X-1))+Y + surround3 = (INPUT_NEURONS_WIDTH*(X-1))+Y+1 + surround4 = (INPUT_NEURONS_WIDTH*(X))+Y-1 + surround6 = (INPUT_NEURONS_WIDTH*(X))+Y+1 + surround7 = (INPUT_NEURONS_WIDTH*(X+1))+Y-1 + surround8 = (INPUT_NEURONS_WIDTH*(X+1))+Y + surround9 = (INPUT_NEURONS_WIDTH*(X+1))+Y+1 + connector = [ + (retinaNumber, retinaNumber, inhib, DELAY), + (surround1, retinaNumber, excite, DELAY), + (surround2, retinaNumber, excite, DELAY), + (surround3, retinaNumber, excite, DELAY), + (surround4, retinaNumber, excite, DELAY), + (surround6, retinaNumber, excite, DELAY), + (surround7, retinaNumber, excite, DELAY), + (surround8, retinaNumber, excite, DELAY), + (surround9, retinaNumber, excite, DELAY), + ] + return connector; + +#----------setup connections for input to 1 6x6 on centre off surround detector +def set6x6OnConnections(X,Y): + centreWeight = 7.0 + surroundWeight = -0.6 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + topLeftCentre = INPUT_NEURONS_WIDTH*(X)+ Y + connector = [ + (topLeftCentre, retinaNumber, centreWeight, DELAY), + (topLeftCentre+1, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+1,retinaNumber,centreWeight, DELAY) + ] + #rows above + for inpRow in range (X-2,X): + for inpCol in range (Y-2,Y+4): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + #left + newConnector = [ + (topLeftCentre-2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-1, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-1,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #right + newConnector = [ + (topLeftCentre+2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+3,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #rows below + for inpRow in range (X+2,X+4): + for inpCol in range (Y-2,Y+4): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + + return connector; + +#----------setup connections for input to 1 6x6 off centre on surround detector +def set6x6OffConnections(X,Y): + centreWeight = -6.0 + surroundWeight = 1.0 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + topLeftCentre = INPUT_NEURONS_WIDTH*(X)+ Y + connector = [ + (topLeftCentre, retinaNumber, centreWeight, DELAY), + (topLeftCentre+1, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+1,retinaNumber,centreWeight, DELAY) + ] + #rows above + for inpRow in range (X-2,X): + for inpCol in range (Y-2,Y+4): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + #left + newConnector = [ + (topLeftCentre-2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-1, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-1,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #right + newConnector = [ + (topLeftCentre+2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+3,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #rows below + for inpRow in range (X+2,X+4): + for inpCol in range (Y-2,Y+4): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + + return connector; + + +#----------setup connections for input to 1 9x9 on centre off surround detector +def set9x9OnConnections(X,Y): + centreWeight = 3.0 + surroundWeight = -0.25 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + topLeftCentre = INPUT_NEURONS_WIDTH*(X)+ Y + connector = [ + (topLeftCentre, retinaNumber, centreWeight, DELAY), + (topLeftCentre+1, retinaNumber, centreWeight, DELAY), + (topLeftCentre+2, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+1,retinaNumber,centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+2,retinaNumber,centreWeight, DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2),retinaNumber,centreWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+1,retinaNumber,centreWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+2,retinaNumber,centreWeight,DELAY), + ] + #rows above + for inpRow in range (X-3,X): + for inpCol in range (Y-3,Y+6): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector +# #left + newConnector = [ + (topLeftCentre-3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-1, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-1,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-1,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #right + newConnector = [ + (topLeftCentre+3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+4, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+5, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+4,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+5,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+4,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+5,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #rows below + for inpRow in range (X+3,X+6): + for inpCol in range (Y-3,Y+6): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + + return connector; + +#----------setup connections for input to 1 9x9 off centre on surround detector +def set9x9OffConnections(X,Y): + centreWeight = -2.5 + surroundWeight = 0.5 + retinaNumber = INPUT_NEURONS_WIDTH*(X)+ Y + topLeftCentre = INPUT_NEURONS_WIDTH*(X)+ Y + connector = [ + (topLeftCentre, retinaNumber, centreWeight, DELAY), + (topLeftCentre+1, retinaNumber, centreWeight, DELAY), + (topLeftCentre+2, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH, retinaNumber, centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+1,retinaNumber,centreWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+2,retinaNumber,centreWeight, DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2),retinaNumber,centreWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+1,retinaNumber,centreWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+2,retinaNumber,centreWeight,DELAY), + ] + #rows above + for inpRow in range (X-3,X): + for inpCol in range (Y-3,Y+6): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector +# #left + newConnector = [ + (topLeftCentre-3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-2, retinaNumber, surroundWeight, DELAY), + (topLeftCentre-1, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH-1,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-2,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)-1,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #right + newConnector = [ + (topLeftCentre+3, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+4, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+5, retinaNumber, surroundWeight, DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+4,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+INPUT_NEURONS_WIDTH+5,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+3,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+4,retinaNumber,surroundWeight,DELAY), + (topLeftCentre+(INPUT_NEURONS_WIDTH*2)+5,retinaNumber,surroundWeight,DELAY) + ] + connector = connector + newConnector + #rows below + for inpRow in range (X+3,X+6): + for inpCol in range (Y-3,Y+6): + inpCell = (inpRow*INPUT_NEURONS_WIDTH) + inpCol + newConnector = [(inpCell, retinaNumber, surroundWeight, DELAY)] + connector = connector + newConnector + + return connector; + + diff --git a/ChrisCabot/test.txt b/ChrisCabot/test.txt new file mode 100644 index 0000000..7cf7875 --- /dev/null +++ b/ChrisCabot/test.txt @@ -0,0 +1,276 @@ + +left fact +[, ] +right fact +[, ] +pyramid fact +[, ] +stalactite fact +[, ] + + +Pop Back + +[] + + +Pop Forward + +[] + + +Pop Turn Right + +[] + + +Pop Turn Left + +[] + +Process finished with exit code 0 +=============================IF_curr_exp=================== + +left fact +[, ] +right fact +[, ] +pyramid fact +[, ] +stalactite fact +[, ] + + +Pop Back + +[] + + +Pop Forward + +[] + + +Pop Turn Right + +[] + + +Pop Turn Left + +[] + + + +=================after setting the amplitude to 55 ============================ +left fact +[, ] +right fact +[, ] +pyramid fact +[, ] +stalactite fact +[, ] + + +Pop Back + +[] + + +Pop Forward + +[] + + +Pop Turn Right + +[] + + +Pop Turn Left + +[] diff --git a/ChrisCabot/v1Connections.py b/ChrisCabot/v1Connections.py new file mode 100755 index 0000000..b07f111 --- /dev/null +++ b/ChrisCabot/v1Connections.py @@ -0,0 +1,647 @@ +""" +Connections from the Retina to V1 +The hEdgeBottom, sEdgeLeft, bEdgeRight, andAngle, lessThanAngle, +greaterThanAngle, HedgeTop, sEdgeRight, bEdgeLeft and orAngle +Connection Functions +""" + +INPUT_NEURONS_HEIGHT = 50 +INPUT_NEURONS_WIDTH = 50 + +DELAY = 1.0 + +#----------setup connections 6x6 on to HEdgeBottom (bottom of a solid) +def set6x6OnToHEdgeBottomConnections(Col,Row): + weight = 4.0 + #don't input off top + if (Row == 0): return [] + #don't output off bottom + if (Row == INPUT_NEURONS_HEIGHT): return [] + connector = [] + toNeuron = (Row)*50+Col + startAddCol = Col-2 + if (startAddCol < 0): startAddCol = 0 + endAddCol = Col+3 + if (endAddCol > INPUT_NEURONS_WIDTH): endAddCol = INPUT_NEURONS_WIDTH + for addCol in range (startAddCol,endAddCol): + fromNeuron = ((Row-1)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + return connector + +#setup connections 6x6off to HEdgeBottom (bottom of a solid) +#2 on either side and self (5) up +def set6x6OffToHEdgeBottomConnections(Col,Row): + weight = 4.0 + #don't input off top + if (Row == 0): return [] + #don't output off bottom + if (Row == INPUT_NEURONS_HEIGHT): return [] + connector = [] + toNeuron = (Row)*50+Col + startAddCol = Col-2 + if (startAddCol < 0): startAddCol = 0 + endAddCol = Col+3 + if (endAddCol > INPUT_NEURONS_WIDTH): endAddCol = INPUT_NEURONS_WIDTH + for addCol in range (startAddCol,endAddCol): + fromNeuron = ((Row+1)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + return connector + +#setup connections 9x9off to HEdgeBottom (bottom of a solid) +#2 on either side and self (5) up one +def set9x9OffToHEdgeBottomConnections(Col,Row): + weight = 3.0 + #don't input off top + if (Row == 0): return [] + #don't output off bottom + if (Row == INPUT_NEURONS_HEIGHT): return [] + connector = [] + toNeuron = (Row)*50+Col + startAddCol = Col-2 + if (startAddCol < 0): startAddCol = 0 + endAddCol = Col+3 + if (endAddCol > INPUT_NEURONS_WIDTH): endAddCol = INPUT_NEURONS_WIDTH + for addCol in range (startAddCol,endAddCol): + fromNeuron = ((Row+1)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + return connector + +#----------setup connections 6x6 to SEdgeLeft (left of a solid) +#connections from self one to right then 3 above 2 below sloping +def set6x6OnToSEdgeLeftConnections(Col,Row): + if (Row <3): return [] + if (Row > INPUT_NEURONS_HEIGHT -3): return [] + if (Col < 2): return [] + if (Col > INPUT_NEURONS_WIDTH -4): return [] + + weight = 4.0 + inhibWeight = -4.0 # inhibit right sEdges well to the rigft + toNeuron = (Row)*50+Col + row1Off = (Row-3)*INPUT_NEURONS_WIDTH + Col+3 + row1Left = (Row-3)*INPUT_NEURONS_WIDTH + Col+2 + row1Right = (Row-3)*INPUT_NEURONS_WIDTH + Col+1 + row2Off = (Row-2)*INPUT_NEURONS_WIDTH + Col+2 + row2Left = (Row-2)*INPUT_NEURONS_WIDTH + Col+1 + row2Right = (Row-2)*INPUT_NEURONS_WIDTH + Col + row3Off = (Row-1)*INPUT_NEURONS_WIDTH + Col+2 + row3Left = (Row-1)*INPUT_NEURONS_WIDTH + Col+1 + row3Right = (Row-1)*INPUT_NEURONS_WIDTH + Col + ownRowOff = Row*INPUT_NEURONS_WIDTH + Col+1 + ownRowLeft = toNeuron + ownRowRight = toNeuron - 1 + row5Off = (Row+1)*INPUT_NEURONS_WIDTH + Col+1 + row5Left = (Row+1)*INPUT_NEURONS_WIDTH + Col + row5Right = (Row+1)*INPUT_NEURONS_WIDTH + Col-1 + row6Off = (Row+2)*INPUT_NEURONS_WIDTH + Col + row6Left = (Row+2)*INPUT_NEURONS_WIDTH + Col-1 + row6Right = (Row+2)*INPUT_NEURONS_WIDTH + Col-2 + connector = [ + (row1Off, toNeuron, inhibWeight, DELAY), + (row1Left, toNeuron, weight, DELAY), + (row1Right, toNeuron, weight, DELAY), + (row2Off, toNeuron, inhibWeight, DELAY), + (row2Left, toNeuron, weight, DELAY), + (row2Right, toNeuron, weight, DELAY), + (row3Off, toNeuron, inhibWeight, DELAY), + (row3Left, toNeuron, weight, DELAY), + (row3Right, toNeuron, weight, DELAY), + (ownRowOff, toNeuron, inhibWeight, DELAY), + (ownRowLeft, toNeuron, weight, DELAY), + (ownRowRight, toNeuron, weight, DELAY), + (row5Off, toNeuron, inhibWeight, DELAY), + (row5Left, toNeuron, weight, DELAY), + (row5Right, toNeuron, weight, DELAY), + (row6Off, toNeuron, inhibWeight, DELAY), + (row6Left, toNeuron, weight, DELAY), + (row6Right, toNeuron, weight, DELAY)] + return connector + + +#----------setup connections BEdgeRight \(on right of a solid) +#setup connections 3x3 on to BEdgeRight (right of a solid) +#connections from self one to left then 3 above 2 below sloping +def set3x3OnAndOffToBEdgeRightConnections(Col,Row): + if (Row < 3): return [] + if (Row > INPUT_NEURONS_HEIGHT -3): return [] + if (Col < 3): return [] + if (Col > INPUT_NEURONS_WIDTH -3): return [] + + weight = 6.0 + inhibWeight = -4.0 # inhibit things well to the left + toNeuron = (Row)*50+Col + row1Off = (Row-3)*INPUT_NEURONS_WIDTH + Col-3 + row1Left = (Row-3)*INPUT_NEURONS_WIDTH + Col-2 + row1Right = (Row-3)*INPUT_NEURONS_WIDTH + Col-1 + row2Off = (Row-2)*INPUT_NEURONS_WIDTH + Col-2 + row2Left = (Row-2)*INPUT_NEURONS_WIDTH + Col-1 + row2Right = (Row-2)*INPUT_NEURONS_WIDTH + Col + row3Off = (Row-1)*INPUT_NEURONS_WIDTH + Col-2 + row3Left = (Row-1)*INPUT_NEURONS_WIDTH + Col-1 + row3Right = (Row-1)*INPUT_NEURONS_WIDTH + Col + ownRowOff = Row*INPUT_NEURONS_WIDTH + Col-1 + ownRowLeft = toNeuron + ownRowRight = toNeuron + 1 + row5Off = (Row+1)*INPUT_NEURONS_WIDTH + Col-1 + row5Left = (Row+1)*INPUT_NEURONS_WIDTH + Col + row5Right = (Row+1)*INPUT_NEURONS_WIDTH + Col+1 + row6Off = (Row+2)*INPUT_NEURONS_WIDTH + Col + row6Left = (Row+2)*INPUT_NEURONS_WIDTH + Col+1 + row6Right = (Row+2)*INPUT_NEURONS_WIDTH + Col+2 + connector = [ + (row1Off, toNeuron, inhibWeight, DELAY), + (row1Left, toNeuron, weight, DELAY), + (row1Right, toNeuron, weight, DELAY), + (row2Off, toNeuron, inhibWeight, DELAY), + (row2Left, toNeuron, weight, DELAY), + (row2Right, toNeuron, weight, DELAY), + (row3Off, toNeuron, inhibWeight, DELAY), + (row3Left, toNeuron, weight, DELAY), + (row3Right, toNeuron, weight, DELAY), + (ownRowOff, toNeuron, inhibWeight, DELAY), + (ownRowLeft, toNeuron, weight, DELAY), + (ownRowRight, toNeuron, weight, DELAY), + (row5Off, toNeuron, inhibWeight, DELAY), + (row5Left, toNeuron, weight, DELAY), + (row5Right, toNeuron, weight, DELAY), + (row6Off, toNeuron, inhibWeight, DELAY), + (row6Left, toNeuron, weight, DELAY), + (row6Right, toNeuron, weight, DELAY)] + return connector + +#setup connections 6x6 off to BEdgeRight (right of a solid) +#connections from self one to left then 3 above 2 below sloping +def set6x6OffToBEdgeRightConnections(Col,Row): + if (Row < 3): return [] + if (Row > INPUT_NEURONS_HEIGHT -3): return [] + if (Col < 3): return [] + if (Col > INPUT_NEURONS_WIDTH -3): return [] + + weight = 6.0 + inhibWeight = -4.0 # inhibit things well to the left + toNeuron = (Row)*50+Col + row1Off = (Row-3)*INPUT_NEURONS_WIDTH + Col-3 + row1Left = (Row-3)*INPUT_NEURONS_WIDTH + Col-2 + row1Right = (Row-3)*INPUT_NEURONS_WIDTH + Col-1 + row2Off = (Row-2)*INPUT_NEURONS_WIDTH + Col-2 + row2Left = (Row-2)*INPUT_NEURONS_WIDTH + Col-1 + row2Right = (Row-2)*INPUT_NEURONS_WIDTH + Col + row3Off = (Row-1)*INPUT_NEURONS_WIDTH + Col-2 + row3Left = (Row-1)*INPUT_NEURONS_WIDTH + Col-1 + row3Right = (Row-1)*INPUT_NEURONS_WIDTH + Col + ownRowOff = Row*INPUT_NEURONS_WIDTH + Col-1 + ownRowLeft = toNeuron + ownRowRight = toNeuron + 1 + row5Off = (Row+1)*INPUT_NEURONS_WIDTH + Col-1 + row5Left = (Row+1)*INPUT_NEURONS_WIDTH + Col + row5Right = (Row+1)*INPUT_NEURONS_WIDTH + Col+1 + row6Off = (Row+2)*INPUT_NEURONS_WIDTH + Col + row6Left = (Row+2)*INPUT_NEURONS_WIDTH + Col+1 + row6Right = (Row+2)*INPUT_NEURONS_WIDTH + Col+2 + connector = [ + (row1Off, toNeuron, inhibWeight, DELAY), + (row1Left, toNeuron, weight, DELAY), + (row1Right, toNeuron, weight, DELAY), + (row2Off, toNeuron, inhibWeight, DELAY), + (row2Left, toNeuron, weight, DELAY), + (row2Right, toNeuron, weight, DELAY), + (row3Off, toNeuron, inhibWeight, DELAY), + (row3Left, toNeuron, weight, DELAY), + (row3Right, toNeuron, weight, DELAY), + (ownRowOff, toNeuron, inhibWeight, DELAY), + (ownRowLeft, toNeuron, weight, DELAY), + (ownRowRight, toNeuron, weight, DELAY), + (row5Off, toNeuron, inhibWeight, DELAY), + (row5Left, toNeuron, weight, DELAY), + (row5Right, toNeuron, weight, DELAY), + (row6Off, toNeuron, inhibWeight, DELAY), + (row6Left, toNeuron, weight, DELAY), + (row6Right, toNeuron, weight, DELAY)] + return connector + + +#----------setup connections 3x3 on to And Angle +#connections from self to own and above row and on either side for 6 in total +#inhibit below +def set3x3OnToAndAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT -2): return [] + if (Row < 1): return [] + if (Col < 1): return [] + if (Col > INPUT_NEURONS_WIDTH-2): return [] + + weight = 5.0 + inhibWeight = -5.0 + + toNeuron = (Row*50)+Col + connector = [(toNeuron-INPUT_NEURONS_WIDTH-1,toNeuron,inhibWeight,DELAY), + (toNeuron-INPUT_NEURONS_WIDTH,toNeuron,inhibWeight,DELAY), + (toNeuron-INPUT_NEURONS_WIDTH+1,toNeuron,inhibWeight,DELAY) + ] + for addRow in range (Row,Row+2): + for addCol in range (Col-1,Col+2): + fromNeuron = ((addRow)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + return connector + +#setup connections 6x6 on to And Angle +#connections from self to own and above rows and on either side for 6 in total +#inhib two below on either side (60 +def set6x6OnToAndAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT -2): return [] + if (Row < 2): return [] + if (Col < 1): return [] + if (Col > INPUT_NEURONS_WIDTH-2): return [] + + weight = 4.0 + inhibWeight = -5.0 + + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row,Row+2): + for addCol in range (Col-1,Col+2): + fromNeuron = ((addRow)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + for addRow in range (Row-2,Row-1): + for addCol in range (Col-1,Col+2): + fromNeuron = ((addRow)*50)+addCol + newConnector = [(fromNeuron, toNeuron, inhibWeight, DELAY)] + connector = connector + newConnector + return connector + +#setup connections 9x9 on to And Angle +#connections from self to above two rows and on either side for 6 in total +#inhib own row +def set9x9OnToAndAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT -3): return [] + if (Col < 1): return [] + if (Col > INPUT_NEURONS_WIDTH-2): return [] + + weight = 4.0 + inhibWeight = -8.0 + + toNeuron = (Row*50)+Col + connector = [(toNeuron-1,toNeuron,inhibWeight,DELAY), + (toNeuron,toNeuron,inhibWeight,DELAY), + (toNeuron+1,toNeuron,inhibWeight,DELAY) + ] + for addRow in range (Row+1,Row+3): + for addCol in range (Col-1,Col+2): + fromNeuron = ((addRow)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + + return connector + +#-----setup connections 3x3 on to Less Than Angle +#connections from self and two left self and two two below (9) one inhib right of that. (3) +def set3x3OnToLessThanAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT-4): return [] #don't go off bottom + if (Col < 2): return [] #don't go off left + + weight = 6.0 + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row,Row+3): + fromNeuron = ((addRow)*50)+Col + newConnectors = [(fromNeuron -1, toNeuron, weight, DELAY), + (fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + +#connect 6x6off from self and one one right self and two below (6) one inhib right of that. (3) +def set6x6OffToLessThanAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT-4): return [] #don't go off bottom + if (Col < 1): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH -2): return [] #don't go off right + + weight = 5.0 + inhibWeight = -10.0 + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row,Row+3): + fromNeuron = ((addRow)*50)+Col + newConnectors = [(fromNeuron-1, toNeuron, inhibWeight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + +#connect 9x9on from one left self and two below(4) one inhib right of that(2). +def set9x9OnToLessThanAngleConnections(Col,Row): + if (Row < 2): return [] #don't go off bottom + if (Col < 1): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-1): return [] #don't go off right + + weight = 6.0 + inhibWeight = -6.0 + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row-3,Row-1): + fromNeuron = ((addRow)*50)+Col + newConnectors = [(fromNeuron-1, toNeuron, inhibWeight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + +#----------setup connections 3x3 on to Greater Than Angle +#conns from self and two right above and below (9) +def set3x3OnToGreaterThanAngleConnections(Col,Row): + if (Row < 1): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-2): return [] #don't go off bottom + if (Col > INPUT_NEURONS_WIDTH-3): return [] #don't go off right + + weight = 9.0 + + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row-1,Row+2): + fromNeuron = ((addRow)*50)+Col + newConnector = [(fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY), + (fromNeuron+2, toNeuron, weight, DELAY) + ] + connector = connector + newConnector + return connector + +#connect 6x6off connect two to right inhib self two rows above (4,2) +def set6x6OffToGreaterThanAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT-3): return [] #don't go off bottom + if (Col < 2): return [] #don't go off left + + weight = 4.0 + inhibWeight = -9.0 + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row+1,Row+3): + fromNeuron = ((addRow)*50)+Col + newConnector = [(fromNeuron, toNeuron, inhibWeight, DELAY), + (fromNeuron-1, toNeuron, weight, DELAY), + (fromNeuron-2, toNeuron, weight, DELAY) + ] + connector = connector + newConnector + return connector + + +#connect 9x9on from left two, inhib from self two rows above (4,2) +def set9x9OnToGreaterThanAngleConnections(Col,Row): + if (Row < 3): return [] #don't go off top + if (Col < 2): return [] #don't go off left + + weight = 4.0 + inhibWeight = -9.0 + + toNeuron = (Row*50)+Col + connector = [] + for addRow in range (Row-2,Row): + fromNeuron = ((addRow)*50)+Col + newConnectors = [(fromNeuron-2, toNeuron, weight, DELAY), + (fromNeuron-1, toNeuron, weight, DELAY), + (fromNeuron, toNeuron, inhibWeight, DELAY)] + connector = connector + newConnectors + return connector + + +#---------Connections for Stalactite V1 detectors +#----------setup connections 6x6off to HEdgeTop (top of a solid) +#one above and 2 on either side for 5 +def set6x6OffToHEdgeTopConnections(Col,Row): + weight = 10.0 + #don't output off bottom + if (Row == INPUT_NEURONS_HEIGHT): return [] + connector = [] + toNeuron = (Row)*50+Col + startAddCol = Col-2 + if (startAddCol < 0): startAddCol = 0 + endAddCol = Col+3 + if (endAddCol > INPUT_NEURONS_WIDTH): endAddCol = INPUT_NEURONS_WIDTH + for addCol in range (startAddCol,endAddCol): + fromNeuron = ((Row+1)*50)+addCol + newConnector = [(fromNeuron, toNeuron, weight, DELAY)] + connector = connector + newConnector + return connector + +#setup connections 9x9 off to HEdgeTop (top of a solid) +#positiive to same space, inhibit below +def set9x9OffToHEdgeTopConnections(Col,Row): + weight = 5.0 + inhibWeight = -10 + #don't output off bottom + if (Row == INPUT_NEURONS_HEIGHT): return [] + connector = [] + toNeuron = (Row)*50+Col + fromNeuron = (Row*50)+Col + connector = [(fromNeuron, toNeuron, weight, DELAY)] + fromNeuron = ((Row+1)*50)+Col + newConnector = [(fromNeuron, toNeuron, inhibWeight, DELAY)] + connector = connector + newConnector + return connector + +#----------setup connections to SEdgeRight (right of a solid) +#set up connections from 3x3on to SEdgeRight\ +#the right of a solid. Have connections from three above, own and below row. +#Each has two excite on right and one inhib on left. One right above one left +#below. (6,3) +def set3x3OnToSEdgeRightConnections(Col,Row): + if (Row < 4): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-5): return [] #don't go off bottom + if (Col < 4): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-5): return [] #don't go off right + + weight = 5.0 + inhibWeight = -5.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (-3,4): + fromNeuron = ((Row+addRow)*50)+(Col-addRow) + if (addRow == -3): + fromNeuron = fromNeuron-1 + newConnectors = [(fromNeuron -1, toNeuron, inhibWeight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + +#Set up connections from 3x3off to SEdgeRight\ +#the right of a solid. Have connections from above, own and below row. +#Each has two excite on right and one inhib on left. One right above one left +#below. (6,3) +def set3x3OffToSEdgeRightConnections(Col,Row): + if (Row < 2): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-3): return [] #don't go off bottom + if (Col < 2): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-3): return [] #don't go off right + + weight = 5.0 + inhibWeight = -5.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-1,Row+2): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row +1): + fromNeuron = fromNeuron-1 + else: + if (addRow == Row -1): + fromNeuron = fromNeuron+1 + newConnectors = [(fromNeuron -1, toNeuron, inhibWeight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + +#6x6off to SEdgeRight the right of a solid. Have connections from three above, +#own and below row. Each has two excite on right and one inhib on left. +#One right above one left below. (6,3) +def set6x6OffToSEdgeRightConnections(Col,Row): + if (Row < 4): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-5): return [] #don't go off bottom + if (Col < 4): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-5): return [] #don't go off right + + weight = 4.0 + inhibWeight = -5.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (-3,4): + fromNeuron = ((Row+addRow)*50)+(Col-addRow) + if (addRow == -3): + fromNeuron = fromNeuron-1 + newConnectors = [(fromNeuron -1, toNeuron, inhibWeight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, weight, DELAY)] + connector = connector + newConnectors + return connector + + +#----------setup connections to BEdgeLeft \ (left of a solid) +#set up connections from 3x3on, and 3x3off to BEdgeLeft\ +#the left of a solid. Have connections from above, own and below row. +#Each has two excite on left and one inhib on right. One left above one right +#below. (6,3) +def set3x3OnAndOffToBEdgeLeftConnections(Col,Row): + if (Row < 2): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-3): return [] #don't go off bottom + if (Col < 2): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-3): return [] #don't go off right + + weight = 10.0 + inhibWeight = -5.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-1,Row+2): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row +1): + fromNeuron = fromNeuron+1 + else: + if (addRow == Row -1): + fromNeuron = fromNeuron-1 + newConnectors = [(fromNeuron -1, toNeuron, weight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, inhibWeight, DELAY)] + connector = connector + newConnectors + return connector + + +#6x6off to BEdgeLeft the left of a solid. Have connections from above, own +#and below row. Each has two excite on left and one inhib on right. +#One left above one right below. (6,3) +def set6x6OffToBEdgeLeftConnections(Col,Row): + if (Row < 2): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-3): return [] #don't go off bottom + if (Col < 2): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-3): return [] #don't go off right + + weight = 3.0 + inhibWeight = -5.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-1,Row+2): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row +1): + fromNeuron = fromNeuron+1 + else: + if (addRow == Row -1): + fromNeuron = fromNeuron-1 + newConnectors = [(fromNeuron -1, toNeuron, weight, DELAY), + (fromNeuron, toNeuron, weight, DELAY), + (fromNeuron+1, toNeuron, inhibWeight, DELAY)] + connector = connector + newConnectors + return connector + +#----------setup connections 3x3 on to or angle +#Connections from left, self and right, from above,self and down one, +#inhib one more down(9,3) +def set3x3OnToOrAngleConnections(Col,Row): + if (Row < 1): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-4): return [] #don't go off bottom + if (Col < 1): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-2): return [] #don't go off right + + weight = 7.0 + inhibWeight = -9.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-1,Row+3): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row +2): + connWeight = inhibWeight + else: + connWeight = weight + newConnectors = [(fromNeuron -1, toNeuron, connWeight, DELAY), + (fromNeuron, toNeuron, connWeight, DELAY), + (fromNeuron+1, toNeuron, connWeight, DELAY)] + connector = connector + newConnectors + return connector + + +#----------setup connections 6x6 on to or angle +#Connections from left, self and right, from two above, inhib own row (6,3) +def set6x6OnToOrAngleConnections(Col,Row): + if (Row < 1): return [] #don't go off top + if (Row > INPUT_NEURONS_HEIGHT-3): return [] #don't go off bottom + if (Col < 1): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-2): return [] #don't go off right + + weight = 3.0 + inhibWeight = -3.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-2,Row+1): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row): + connWeight = inhibWeight + else: + connWeight = weight + newConnectors = [(fromNeuron -1, toNeuron, connWeight, DELAY), + (fromNeuron, toNeuron, connWeight, DELAY), + (fromNeuron+1, toNeuron, connWeight, DELAY)] + connector = connector + newConnectors + return connector + + +#----------setup connections 9x9on to or angle +#Connections from left, self and right, from three above, inhib from one above (6,3) +def set9x9OnToOrAngleConnections(Col,Row): + if (Row > INPUT_NEURONS_HEIGHT-4): return [] #don't go off bottom + if (Col < 1): return [] #don't go off left + if (Col > INPUT_NEURONS_WIDTH-2): return [] #don't go off right + + weight = 3.0 + inhibWeight = -3.0 + toNeuron = (Row)*50+Col + connector = [] + for addRow in range (Row-3,Row): + fromNeuron = ((addRow)*50)+Col + if (addRow == Row-1): + connWeight = inhibWeight + else: + connWeight = weight + newConnectors = [(fromNeuron -1, toNeuron, connWeight, DELAY), + (fromNeuron, toNeuron, connWeight, DELAY), + (fromNeuron+1, toNeuron, connWeight, DELAY)] + connector = connector + newConnectors + return connector diff --git a/ChrisCabot/visionClass.py b/ChrisCabot/visionClass.py new file mode 100644 index 0000000..5324d59 --- /dev/null +++ b/ChrisCabot/visionClass.py @@ -0,0 +1,471 @@ +#imports for PyNN +from pyNN.nest import * +from retinaConnections import set3x3OnConnections,set3x3OffConnections +from retinaConnections import set6x6OnConnections, set6x6OffConnections +from retinaConnections import set9x9OnConnections,set9x9OffConnections +from v1Connections import set6x6OnToHEdgeBottomConnections, set6x6OffToHEdgeBottomConnections +from v1Connections import set9x9OffToHEdgeBottomConnections +from v1Connections import set6x6OnToSEdgeLeftConnections +from v1Connections import set3x3OnAndOffToBEdgeRightConnections, set6x6OffToBEdgeRightConnections +from v1Connections import set3x3OnToAndAngleConnections,set6x6OnToAndAngleConnections +from v1Connections import set9x9OnToAndAngleConnections +from v1Connections import set3x3OnToLessThanAngleConnections,set6x6OffToLessThanAngleConnections +from v1Connections import set9x9OnToLessThanAngleConnections +from v1Connections import set3x3OnToGreaterThanAngleConnections,set6x6OffToGreaterThanAngleConnections +from v1Connections import set9x9OnToGreaterThanAngleConnections +from v1Connections import set6x6OffToHEdgeTopConnections, set9x9OffToHEdgeTopConnections +from v1Connections import set3x3OnToSEdgeRightConnections, set3x3OffToSEdgeRightConnections +from v1Connections import set6x6OffToSEdgeRightConnections +from v1Connections import set3x3OnAndOffToBEdgeLeftConnections, set6x6OffToBEdgeLeftConnections +from v1Connections import set3x3OnToOrAngleConnections, set6x6OnToOrAngleConnections +from v1Connections import set9x9OnToOrAngleConnections +from objRecConnections import connectCA +from objRecConnections import connectHEdgeBottomToPyramid, connectSEdgeLeftToPyramid +from objRecConnections import connectBEdgeRightToPyramid, connectAndAngleToPyramid +from objRecConnections import connectLessThanAngleToPyramid, connectGreaterThanAngleToPyramid +from objRecConnections import connectHEdgeTopToStalactite, connectSEdgeRightToStalactite +from objRecConnections import connectBEdgeLeftToStalactite, connectOrAngleToStalactite + + + +INPUT_NEURONS_HEIGHT = 50 +INPUT_NEURONS_WIDTH = 50 +cInputNeurons = INPUT_NEURONS_HEIGHT * INPUT_NEURONS_WIDTH + +class visionArea: + + def printPopulationFirings(self,receptorPop): + totalNeurons = INPUT_NEURONS_HEIGHT*INPUT_NEURONS_WIDTH + for neuronNum in range (0,totalNeurons-1): + if (neuronNum < totalNeurons): + outAssembly = Assembly(receptorPop[neuronNum,(neuronNum+1)]) + else: + outAssembly = Assembly(receptorPop[neuronNum,0]) + outDat = outAssembly.get_data() + seg = outDat.segments[0] + spikeTrains = seg.spiketrains + if len(spikeTrains) > 0: + times = spikeTrains[0].times + if len(times) > 0: + print neuronNum, len(times), + for time in times: + base = time.base + print base, + print " " + + def printReceptors(self): + print "3x3 On" + self.printPopulationFirings(self.retina3x3OnPop) + print "3x3 Off" + self.printPopulationFirings(self.retina3x3OffPop) + print "6x6 On" + self.printPopulationFirings(self.retina6x6OnPop) + print "6x6 Off" + self.printPopulationFirings(self.retina6x6OffPop) + print "9x9 On" + self.printPopulationFirings(self.retina9x9OnPop) + print "9x9 Off" + self.printPopulationFirings(self.retina9x9OffPop) + + def printV1(self): + print "HEdgeBottom" + self.printPopulationFirings(self.v1HEdgeBottomPop) + print "SEdgeRight" + self.printPopulationFirings(self.v1SEdgeRightPop) + print "BEdgeLeft" + self.printPopulationFirings(self.v1BEdgeLeftPop) + print "AndAngle" + self.printPopulationFirings(self.v1AndAnglePop) + print "LessThanAngle" + self.printPopulationFirings(self.v1LessThanAnglePop) + print "GreaterThanAngle" + self.printPopulationFirings(self.v1GreaterThanAnglePop) + + def printVisionNets(self): + print "Long Print Vision Nets" + self.printReceptors() + self.printV1() + + #---create neurons + def allocateNeurons(self): + #default a .02, b .2, c -65, d 2.0, i_offset 0 + # inp_cell_params = {'a' : 0.0, 'b' :0.2, 'c' : -65, 'd' : 0.0} + inp_cell_params = {} + self.inpPop = Population(cInputNeurons,IF_curr_exp(**inp_cell_params)) + # self.inpPop.initialize(v=-58.0) + + #create retinal neurons off centre different than on centre + # retina_cell_params = {'a' : 0.2, 'b' :0.2, 'c' : -65, 'd' : 2.0} + retina_cell_params = {} + self.retina3x3OnPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + self.retina6x6OnPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + self.retina9x9OnPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + + # retina_cell_params = {'a' : 0.2, 'b' :0.2, 'c' : -65, 'd' : 2.0,'i_offset':1.0} + retina_cell_params = {} + self.retina3x3OffPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + self.retina9x9OffPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + + # retina_cell_params = {'a' : 0.2, 'b' :0.2, 'c' : -65, 'd' : 2.0,'i_offset':2.0} + retina_cell_params = {} + self.retina6x6OffPop = Population(cInputNeurons,IF_curr_exp(**retina_cell_params)) + + def allocateV1Neurons(self): + #create V1 neurons + # V1_c_p = {'a' : 0.2, 'b' :0.2, 'c' : -65, 'd' : 2.0} + V1_c_p = {} + self.v1HEdgeBottomPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1SEdgeLeftPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1BEdgeRightPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1AndAnglePop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1LessThanAnglePop=Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1GreaterThanAnglePop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1HEdgeTopPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1SEdgeRightPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1BEdgeLeftPop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + self.v1OrAnglePop = Population(cInputNeurons,IF_curr_exp(**V1_c_p)) + + def allocateObjRecNeurons(self): + #create object recognition neurons + # obj_c_p = {'a' : 0.02,'i_offset' : 2} + obj_c_p = {} + self.pyramidPop = Population(cInputNeurons,IF_curr_exp(**obj_c_p)) + self.stalactitePop = Population(cInputNeurons,IF_curr_exp(**obj_c_p)) + + def allocateVisionNeurons(self): + self.allocateNeurons() + self.allocateV1Neurons() + self.allocateObjRecNeurons() + + + #----------------setup input to retina connections + def makeInputToRetSynapses(self): + print "Make Input to Retina Synapses" + synapseArray = [] + #3x3On + for row in range (1,49): + for col in range (1,49): + newSynapses = set3x3OnConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina3x3OnPop,FromListConnector(synapseArray),StaticSynapse()) + + #3x3Off + synapseArray = [] + for row in range (1,49): + for col in range (1,49): + newSynapses = set3x3OffConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina3x3OffPop,FromListConnector(synapseArray),StaticSynapse()) + + #6x6On + synapseArray = [] + for row in range (2,47): + for col in range (2,47): + newSynapses = set6x6OnConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina6x6OnPop,FromListConnector(synapseArray),StaticSynapse()) + + #6x6Off + synapseArray = [] + for row in range (2,47): + for col in range (2,47): + newSynapses = set6x6OffConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina6x6OffPop,FromListConnector(synapseArray),StaticSynapse()) + + #9x9Off + synapseArray = [] + for row in range (3,45): + for col in range (3,45): + newSynapses = set9x9OffConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina9x9OffPop,FromListConnector(synapseArray),StaticSynapse()) + + #9x9On + synapseArray = [] + for row in range (3,45): + for col in range (3,45): + newSynapses = set9x9OnConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.inpPop,self.retina9x9OnPop,FromListConnector(synapseArray),StaticSynapse()) + + #-------------------setup retina to V1 connections--- + def makeRetToV1Synapses(self): + print "Make synapses from Ret to V1" + #HedgeBottom + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (2,INPUT_NEURONS_HEIGHT-3): + newSynapses = set6x6OnToHEdgeBottomConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OnPop,self.v1HEdgeBottomPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (2,INPUT_NEURONS_HEIGHT-3): + newSynapses = set6x6OffToHEdgeBottomConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1HEdgeBottomPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (2,INPUT_NEURONS_HEIGHT-3): + newSynapses = set9x9OffToHEdgeBottomConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OffPop,self.v1HEdgeBottomPop,FromListConnector(synapseArray),StaticSynapse()) + + #SEdge Left Connections + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OnToSEdgeLeftConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OnPop,self.v1SEdgeLeftPop,FromListConnector(synapseArray),StaticSynapse()) + Projection(self.retina6x6OffPop,self.v1SEdgeLeftPop,FromListConnector(synapseArray),StaticSynapse()) + + #rightBEdges + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set3x3OnAndOffToBEdgeRightConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1BEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + Projection(self.retina3x3OffPop,self.v1BEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OffToBEdgeRightConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1BEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + + #andAngle + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set3x3OnToAndAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1AndAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OnToAndAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OnPop,self.v1AndAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set9x9OnToAndAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OnPop,self.v1AndAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + #Less Than Angle + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set3x3OnToLessThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1LessThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OffToLessThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1LessThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set9x9OnToLessThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OnPop,self.v1LessThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + #Greater Than Angle + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set3x3OnToGreaterThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1GreaterThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OffToGreaterThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1GreaterThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set9x9OnToGreaterThanAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OnPop,self.v1GreaterThanAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + #topHEdges + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set6x6OffToHEdgeTopConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1HEdgeTopPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set9x9OffToHEdgeTopConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OffPop,self.v1HEdgeTopPop,FromListConnector(synapseArray),StaticSynapse()) + + #right SEdges + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set3x3OnToSEdgeRightConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1SEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set3x3OffToSEdgeRightConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OffPop,self.v1SEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set6x6OffToSEdgeRightConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1SEdgeRightPop,FromListConnector(synapseArray),StaticSynapse()) + + #left BEdges + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set3x3OnAndOffToBEdgeLeftConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1BEdgeLeftPop,FromListConnector(synapseArray),StaticSynapse()) + Projection(self.retina3x3OffPop,self.v1BEdgeLeftPop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set6x6OffToBEdgeLeftConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OffPop,self.v1BEdgeLeftPop,FromListConnector(synapseArray),StaticSynapse()) + + #or Angle + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set3x3OnToOrAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina3x3OnPop,self.v1OrAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT): + for col in range (0,INPUT_NEURONS_WIDTH): + newSynapses = set6x6OnToOrAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina6x6OnPop,self.v1OrAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + synapseArray = [] + for row in range (0,INPUT_NEURONS_HEIGHT-1): + for col in range (0,INPUT_NEURONS_HEIGHT): + newSynapses = set9x9OnToOrAngleConnections(col,row) + synapseArray = synapseArray + newSynapses + Projection(self.retina9x9OnPop,self.v1OrAnglePop,FromListConnector(synapseArray),StaticSynapse()) + + #-------------------setup Object Recognion and V1 to ObjRec connections--- + def makeV1ToObjRecSynapses(self): + print "Make V1 to Object Recognition Synapses" + + #setup pyramid CAs + synapseArray = [] + for cCA in range (0,25): + newSynapses = connectCA(cCA) + synapseArray = synapseArray + newSynapses + Projection(self.pyramidPop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #HEdge to Pyramid + synapseArray = connectHEdgeBottomToPyramid() + Projection(self.v1HEdgeBottomPop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #SEdge to Pyramid + synapseArray = connectSEdgeLeftToPyramid() + Projection(self.v1SEdgeRightPop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #BEdge to Pyramid + synapseArray = connectBEdgeRightToPyramid() + Projection(self.v1BEdgeLeftPop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #And to Pyramid + synapseArray = connectAndAngleToPyramid() + Projection(self.v1AndAnglePop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #Less Than Angle to Pyramid + synapseArray = connectLessThanAngleToPyramid() + Projection(self.v1LessThanAnglePop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #Greater Than Angle to Pyramid + synapseArray = connectGreaterThanAngleToPyramid() + Projection(self.v1GreaterThanAnglePop,self.pyramidPop,FromListConnector(synapseArray),StaticSynapse()) + + #---------------setup stalactite CAs + synapseArray = [] + for cCA in range (0,25): + newSynapses = connectCA(cCA) + synapseArray = synapseArray + newSynapses + Projection(self.stalactitePop,self.stalactitePop,FromListConnector(synapseArray),StaticSynapse()) + + #HEdge to Stalactite + synapseArray = connectHEdgeTopToStalactite() + Projection(self.v1HEdgeTopPop,self.stalactitePop,FromListConnector(synapseArray),StaticSynapse()) + + #sEdge to Stalactite + synapseArray = connectSEdgeRightToStalactite() + Projection(self.v1SEdgeRightPop,self.stalactitePop,FromListConnector(synapseArray),StaticSynapse()) + + #bEdge to Stalactite + synapseArray = connectBEdgeLeftToStalactite() + Projection(self.v1BEdgeLeftPop,self.stalactitePop,FromListConnector(synapseArray),StaticSynapse()) + + #orAngle to Stalactite + synapseArray = connectOrAngleToStalactite() + Projection(self.v1OrAnglePop,self.stalactitePop,FromListConnector(synapseArray),StaticSynapse()) + + def makeVisionSynapses(self): + self.makeInputToRetSynapses() + self.makeRetToV1Synapses() + self.makeV1ToObjRecSynapses() + + + def setVisionRecording(self): + self.retina3x3OffPop.record(['spikes','v']) + self.retina3x3OffPop.record(['spikes','v']) + self.retina6x6OnPop.record(['spikes','v']) + self.retina6x6OffPop.record(['spikes','v']) + self.retina9x9OnPop.record(['spikes','v']) + self.retina9x9OffPop.record(['spikes','v']) + self.v1HEdgeBottomPop.record(['spikes','v']) + self.v1SEdgeRightPop.record(['spikes','v']) + self.v1BEdgeLeftPop.record(['spikes','v']) + self.v1AndAnglePop.record(['spikes','v']) + self.v1LessThanAnglePop.record(['spikes','v']) + self.v1GreaterThanAnglePop.record(['spikes','v']) + self.pyramidPop.record(['spikes','v']) + self.stalactitePop.record(['spikes','v']) + + + def getInputPopulation(self): + return self.inpPop + + def getPyramidPopulation(self): + return self.pyramidPop + + def getStalactitePopulation(self): + return self.stalactitePop