~mwshinn/+junk/structure

« back to all changes in this revision

Viewing changes to Ca_V1_Grid.py

  • Committer: Max Shinn
  • Date: 2013-07-11 13:06:00 UTC
  • Revision ID: trombonechamp@gmail.com-20130711130600-i6b3yljhe80pqse3
BetterĀ real-timeĀ plotting

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
 
126
126
        #Plot results in real time
127
127
        if plot_results > 0 and i%plot_results_interval==0:
128
 
            weights_list = net.projection(pre='LGN', post='V1_Simple').values
129
 
            nrows = 5#ceil(sqrt(len(weights_list)))
 
128
            # weights_list is an array of arrayes.  The first
 
129
            # dimension reresents the index of the postsynaptic
 
130
            # neuron, and the second the presynaptic.  The layers are
 
131
            # concatenated.
 
132
            weights_list = numpy.array(net.projection(pre='LGN', post='V1_Simple').values)
 
133
            ndims = 2 # Number of layers/depth in the LGN
 
134
            fielddim = int(sqrt(int(len(weights_list[0])/ndims))) # This is the visualized image's length/width, or receptive field dimentions.  This assumes it is a square, so fielddim=height=width.  
 
135
            nneurons = weights_list.shape[0] # The number of postsynaptic neurons
 
136
            nels = 30#nneurons*ndims # The number of images that must be plotted
 
137
            ncols = round(2*sqrt(nels)) # The number of rows of subplots
 
138
            nrows = ceil(nels/ncols) # The number of columns of subplots
 
139
            print nrows
130
140
            print len(weights_list)
 
141
            # This creats several subplots, each one containing an
 
142
            # image.  The image is the weight values of the
 
143
            # feed-forward connections coming into each neuron in the
 
144
            # V1_Simple layer, plotted spatially.  Then, it draws it
 
145
            # or writes it to a file.
131
146
            ppl.clf()
132
 
            for pn in range(0,nrows*nrows):
133
 
                e = numpy.matrix(weights_list[pn])
134
 
                e = e.reshape((8, 9))
135
 
                ppl.subplot(nrows,nrows,pn+1)
136
 
                ppl.imshow(e, cmap=cm.Greys_r)
137
 
                ppl.axis('off')
 
147
            for nn in range(0,nneurons): # nn = neuron number
 
148
                e = weights_list[nn]
 
149
                e = e.reshape((fielddim,fielddim,ndims)) 
 
150
                for dn in range(0,ndims): # dn = dimension number
 
151
                    esub = e[:,:,dn] 
 
152
                    if nn*ndims+dn > nrows*ncols: break
 
153
                    ppl.subplot(nrows,ncols,nn*ndims+dn)
 
154
                    ppl.imshow(esub, cmap=cm.Greys_r)
 
155
                    ppl.axis('off')
 
156
                if (nn+1)*ndims > nrows*ncols: break
138
157
            ppl.text(.05,.95,"Timestep: "+str(i), transform=_figure.transFigure)
139
158
            if plot_results % 2 == 1:
140
159
                ppl.draw()
155
174
    tmp_mat = './results/network_'+str(net.time)+'.mat'
156
175
    net.save(filename=tmp_data)
157
176
    net.save(filename=tmp_mat)
158
 
 
159
177
        
160
178
def test_CRI_task(net,presentation_time=100):
161
179
    #Time measurement