def plotNet(net): plt.ion() plt.clf() fig = plt.gcf() ax = fig.add_subplot(111) # Plot Layers tp.PlotLayer(net.in_cortex, nodesize=50, fig=fig) tp.PlotLayer(net.cortex, nodesize=30, fig=fig) tp.PlotLayer(net.critic, nodesize=30, fig=fig) tp.PlotLayer(net.actor, nodesize=30, fig=fig) # tp.PlotLayer(net.input_dopa, nodesize=50, fig=fig) tp.PlotLayer(net.dopa, nodesize=30, fig=fig) tp.PlotLayer(net.vt_dopa, nodesize=50, fig=fig) # tp.PlotLayer(net.output, nodesize=50, fig=fig) plt.axis([-15.0, 15.0, -9.0, 9.0]) plt.axes().set_aspect('equal', 'box') plt.axes().set_xticks(np.arange(-15.0, 15.1, 1.0)) plt.axes().set_yticks(np.arange(-9.0, 9.1, 1.0)) plt.grid(True) plt.xlabel('Workspace Columns: 25') plt.ylabel('Workspace Rows: 30') plt.title('RoboBee Brain')
def main(plot_torus=True, plot_target=True, num_plot_tagets=3, use_lr_connection_type=NETWORK_DICT["np"]): """ Main function running the test routines :param plot_torus: Flag to plot neural layer :param plot_target: Flag to plot targets to control established connections :param num_plot_tagets: Plot connections of the num_plot_targts-th node :param use_lr_connection_type: Define the type of long range connections :return None """ torus_layer = create_torus_layer_uniform() if plot_torus: fig, _ = plt.subplots() tp.PlotLayer(torus_layer, fig) plt.show() create_local_circular_connections(torus_layer) debug_layer = create_distant_connections( torus_layer, connection_type=use_lr_connection_type) if plot_target: choice = np.random.choice(np.asarray(debug_layer), num_plot_tagets, replace=False) for c in choice: tp.PlotTargets([int(c)], torus_layer) plt.show() adj_mat = create_adjacency_matrix( nest.GetNodes(torus_layer)[0], nest.GetNodes(torus_layer)[0]) eigenvalue_analysis(adj_mat, plot=True)
def test_PlotLayer(self): """Test plotting layer.""" ldict = {'elements': 'iaf_neuron', 'rows': 3, 'columns': 3, 'extent': [2., 2.], 'edge_wrap': True} nest.ResetKernel() l = topo.CreateLayer(ldict) topo.PlotLayer(l) self.assertTrue(True)
def plot_layer_targets(cds, savename): layer = topo.CreateLayer(layer_dict) for cd in cds: topo.ConnectLayers(layer, layer, cd) ctr = topo.FindCenterElement(layer) fig = topo.PlotLayer(layer, nodesize=20) topo.PlotTargets(ctr, layer, fig=fig, tgt_color="red") plt.savefig("%s.png" % savename) plt.close()
def plot_conn(self): """Plot the targets of a unit using nest.topology function.""" # TODO: Get our own version so we can plot convergent connections import nest.topology as tp import matplotlib.pyplot as plt fig, ax = plt.subplots() # pylint:disable=invalid-name tp.PlotLayer(self.target.gid, fig) ctr = self.source.find_center_element( population=self.source_population) # Plot the kernel and mask if the connection is topological or rescaled. try: tp.PlotKernel(ax, ctr, self.nest_params['mask'], kern=self.nest_params['kernel'], kernel_color='green') except (AttributeError, KeyError, ValueError): # AttributeError, KeyError: if no nest_params mask or kernel # ValueError: if the mask or kernel cannot be plotted (custom mask) pass try: tp.PlotTargets(ctr, self.target.gid, tgt_model=self.target_population, syn_type=self.synapse_model, fig=fig, tgt_size=40, src_size=250, tgt_color='red') except ValueError: print((f"Not plotting targets: the center unit {ctr[0]} has no " + f"target within connection {self.__str__}")) plt.suptitle( f"Plot of targets of a single source unit.\n" f"Target units' pop: {self.target.name}," f"{str(self.target_population)} (targets in red),\n" f"Source unit's population: {self.source.name}," f"{str(self.source_population)}\n" f"Connection name: {self.name},\n", fontsize=7) footnote = ( "NB: The actual connection probability might be smaller " "than it seems if there is multiple units per grid position" " in the target population(s)") ax.annotate(footnote, xy=(1, 0), xycoords='axes fraction', fontsize=5, xytext=(0, -15), textcoords='offset points', ha='right', va='top') return fig
def plot_layer_targets(cds, savename): nest.ResetKernel() layer = topp.CreateLayer({"rows":rowcol, "columns":rowcol, "extent":extent, "elements":model}) for cd in cds: topp.ConnectLayers(layer, layer, cd) ctr = topp.FindCenterElement(layer) fig = topp.PlotLayer(layer, nodesize=20) topp.PlotTargets(ctr,layer, fig=fig, tgt_color="red") pylab.savefig("%s.png"%savename) pylab.close()
def plotKernel(self, folder): fig, ax = plt.subplots() tp.PlotLayer(self.l, fig, nodesize=10) ctr_elem = tp.FindCenterElement(self.l) # import ipdb; ipdb.set_trace() # tp.PlotKernel(ax, ctr_elem, mask=self.cdict_i2i['mask'], kern=self.cdict_i2i['kernel']) tp.PlotTargets(ctr_elem, self.l, fig=fig, tgt_color='red', mask=self.cdict_e2e['mask'], kernel=self.cdict_e2e['kernel'], kernel_color='green', mask_color='green', syn_type='exc_recurrent') # tp.PlotKernel(ax, ctr_elem, mask=self.cdict_e2e['mask'], mask_color='green') plt.xlabel(r'X') plt.ylabel(r'Y') plt.xlim(-.5, .5) plt.ylim(-.5, .5) plt.savefig(folder+'/kernel.pdf')
def plot_layer_targets(cds, savename): nest.ResetKernel() layer = topp.CreateLayer({ 'rows': rowcol, 'columns': rowcol, 'extent': extent, 'elements': model }) for cd in cds: topp.ConnectLayers(layer, layer, cd) ctr = topp.FindCenterElement(layer) fig = topp.PlotLayer(layer, nodesize=20) topp.PlotTargets(ctr, layer, fig=fig, tgt_color='red') pylab.savefig('%s.png' % savename) pylab.close()
def build_model(): global NEURONS nest.SetDefaults('iaf_psc_exp', iaf_neuronparams) layerNumberZ = 6 neuronID = 2 for layer in Cortex: columns = layer[area][X_area] rows = layer[area][Y_area] print rows NEURONS += rows * columns for y in range(rows): for x in range(columns): dictPosition_NeuronID[(float(x), float(y), float(layerNumberZ))] = neuronID neuronID += 1 layerNumberZ -= 1 logger.debug("{0} {1} neurons".format(layer[Glu][k_name][:2], rows * columns)) logger.debug("X: {0} ({1}neu x {2}col) \n".format( layer[area][X_area], sum(layer[step]), layer[area][X_area] / sum(layer[step])) + " " * 16 + "Y: {0} ({1}neu x {2}col)".format( layer[area][Y_area], 2, layer[area][Y_area] / 2)) model_3D = tp.CreateLayer({ 'positions': dictPosition_NeuronID.keys(), 'elements': 'iaf_psc_exp', 'extent': [1000.0, 1000.0, 100.0], 'edge_wrap': False }) # TODO uncomment if you want to see the 3D model tp.PlotLayer(model_3D) plt.show() # Build another parts for part in tuple(sorted(Thalamus + V1)): part[k_model] = 'iaf_psc_exp' part[k_IDs] = nest.Create(part[k_model], part[k_NN]) NEURONS += part[k_NN] logger.debug("{0} [{1}, {2}] {3} neurons".format( part[k_name], part[k_IDs][0], part[k_IDs][0] + part[k_NN] - 1, part[k_NN]))
def plot_connections(layer_dict, conn_dict, file_name): conn_dict['synapse_model'] = 'static_synapse' layer = tp.CreateLayer(layer_dict) tp.ConnectLayers(layer, layer, conn_dict) fig = tp.PlotLayer(layer) tp.PlotTargets(tp.FindCenterElement(layer), layer, fig=fig, tgt_color='red') pylab.savefig(file_name) #pylab.show() tp.DumpLayerConnections(layer, conn_dict['synapse_model'], file_name + ".dump") positions = tp.GetTargetPositions(layer, layer)
def plot_layer(layer): tp.PlotLayer(layer, nodesize=50) status = GetStatus(layer)[0] extent = status['topology']['extent'] # beautify plt.axis([ extent[0] / (-2.0) - 0.25, extent[0] / 2.0 + 0.25, extent[1] / (-2.0) - 0.25, extent[1] / 2.0 + 0.25 ]) plt.axes().set_aspect('equal', 'box') plt.axes().set_xticks( [w - extent[0] / 2.0 for w in range(int(extent[0]) + 1)]) plt.axes().set_yticks( [w - extent[1] / 2.0 for w in range(int(extent[1]) + 1)]) plt.grid(True) plt.xlabel('%d Columns, Extent: %f' % (status['topology']['columns'], extent[0])) plt.ylabel('%d Rows, Extent: %f' % (status['topology']['rows'], extent[1]))
def conn_figure(fig, layer, connd, targets=None, showmask=True, showkern=False, xticks=range(-5, 6), yticks=range(-5, 6), xlim=[-5.5, 5.5], ylim=[-5.5, 5.5]): if targets is None: targets = ((tp.FindCenterElement(layer), 'red'), ) tp.PlotLayer(layer, fig=fig, nodesize=60) for src, clr in targets: if showmask: mask = connd['mask'] else: mask = None if showkern: kern = connd['kernel'] else: kern = None tp.PlotTargets(src, layer, fig=fig, mask=mask, kernel=kern, src_size=250, tgt_color=clr, tgt_size=20, kernel_color='green') beautify_layer(layer, fig, xlim=xlim, ylim=ylim, xticks=xticks, yticks=yticks, xlabel='', ylabel='') fig.gca().grid(False)
def main(plot_torus=True, plot_target=True, num_plot_tagets=3, use_lr_connection_type=NETWORK_DICT["np"]): """ Main function running the test routines :param plot_torus: Flag to plot neural layer :param plot_target: Flag to plot targets to control established connections :param num_plot_tagets: Plot connections of the num_plot_targts-th node :param use_lr_connection_type: Define the type of long range connections """ torus_layer = create_torus_layer_uniform() if plot_torus: fig, _ = plt.subplots() tp.PlotLayer(torus_layer, fig) plt.show() create_local_circular_connections(torus_layer) if use_lr_connection_type == NETWORK_DICT["np"]: debug_layer = create_distant_np_connections(torus_layer) elif use_lr_connection_type == NETWORK_DICT["random"]: debug_layer = create_random_patches(torus_layer) elif use_lr_connection_type == NETWORK_DICT["overlapping"]: debug_layer = create_overlapping_patches(torus_layer) elif use_lr_connection_type == NETWORK_DICT["shared"]: debug_layer = create_shared_patches(torus_layer) elif use_lr_connection_type == NETWORK_DICT["partially-overlapping"]: debug_layer = create_partially_overlapping_patches(torus_layer) else: raise ValueError("Not a valid network") if plot_target: choice = np.random.choice(np.asarray(debug_layer), num_plot_tagets, replace=False) for c in choice: tp.PlotTargets([int(c)], torus_layer) plt.show()
def conn_figure_3d(fig, layer, connd, targets=None, showmask=True, showkern=False, xticks=range(-5, 6), yticks=range(-5, 6), xlim=[-5.5, 5.5], ylim=[-5.5, 5.5]): if targets is None: targets = ((tp.FindCenterElement(layer), 'red'), ) tp.PlotLayer(layer, fig=fig, nodesize=20, nodecolor=(.5, .5, 1.)) for src, clr in targets: if showmask: mask = connd['mask'] else: mask = None if showkern: kern = connd['kernel'] else: kern = None tp.PlotTargets(src, layer, fig=fig, mask=mask, kernel=kern, src_size=250, tgt_color=clr, tgt_size=60, kernel_color='green') ax = fig.gca() ax.set_aspect('equal', 'box') plt.draw()
row2_Gaba = (kol2 - row2_Glu * 2) / 2 sl2_Glu = tp.CreateLayer({ 'rows': row2_Glu, 'columns': 5, 'layers': 1, 'elements': 'pyr', 'center': [0., 0., 4.] }) sl2_Gaba = tp.CreateLayer({ 'rows': row2_Gaba, 'columns': 5, 'layers': 1, 'elements': 'in', 'center': [0., 1., 4.] }) fig1 = tp.PlotLayer(sl2_Glu, nodesize=size, nodecolor='green') fig2 = tp.PlotLayer(sl2_Gaba, nodesize=size, fig=fig1, nodecolor='red') # Layer3 row3_Glu = int(math.ceil(kol3 * l3_Glu) / 2) row3_Gaba = (kol3 - row3_Glu * 2) / 2 sl3_Glu = tp.CreateLayer({ 'rows': row3_Glu, 'columns': 5, 'layers': 1, 'elements': 'pyr', 'center': [0., 0., 5.] }) sl3_Gaba = tp.CreateLayer({ 'rows': row3_Gaba, 'columns': 5,
ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) return # -------------------------------------------------- nest.ResetKernel() # { layer1 #} import nest.topology as tp l = tp.CreateLayer({'rows': 5, 'columns': 5, 'elements': 'iaf_neuron'}) # { end #} fig = tp.PlotLayer(l, nodesize=50) beautify_layer(l, fig, xlabel='x-axis (columns)', ylabel='y-axis (rows)') ax = fig.gca() tx = [] for r in range(5): tx.append( ax.text(0.65, 0.4 - r * 0.2, str(r), horizontalalignment='center', verticalalignment='center')) tx.append( ax.text(-0.4 + r * 0.2, 0.65, str(r), horizontalalignment='center',
import nest import pylab import nest.topology as topo pylab.ion() nest.ResetKernel() l1 = topo.CreateLayer({ 'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], 'elements': 'iaf_neuron' }) nest.PrintNetwork() nest.PrintNetwork(2) nest.PrintNetwork(2, l1) topo.PlotLayer(l1, nodesize=50) # beautify pylab.axis([-1.0, 1.0, -0.75, 0.75]) pylab.axes().set_aspect('equal', 'box') pylab.axes().set_xticks((-0.75, -0.25, 0.25, 0.75)) pylab.axes().set_yticks((-0.5, 0, 0.5)) pylab.grid(True) pylab.xlabel('4 Columns, Extent: 1.5') pylab.ylabel('2 Rows, Extent: 1.0') # pylab.savefig('grid_iaf.png')
'positions': M_cone_pos, 'elements': 'iaf_psc_alpha', 'extent': [diam_retina, diam_retina] }) retina_RGCs = tp.CreateLayer({ 'positions': RGC_pos, 'elements': 'iaf_psc_alpha', 'extent': [diam_retina, diam_retina] }) # Plot layer ----------------------------------------------------------------------------------------------------------- plt.close('all') retinalplot = plt.figure(num='retina', figsize=(8, 8)) plt.title('Retina') tp.PlotLayer(retina_rods, fig=retinalplot, nodecolor='k', nodesize=1) tp.PlotLayer(retina_S_cones, fig=retinalplot, nodecolor='#b412ed', nodesize=10) tp.PlotLayer(retina_M_cones, fig=retinalplot, nodecolor='#019309', nodesize=10) retinalplot.savefig('Retina/figures/retina.png', dpi=100) plt.show() plt.figure('PDF') plt.plot(fitspace, rodfit(fitspace)) plt.show() #''' #''' # 2D histogram---------------------------------------------------------------------------------------------------------- # Rods: rod_pos_x = [row[0] for row in rod_pos] rod_pos_y = [row[1] for row in rod_pos]
import pylab import time import nest import nest.topology as topo for ctr in [(0.0, 0.0), (-2.0, 2.0), (2.0, 1.0)]: nest.ResetKernel() # pylab.clf() l1 = topo.CreateLayer({ 'columns': 4, 'rows': 3, 'extent': [2.0, 1.5], 'center': ctr, 'elements': 'iaf_psc_alpha' }) topo.PlotLayer(l1, nodesize=50, fig=pylab.gcf()) # beautify pylab.axis([-3, 3, -3, 3]) pylab.axes().set_aspect('equal', 'box') pylab.axes().set_xticks(pylab.arange(-3.0, 3.1, 1.0)) pylab.axes().set_yticks(pylab.arange(-3.0, 3.1, 1.0)) pylab.grid(True) pylab.xlabel('4 Columns, Extent: 1.5, Center: %.1f' % ctr[0]) pylab.ylabel('2 Rows, Extent: 1.0, Center: %.1f' % ctr[1]) # pylab.draw() # pylab.pause(2) pylab.savefig("figs/grid_iaf_oc.png") # pylab.show()
"positions": poss, "elements": "iaf_psc_alpha", "extent": [1.1, 1.1] } my_layer_dict_on_grid = { "rows": 11, "columns": 11, "extent": [11.0, 11.0], "elements": 'iaf_psc_alpha' } # connectivity specifications with a mask conndict = { 'connection_type': 'divergent', 'mask': { 'rectangular': { 'lower_left': [-2.0, -1.0], 'upper_right': [2.0, 1.0] } } } my_layer = topp.CreateLayer(my_layer_dict_on_grid) topp.PlotLayer(my_layer) topp.ConnectLayers(my_layer, my_layer, conndict) nest.PrintNetwork(depth=1) topp.PlotTargets([5], my_layer) plt.show()
# import nest import pylab as pl import numpy as np import nest.topology as tp fig, ax = pl.subplots(1, figsize=(6, 5)) nc, nr = 5, 3 d = 0.1 layer = tp.CreateLayer({"columns": nc, "rows": nr, "elements": "iaf_psc_alpha", "extent": [nc * d, nr * d], "center": [nc* d / 2., 0.]}) # tp.PlotLayer([layer1[0], layer2[0]], nodecolor="k", nodesize=50, fig=fig) tp.PlotLayer(layer, nodecolor="k", nodesize=50, fig=fig) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_aspect('equal', 'box') ax.set_xticks(np.arange(0,0.6,0.1)) fig.savefig("figs/02.png") # pl.show()
def create_spike_times(Sim, NModel): if Sim.overwrite_files == "no": if Sim.data_folder.is_dir()==True: print("You are not allowed to overwrite the files.") sys.exit("Error message") else: Sim.data_folder.mkdir(parents=True) elif Sim.overwrite_files == "yes": if Sim.data_folder.is_dir()==True: print("You have overwritten old files.") else: Sim.data_folder.mkdir(parents=True) else: print("You have two options for overwrite files") connections_path = Sim.data_folder / "connections.txt" spikes_path = Sim.data_folder / "spikes.mat" spikes_split_path = Sim.data_folder / "spikes_split.mat" multimeter_data_path = Sim.data_folder / "multimeter_data.mat" hyperparameters_path = Sim.data_folder / "hyperparameters.mat" position_path = Sim.data_folder / "position.mat" # Define important simulation parameters nest.ResetKernel() seed=1008.0 nest.SetKernelStatus({"resolution": Sim.resolution, "print_time": True, "overwrite_files":True, "grng_seed": int(seed), "rng_seeds": [int(seed)] }) # Construct the position grid of the neural network(NN) jit = 0.03 if NModel.nr_neurons==100: xs = np.arange(-0.45,.451,0.1) # defines the size of the network elif NModel.nr_neurons==16: xs = np.arange(-0.15,.151,0.1) else: print("Current network can constitute of 16 or 100 neurons.") np.random.seed(int(seed)) pos = [[x,y] for y in xs for x in xs] pos = [[p[0]+np.random.uniform(-jit,jit),p[1]+np.random.uniform(-jit,jit)] for p in pos] # Construct the neurons on the grid and establish connections between them. # The probabilty of connection varies with the distance between the neurons # Define synapse connections nest.SetDefaults("tsodyks_synapse",{"delay": NModel.t_delay, #1.5 in Stetter's code "tau_rec": NModel.tau_rec, "tau_fac":0.0, "U": NModel.U }) conn1 = { "connection_type":"divergent", "mask": {"circular":{"radius":0.75}}, "kernel": {"gaussian":{"p_center":1.,"sigma":0.15}}, #0.15 for 100 neurons "allow_autapses":False, "synapse_model":"tsodyks_synapse", "weights": NModel.alpha_int } # specify the neural model neuron_param= { #"I_e" : 0.0, "C_m" : 1.0, "tau_m" : NModel.tau_m, "t_ref" : NModel.tau_s, #refactory periods in ms 2.0 is default "E_L" : 0.0, "V_th" : NModel.V_thres, "V_m" : 0.0, "V_reset" : 0.0 } nest.SetDefaults("iaf_psc_alpha", neuron_param) layer_dict_ex = {"positions": pos, "extent" : [1.1,1.1], "elements" : "iaf_psc_alpha"} layer = topp.CreateLayer(layer_dict_ex) topp.ConnectLayers(layer,layer,conn1) # Plot layer topp.PlotLayer(layer) # change the seed for different Poisson spike trains nest.SetKernelStatus({ 'grng_seed': int(seed), 'rng_seeds': [int(seed)] }) # Creation of a poisson generator nest.CopyModel('poisson_generator', 'PG', params={'rate': NModel.poisson_spike_rate}) #1.6 in the paper, I don't know why they changed it in the programm pg = topp.CreateLayer({ 'rows' : 1, 'columns' : 1, 'elements' : 'PG'}) cdict_stim = {'connection_type' : 'divergent', 'weights': NModel.alpha_ext} topp.ConnectLayers(pg,layer,cdict_stim) # create multimeter nrns=nest.GetLeaves(layer,local_only=True)[0] multimeter = nest.Create("multimeter", NModel.nr_neurons) nest.SetStatus(multimeter, {"withtime":True, "record_from":["V_m","I_syn_ex"],"interval":Sim.interval}) #, "input_currents_ex","input_currents_in" nest.Connect(multimeter,nrns,"one_to_one") # Create spike detector sd1 = nest.Create('spike_detector') nest.SetStatus(sd1,{'precise_times':True}) nest.Connect(nrns,sd1) # Simulate nest.Simulate(Sim.sim_length + Sim.interval) # Retrieve the generated data [potential,currents_ex,spikes,time]=get_data(multimeter,sd1,NModel.nr_neurons,Sim.nr_samples) # Save the spikes to a file spikesdict={'N1':spikes} sio.savemat(str(spikes_path),spikesdict) if Sim.P>1: potential_fin = time_series_split(potential,Sim.P)[0] currents_ex_fin = time_series_split(currents_ex,Sim.P)[0] spikesdict_split = spike_times_split(spikes, Sim.sim_length, Sim.P) else: potential_fin=potential currents_ex_fin=currents_ex spikesdict_split = {'N1':spikes} # Pass important hyperparameters to create_fluorescent_data_from_spike_times.py hyperdict = { 'P' : Sim.P, 'length_ts' : Sim.length_ts, 'nr_samples' : Sim.nr_samples, 'nr_neurons' : NModel.nr_neurons, 'interval' : Sim.interval } sio.savemat(str(hyperparameters_path),hyperdict) # save the position sio.savemat(str(position_path), {'position' : pos}) # save the results sio.savemat(str(multimeter_data_path),mdict={ 'potential' : potential_fin, 'input_currents_ex': currents_ex_fin }) sio.savemat(str(spikes_split_path),spikesdict_split) topp.DumpLayerConnections(layer,'tsodyks_synapse',str(connections_path))
row23_Gaba = (kol23 - row23_Glu * 2) / 2 sl23_Glu = tp.CreateLayer({ 'rows': row23_Glu, 'columns': 2, 'layers': 1, 'elements': 'pyr', 'center': [0., 0., 4.] }) sl23_Gaba = tp.CreateLayer({ 'rows': row23_Gaba, 'columns': 2, 'layers': 1, 'elements': 'in', 'center': [0., 1., 4.] }) fig1 = tp.PlotLayer(sl23_Glu, nodesize=10, nodecolor='orange') fig2 = tp.PlotLayer(sl23_Gaba, nodesize=10, fig=fig1) # Layer4 row4_Glu = int(math.ceil(kol4 * l4_GLu) / 2) row4_Gaba = (kol4 - row4_Glu * 2) / 2 sl4_Glu = tp.CreateLayer({ 'rows': row4_Glu, 'columns': 2, 'layers': 1, 'elements': 'pyr', 'center': [0., 0., 3.] }) sl4_Gaba = tp.CreateLayer({ 'rows': row4_Gaba, 'columns': 2,
#! Collect all populations #! ----------------------- #! For reference purposes, e.g., printing, we collect all populations #! in a tuple: populations = (retina, Tp, Rp, Vp_h, Vp_v) #! Inspection #! ---------- #! We can now look at the network using `PrintNetwork`: nest.PrintNetwork() #! We can also try to plot a single layer in a network. For #! simplicity, we use Rp, which has only a single neuron per position. topo.PlotLayer(Rp) pylab.title('Layer Rp') pylab.show() #! Synapse models #! ============== #! Actual synapse dynamics, e.g., properties such as the synaptic time #! course, time constants, reversal potentials, are properties of #! neuron models in NEST and we set them in section `Neuron models`_ #! above. When we refer to *synapse models* in NEST, we actually mean #! connectors which store information about connection weights and #! delays, as well as port numbers at the target neuron (``rport``) #! and implement synaptic plasticity. The latter two aspects are not #! relevant here. #!
import nest import nest.topology as tp import math import pylab l=tp.CreateLayer({'rows':21,'columns':21,'elements':'iaf_neuron'}) conndict={'connection_type':'divergent','mask':{'circular':{'radius':0.4}},'kernel':{'gaussian':{'p_center':1.0,'sigma':0.15}}} tp.ConnectLayers(l,l,conndict) fig=tp.PlotLayer(l,nodesize=80) ctr=tp.FindCenterElement(l) tp.PlotTargets(ctr,l,fig=fig, mask=conndict['mask'],kernel=conndict['kernel'], src_size=250,tgt_color='red',tgt_size=20, kernel_color='green') l1=tp.CreateLayer({'rows':5,'columns':5,'elements':'iaf_neuron'}) l2=tp.CreateLayer({'rows':5,'columns':5,'elements':'iaf_neuron','center':[-1.0,1.0]}) l3=tp.CreateLayer({'rows':5,'columns':5,'elements':'iaf_neuron','center':[1.5,0.5]}) tp.ConnectLayers(l1,l3,mix_par)