def run_network(options): '''Run network with given `options` and return the dictionary that would be saved to an output file. ''' o = options seed_gen = TrialSeedGenerator(o.master_seed) stateMonParams = {'start': o.time - o.stateMonDur} nrec_spikes_e = None # all neurons nrec_spikes_i = 10 d = {} if "trials" not in d.keys(): d['trials'] = [] overalT = 0. ################################################################################ for trial_idx in range(len(d['trials']), o.ntrials): print("\n\t\tStarting trial no. {0}\n".format(trial_idx)) seed_gen.set_generators(trial_idx) d['invalidated'] = 1 ei_net = BasicGridCellNetwork(o, simulationOpts=None, nrec_spikes=(nrec_spikes_e, nrec_spikes_i), stateRecParams=(stateMonParams, stateMonParams)) if o.velON and not o.constantPosition: ei_net.setVelocityCurrentInput_e() posIn = ConstPosInputs(0, 0) if o.constantPosition else None ei_net.setPlaceCells(posIn=posIn) try: ei_net.simulate(o.time, printTime=o.printTime) except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Trying to save the simulated data if possible...") ei_net.endSimulation() d['trials'].append(ei_net.getAllData()) constrT, simT, totalT = ei_net.printTimes() overalT += totalT print("Script total run time: {0} s".format(overalT)) ################################################################################ return d
def run_network(options): '''Run network with given `options` and return the dictionary that would be saved to an output file. ''' o = options seed_gen = TrialSeedGenerator(o.master_seed) stateMonParams = { 'start' : o.time - o.stateMonDur } nrec_spikes_e = None # all neurons nrec_spikes_i = 10 d = {} if "trials" not in d.keys(): d['trials'] = [] overalT = 0. ################################################################################ for trial_idx in range(len(d['trials']), o.ntrials): print("\n\t\tStarting trial no. {0}\n".format(trial_idx)) seed_gen.set_generators(trial_idx) d['invalidated'] = 1 ei_net = BasicGridCellNetwork(o, simulationOpts=None, nrec_spikes=(nrec_spikes_e, nrec_spikes_i), stateRecParams=(stateMonParams, stateMonParams)) if o.velON and not o.constantPosition: ei_net.setVelocityCurrentInput_e() posIn = ConstPosInputs(0, 0) if o.constantPosition else None ei_net.setPlaceCells(posIn=posIn) try: ei_net.simulate(o.time, printTime=o.printTime) except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Trying to save the simulated data if possible...") ei_net.endSimulation() d['trials'].append(ei_net.getAllData()) constrT, simT, totalT = ei_net.printTimes() overalT += totalT print("Script total run time: {0} s".format(overalT)) ################################################################################ return d
print("\n\t\tStarting trial no. {0}\n".format(trial_idx)) seed_gen.set_generators(trial_idx) d['invalidated'] = 1 ei_net = BasicGridCellNetwork( o, simulationOpts=None, nrec_spikes=(nrec_spikes_e, nrec_spikes_i), stateRecParams=(stateMonParams, stateMonParams), rec_spikes_probabilistic=o.rec_spikes_probabilistic) if o.velON and not o.constantPosition: ei_net.setVelocityCurrentInput_e() if o.pcON: # This also sets the start PCs posIn = ConstPosInputs(0, 0) if o.constantPosition else None ei_net.setPlaceCells(posIn=posIn) else: # Here the start PCs must be set explicitly ei_net.setStartPlaceCells(ConstPosInputs(0, 0)) if o.ipc_ON: if o.constantPosition: raise RuntimeError("Place cells connected to I cells cannot be " "used when the constantPosition parameter is " "ON.") ei_net.setIPlaceCells() d['net_params'] = ei_net.getNetParams() # Common settings will stay d.flush() try: ei_net.simulate(o.time, printTime=o.printTime)
#const_v = [0.0, -o.Ivel] ei_net = BasicGridCellNetwork(o, simulationOpts=None) d['net_params'] = ei_net.getNetParams() # Common settings will stay # turn velocity inputs on if o.velON: ei_net.setVelocityCurrentInput_e() # animal position inputs (constant) pos = ConstPosInputs(0 + x_off[trial_idx], 0 + y_off[trial_idx]) # place cells if o.pcON: # activate place cells (including start place cells)) ei_net.setPlaceCells() # start place cells if o.spcON: # activate start place cells only ei_net.setStartPlaceCells(pos) # border cells if o.bcON: # create the border cells - "crosshair" arena_borders = [ ((0.0 + x_off[trial_idx], 90.0), (0.0 + x_off[trial_idx], -90.0)), ((-90.0, 0.0 + y_off[trial_idx]), (90.0, 0.0 + y_off[trial_idx])) ] ei_net.create_border_cells(borders=arena_borders, N_per_border=o.bcNum, posIn=pos)
seed_gen.set_generators(trial_idx) # Each trial is reproducible d['master_seed'] = int(o.master_seed) d['invalidated'] = 1 #const_v = [0.0, -o.Ivel] ei_net = BasicGridCellNetwork(o, simulationOpts=None) d['net_params'] = ei_net.getNetParams() # Common settings will stay # turn velocity inputs on if o.velON: ei_net.setVelocityCurrentInput_e() # place cells if o.pcON: # activate place cells (including start place cells)) ei_net.setPlaceCells(distribution='box_outline', boxSize=border_dim) elif o.spcON: # activate start place cells only ei_net.setStartPlaceCells(ConstPosInputs(0, 0)) else: pass # border cells if o.bcON: # create the border cells ei_net.create_border_cells(borders=borders, N_per_border=o.bcNum) # connect border cells according to chosen method if o.bcConnMethod == "line": ei_net.connect_border_cells_line_method(o.bc_conn_weight) elif o.bcConnMethod == "place": ei_net.connect_border_cells_modified_place_cell_method(
for trial_idx in range(len(d['trials']), o.ntrials): print("\n\t\tStarting trial no. {0}\n".format(trial_idx)) seed_gen.set_generators(trial_idx) d['invalidated'] = 1 ei_net = BasicGridCellNetwork(o, simulationOpts=None, nrec_spikes=(nrec_spikes_e, nrec_spikes_i), stateRecParams=(stateMonParams, stateMonParams), rec_spikes_probabilistic=o.rec_spikes_probabilistic) if o.velON and not o.constantPosition: ei_net.setVelocityCurrentInput_e() if o.pcON: # This also sets the start PCs posIn = ConstPosInputs(0, 0) if o.constantPosition else None ei_net.setPlaceCells(posIn=posIn) else: # Here the start PCs must be set explicitly ei_net.setStartPlaceCells(ConstPosInputs(0, 0)) if o.ipc_ON: if o.constantPosition: raise RuntimeError("Place cells connected to I cells cannot be " "used when the constantPosition parameter is " "ON.") ei_net.setIPlaceCells() d['net_params'] = ei_net.getNetParams() # Common settings will stay d.flush() try: ei_net.simulate(o.time, printTime=o.printTime)