def InstallBCPNN(on_milner=False, on_beskow=False): ''' This function installs the BCPNN Synapse by Phil Tully. The optional parameter passed, indicate whether this is on Supercomputer Milner (True) or Beskow or my local machine (False) ''' if ('milner' in os.getcwd()): on_milner = True if ('klemming' in os.getcwd()): on_beskow = True if (not 'bcpnn_synapse' in nest.Models('synapses')): if on_beskow: nest.sr( '(/cfs/klemming/nobackup/f/fiebig/170501_Beskow_BCPNN/share/nest/sli) addpath' ) nest.Install( '/cfs/klemming/nobackup/f/fiebig/170501_Beskow_BCPNN/lib/nest/pt_module' ) elif on_milner: nest.sr( '(/cfs/milner/scratch/f/fiebig/140408_Milner_BCPNN/share/nest/sli) addpath' ) nest.Install( '/cfs/milner/scratch/f/fiebig/140408_Milner_BCPNN/lib/nest/pt_module' ) else: try: nest.Install('pt_module') except: nest.Install('pt_module')
def run_model(model='aeif_cond_alpha', dt=0.1,reps=1): nest.ResetKernel() nest.sr("30 setverbosity") nest.SetKernelStatus({"overwrite_files": True}) nest.SetStatus([0],[{"resolution": dt}]) nest.SetDefaults('aeif_cond_alpha_RK5',{'HMIN':0.001}) nest.SetDefaults('aeif_cond_alpha_RK5',{'MAXERR':1e-10}) neuron = nest.Create(model,2) nest.SetStatus(neuron,[{"V_peak": 0.0, "a": 4.0, "b":80.5}]) dc=nest.Create("dc_generator") nest.SetStatus(dc,[{"amplitude":700.0, "start":700.0, "stop":2700.0}]) nest.Connect(dc,[neuron[0]]) sd = nest.Create('spike_detector') nest.Connect([neuron[0]],sd) meter0 = nest.Create('multimeter', params={'record_from': ['V_m', 'g_ex','g_in','w'], 'interval' :0.1}) nest.Connect(meter0,[neuron[0]]) nest.SetStatus(meter0,[{"to_file": False, "withtime": True}]) t = timeit.Timer("nest.Simulate(3000)","import nest") runtime = t.timeit(number=reps)/reps sptimes = nest.GetStatus(sd,"events")[0]['times'] voltage_trace = nest.GetStatus(meter0,"events")[0]['V_m'] return (runtime,sptimes,voltage_trace)
def run_model(model='aeif_cond_alpha', dt=0.1, reps=1): nest.ResetKernel() nest.sr("30 setverbosity") nest.SetKernelStatus({"overwrite_files": True}) nest.SetStatus([0], [{"resolution": dt}]) nest.SetDefaults('aeif_cond_alpha_RK5', {'HMIN': 0.001}) nest.SetDefaults('aeif_cond_alpha_RK5', {'MAXERR': 1e-10}) neuron = nest.Create(model, 2) nest.SetStatus(neuron, [{"V_peak": 0.0, "a": 4.0, "b": 80.5}]) dc = nest.Create("dc_generator") nest.SetStatus(dc, [{"amplitude": 700.0, "start": 700.0, "stop": 2700.0}]) nest.Connect(dc, [neuron[0]]) sd = nest.Create('spike_detector') nest.Connect([neuron[0]], sd) meter0 = nest.Create('multimeter', params={ 'record_from': ['V_m', 'g_ex', 'g_in', 'w'], 'interval': 0.1 }) nest.Connect(meter0, [neuron[0]]) nest.SetStatus(meter0, [{"to_file": False, "withtime": True}]) t = timeit.Timer("nest.Simulate(3000)", "import nest") runtime = t.timeit(number=reps) / reps sptimes = nest.GetStatus(sd, "events")[0]['times'] voltage_trace = nest.GetStatus(meter0, "events")[0]['V_m'] return (runtime, sptimes, voltage_trace)
def compute_transfer(self, i_mean=(0.0,100.0, 10.0), i_std=(0.0,100.0, 10.0)): self.i_range=numpy.arange(*i_mean) self.std_range=numpy.arange(*i_std) self.rate=numpy.zeros((self.i_range.size,self.std_range.size)) nest.sr('M_WARNING setverbosity') for n,i in enumerate(self.i_range): print "I= %s"%i for m,std in enumerate(self.std_range): self.rate[n,m]=self.output_rate(i,std)
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params): """ Should be called at the very beginning of a script. extra_params contains any keyword arguments that are required by a given simulator but not by others. """ global tempdir common.setup(timestep, min_delay, max_delay, **extra_params) if 'verbosity' in extra_params: nest_verbosity = extra_params['verbosity'].upper() else: nest_verbosity = "WARNING" nest.sli_run("M_%s setverbosity" % nest_verbosity) # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() # set tempdir tempdir = tempfile.mkdtemp() tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({ 'data_path': tempdir, }) # set kernel RNG seeds num_threads = extra_params.get('threads') or 1 if 'rng_seeds' in extra_params: rng_seeds = extra_params['rng_seeds'] else: rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42 rng = NumpyRNG(rng_seeds_seed) rng_seeds = (rng.rng.uniform(size=num_threads * num_processes()) * 100000).astype('int').tolist() logger.debug("rng_seeds = %s" % rng_seeds) nest.SetKernelStatus({ 'local_num_threads': num_threads, 'rng_seeds': rng_seeds }) # set resolution nest.SetKernelStatus({'resolution': timestep}) # Set min_delay and max_delay for all synapse models for synapse_model in NEST_SYNAPSE_TYPES: nest.SetDefaults(synapse_model, { 'delay': min_delay, 'min_delay': min_delay, 'max_delay': max_delay }) simulator.reset() return rank()
def compute_transfer(self, i_mean=(0.0, 100.0, 10.0), i_std=(0.0, 100.0, 10.0)): self.i_range = numpy.arange(*i_mean) self.std_range = numpy.arange(*i_std) self.rate = numpy.zeros((self.i_range.size, self.std_range.size)) nest.sr('M_WARNING setverbosity') for n, i in enumerate(self.i_range): print "I= %s" % i for m, std in enumerate(self.std_range): self.rate[n, m] = self.output_rate(i, std)
def setUp(self): nest.ResetKernel() nest.sr("statusdict/threading :: (no) eq not") if not nest.spp(): # no multi-threading nest.SetKernelStatus({'grng_seed': 120, 'rng_seeds': [576]}) else: # multi-threading nest.SetKernelStatus({'local_num_threads': 2, 'grng_seed': 120, 'rng_seeds': [576, 886]}) pass
def test_DivisionByZero(self): """Division by zero""" nest.ResetKernel() try: nest.sr('1 0 div') self.fail('an error should have risen!') # should not be reached except nest.NESTError: info = sys.exc_info()[1] if not "DivisionByZero" in info.__str__(): self.fail('wrong error message') # another error has been thrown, this is wrong except: self.fail('wrong error has been thrown')
def test_StackUnderFlow(self): """Stack underflow""" nest.ResetKernel() try: nest.sr('clear ;') self.fail('an error should have risen!') # should not be reached except nest.NESTError: info = sys.exc_info()[1] if not "StackUnderflow" in info.__str__(): self.fail('wrong error message') # another error has been thrown, this is wrong except: self.fail('wrong error has been thrown')
def clear(self): self.populations = [] self.recording_devices = [] self.recorders = set() # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() # set tempdir tempdir = tempfile.mkdtemp() self.tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({'data_path': tempdir, }) self.segment_counter = -1 self.reset()
def install_module(path, sli_path, model_to_exist='my_aeif_cond_exp'): if not model_to_exist in nest.Models(): if sli_path != '': nest.sr('(' + sli_path + ') addpath') #nest.Install(path) # Solves weird problem that I need to load it twice # only on my wheezy debian try: nest.Install(path) #always fails in Nest 2.4.X except: nest.Install(path) #running twice fixes Nest 2.4.X print '...successful'
def clear(self): self.populations = [] self.recording_devices = [] self.recorders = set() # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() # but this reverts some of the PyNN settings, so we have to repeat them (see NEST #716) self.spike_precision = self._spike_precision # set tempdir tempdir = tempfile.mkdtemp() self.tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({'data_path': tempdir, }) self.segment_counter = -1 self.reset()
def test_EventsVoltage(self): """Voltage Events""" nest.ResetKernel() nest.sr('20 setverbosity') n = nest.Create('iaf_neuron') vm = nest.Create('voltmeter', 1, {'withtime': True, 'interval': 1.}) nest.Connect(vm, n) nest.SetKernelStatus({'print_time': False}) nest.Simulate(10) d = nest.GetStatus(vm, 'events')[0] self.assertEqual(len(d['V_m']), 9)
def install_module(path, sli_path, model_to_exist='my_aeif_cond_exp'): if not model_to_exist in nest.Models(): if sli_path!='': nest.sr('('+sli_path+') addpath') #nest.Install(path) # Solves weird problem that I need to load it twice # only on my wheezy debian try: nest.Install(path)#always fails in Nest 2.4.X except: nest.Install(path)#running twice fixes Nest 2.4.X print '...successful'
def test_EventsSpikes(self): """Spike Events""" nest.ResetKernel() nest.sr('20 setverbosity') n = nest.Create('iaf_neuron', 1, {'I_e': 1000.}) sd = nest.Create('spike_detector', 1, {'withtime': True}) nest.Connect(n, sd) nest.SetKernelStatus({'print_time': False}) nest.Simulate(1000) d = nest.GetStatus(sd, 'events')[0] self.assert_(len(d['times']) > 0)
def clear(self): self.populations = [] self.recording_devices = [] self.recorders = set() # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() # but this reverts some of the PyNN settings, so we have to repeat them (see NEST #716) self.spike_precision = self._spike_precision # set tempdir tempdir = tempfile.mkdtemp() self.tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({ 'data_path': tempdir, }) self.segment_counter = -1 self.reset()
def clear(self, **kwargs): # Set initial values self.populations = [] self.recording_devices = [] self.recorders = set() # clear the sli stack, if this is not done --> memory leak cause the # stack increases nest.sr('clear') # set tempdir tempdir = tempfile.mkdtemp() self.tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({'data_path': tempdir}) self.segment_counter = 0 # Get values before they are reset dt = kwargs.get('dt', self.dt) num_processes = self.num_processes threads = self.threads # Reset network and kernel nest.ResetKernel() nest.ResetNetwork() nest.SetKernelStatus({'overwrite_files': True, 'resolution': dt}) if 'dt' in kwargs: self.dt = kwargs['dt'] # set kernel RNG seeds self.num_threads = kwargs.get('threads', 1) if 'grng_seed' in kwargs: self.grng_seed = kwargs['grng_seed'] if 'rng_seeds' in kwargs: self.rng_seeds = kwargs['rng_seeds'] else: rng = numpy.random.RandomState(kwargs.get('rng_seed', int(time.time()))) n = num_processes * threads self.rng_seeds = list( numpy.asarray(rng.uniform(low=0, high=100000, size=n), dtype=int)) self.reset()
def test_Count(self): """Object count""" nest.ResetKernel() nest.sr('clear') for i in range(100): nest.sps(i) nest.sr('count') self.assertEqual(nest.spp(), 100) for i in range(100): self.assertEqual(nest.spp(), (99 - i)) nest.sr('count') self.assertEqual(nest.spp(), 0)
def memory_thisjob(): '''Wrapper to obtain current memory usage''' nest.sr('memory_thisjob') return nest.spp()
def nest_multithreaded(self): """Return True, if we have a thread-enabled NEST, False otherwise""" nest.sr("statusdict/threading :: (no) eq not") return nest.spp()
def lambertwm1(x): '''Wrapper for LambertWm1 function''' nest.sr('{} LambertWm1'.format(x)) return nest.spp()
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params): """ Should be called at the very beginning of a script. extra_params contains any keyword arguments that are required by a given simulator but not by others. """ global tempdir common.setup(timestep, min_delay, max_delay, **extra_params) # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() if 'verbosity' in extra_params: nest_verbosity = extra_params['verbosity'].upper() else: nest_verbosity = "WARNING" nest.sli_run("M_%s setverbosity" % nest_verbosity) if "spike_precision" in extra_params: simulator.state.spike_precision = extra_params["spike_precision"] if extra_params["spike_precision"] == 'off_grid': simulator.state.default_recording_precision = 15 nest.SetKernelStatus( {'off_grid_spiking': simulator.state.spike_precision == 'off_grid'}) if "recording_precision" in extra_params: simulator.state.default_recording_precision = extra_params[ "recording_precision"] # all NEST to erase previously written files (defaut with all the other simulators) nest.SetKernelStatus({'overwrite_files': True}) # set tempdir tempdir = tempfile.mkdtemp() tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({ 'data_path': tempdir, }) # set kernel RNG seeds num_threads = extra_params.get('threads') or 1 if 'rng_seeds' in extra_params: rng_seeds = extra_params['rng_seeds'] else: rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42 rng = NumpyRNG(rng_seeds_seed) rng_seeds = (rng.rng.uniform(size=num_threads * num_processes()) * 100000).astype('int').tolist() logger.debug("rng_seeds = %s" % rng_seeds) nest.SetKernelStatus({ 'local_num_threads': num_threads, 'rng_seeds': rng_seeds }) # set resolution nest.SetKernelStatus({'resolution': timestep}) if 'allow_offgrid_spikes' in nest.GetDefaults('spike_generator'): nest.SetDefaults('spike_generator', {'allow_offgrid_spikes': True}) # Set min_delay and max_delay for all synapse models NEST_SYNAPSE_TYPES = nest.Models( mtype='synapses') # need to rebuild after ResetKernel for synapse_model in NEST_SYNAPSE_TYPES: nest.SetDefaults(synapse_model, { 'delay': min_delay, 'min_delay': min_delay, 'max_delay': max_delay }) simulator.connection_managers = [] simulator.populations = [] simulator.reset() return rank()
import tempfile import mynest import mynest_light import pprint as pp os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp() import matplotlib matplotlib.use('Agg') import pylab as pl print 'INIT' # Load BCPNN synapse and bias-iaf neuron module if (not 'bcpnn_dopamine_synapse' in nest.Models()): nest.sr('(/cfs/milner/scratch/b/berthet/modules/bcpnndopa_module/share/ml_module/sli) addpath') #t/tully/sequences/share/nest/sli nest.Install('/cfs/milner/scratch/b/berthet/modules/bcpnndopa_module/lib/nest/ml_module') #t/tully/sequences/lib/nest/pt_module # nest.Install('ml_module') try: from mpi4py import MPI USE_MPI = True comm = MPI.COMM_WORLD pc_id, n_proc = comm.rank, comm.size print "USE_MPI:", USE_MPI, 'pc_id, n_proc:', pc_id, n_proc except: USE_MPI = False pc_id, n_proc, comm = 0, 1, None print "MPI not used" nest.ResetKernel() nest.ResetKernel()
import nest print nest.Models() # 'bcpnn_synapse' should NOT show up # ON LINDGREN: instead of nest.Install('pt_module'), do: #if (not 'bcpnn_synapse' in nest.Models('synapses')): # nest.sr('(/home/bernhard/Downloads/nest/nest-2.2.1-build/share/nest/sli) addpath') # nest.Install('/home/bernhard/workspace/BCPNN-module/build-module-100725/pt_module') on_milner = True if (not 'bcpnn_synapse' in nest.Models('synapses')): if on_milner: nest.sr( '(/cfs/milner/scratch/b/bkaplan/BCPNN-Module/share/nest/sli) addpath' ) nest.Install( '/cfs/milner/scratch/b/bkaplan/BCPNN-Module/lib/nest/pt_module') else: nest.Install('pt_module') nest.Models() # now, 'bcpnn_synapse' is available nest.GetDefaults('bcpnn_synapse')
import pprint pp=pprint.pprint from os.path import expanduser from core.my_population import MySpikeList s='nest-2.2.2' HOME = expanduser("~") MODULE_PATH= (HOME+'/opt/NEST/module/' +'install-module-130701-'+s+'/lib/nest/ml_module') MODULE_SLI_PATH= (HOME+'/opt/NEST/module/' +'install-module-130701-'+s+'/share/ml_module/sli') nest.sr('('+MODULE_SLI_PATH+') addpath') nest.Install(MODULE_PATH) pp(nest.Models()) # nest.GetDefaults(dn['type_id']) nest.CopyModel('poisson_generator_dynamic', 'new') pp(nest.GetDefaults('poisson_generator_dynamic')) n=nest.Create('poisson_generator_dynamic', params={'rates':[500.,0.,100.], 'timings':[0.,3000., 4000.]}) pn=nest.Create('parrot_neuron',2) sd=nest.Create('spike_detector',2) nest.Connect(n+n,pn)
This example is also shown in the article Eppler et al. (2009) PyNEST: A convenient interface to the {NEST} simulator, Front. Neuroinform. doi:10.3389/neuro.11.012.2008 ''' # First, we import all necessary modules for simulation, analysis and # plotting. Additionally, we set the verbosity to suppress info # messages from scipy.optimize import bisect import nest import nest.voltage_trace nest.sr("M_WARNING setverbosity") nest.ResetKernel() # Second, the simulation parameters are assigned to variables. t_sim = 25000.0 # how long we simulate n_ex = 16000 # size of the excitatory population n_in = 4000 # size of the inhibitory population r_ex = 5.0 # mean rate of the excitatory population r_in = 20.5 # initial rate of the inhibitory population epsc = 45.0 # peak amplitude of excitatory synaptic currents ipsc = -45.0 # peak amplitude of inhibitory synaptic currents d = 1.0 # synaptic delay lower = 15.0 # lower bound of the search interval upper = 25.0 # upper bound of the search interval prec = 0.01 # how close need the excitatory rates be
import json import simulation_parameters import utils import numpy as np import time import tempfile import mynest os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp() import matplotlib matplotlib.use('Agg') import pylab as pl # Load BCPNN synapse and bias-iaf neuron module if (not 'bcpnn_dopamine_synapse' in nest.Models()): nest.sr('(/cfs/klemming/nobackup/b/berthet/code/modules/bcpnndopa_module/share/ml_module/sli) addpath') #t/tully/sequences/share/nest/sli nest.Install('/cfs/klemming/nobackup/b/berthet/code/modules/bcpnndopa_module/lib/nest/ml_module') #t/tully/sequences/lib/nest/pt_module nest.ResetKernel() nest.SetKernelStatus({"overwrite_files": True}) GP = simulation_parameters.global_parameters() GP.write_parameters_to_file() # write_parameters_to_file MUST be called before every simulation params = GP.params t0 = time.time() # ######################## # SIMULATION
import nest print nest.Models() # 'bcpnn_synapse' should NOT show up on_beskow = True if (not 'bcpnn_synapse' in nest.Models('synapses')): if on_beskow: nest.sr( '(/cfs/klemming/nobackup/f/fiebig/170501_Beskow_BCPNN/share/nest/sli) addpath' ) nest.Install( '/cfs/klemming/nobackup/f/fiebig/170501_Beskow_BCPNN/lib/nest/pt_module' ) else: try: nest.Install('pt_module') except: nest.Install('pt_module') status = ('bcpnn_synapse' in nest.Models('synapses')) print 'bcpnn now available', status nest.GetDefaults('bcpnn_synapse')
servo_ids["shin.L"] = setPositionServo(reference_object_name = "obj_shin.L", attached_object_name = "obj_thigh.L", P = PP) servo_ids["shin.R"] = setPositionServo(reference_object_name = "obj_shin.R", attached_object_name = "obj_thigh.R", P = PP) servo_ids["thigh.L"] = setPositionServo(reference_object_name = "obj_thigh.L", attached_object_name = "obj_hips", P = PP) servo_ids["thigh.R"] = setPositionServo(reference_object_name = "obj_thigh.R", attached_object_name = "obj_hips", P = PP) # ================================================================================================================================================= # Network creation ## Nest Kernel Initialization T=8 nest.ResetKernel() nest.SetKernelStatus({"overwrite_files": True, "print_time": True}) nest.SetKernelStatus({"local_num_threads": T}) aa=np.random.randint(1,100) nest.SetKernelStatus({'rng_seeds' : range(aa,aa+T)}) nest.sr("M_ERROR setverbosity") ## Network Parameters neuronModel='aeif_cond_exp' numSC=100 dx=10 dy=5 dz=2 dim=3 inpDim=6 connProb=.1 synType='tsodyks2_synapse' numInp=(numSC*1.) numOut=12 Weight=10.
ll = (V0*mV - mu) / (sigma)/sqrt(2) interval = (ul-ll)/num_iterations tmpsum = 0.0 for cu in range(0,num_iterations+1): u = ll + cu * interval f = exp(u**2)*(1+erf(u)) tmpsum += interval * sqrt(pi) * f r = 1. / (tref*ms + tau_m*ms * tmpsum) ######################################################################################## # Simulation section nest.ResetKernel() nest.sr('20 setverbosity') neurondict = {'V_th':Vth, 'tau_m':tau_m, 'tau_syn_ex':tau_syn_ex,'tau_syn_in':tau_syn_in, 'C_m':Cm, 'E_L':V0, 't_ref':tref, 'V_m': V0, 'V_reset': V0} if (mu*1000) < Vth: neurondict['V_m'] = mu*1000. nest.SetDefaults('iaf_psc_alpha', neurondict) n = nest.Create('iaf_psc_alpha', n_neurons) n_free = nest.Create('iaf_psc_alpha', 1 ,[{'V_th':999999.}]) # high threshold as we want free membrane potential pg = nest.Create('poisson_generator', len(rates), [ {'rate':float(rate_i)} for rate_i in rates] ) vm = nest.Create('voltmeter', 1, [{'record_to':['memory'], 'withtime':True, 'withgid':True, 'interval':.1}]) sd = nest.Create('spike_detector',1, [{'record_to':['memory'], 'withtime':True, 'withgid':True}]) for i, currentpg in enumerate(pg): nest.DivergentConnect([currentpg],n,weight=float(J[i]), delay=0.1) nest.Connect([currentpg],n_free, {'weight':J[i]})
def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params): """ Should be called at the very beginning of a script. extra_params contains any keyword arguments that are required by a given simulator but not by others. """ global tempdir common.setup(timestep, min_delay, max_delay, **extra_params) if 'verbosity' in extra_params: nest_verbosity = extra_params['verbosity'].upper() else: nest_verbosity = "WARNING" nest.sli_run("M_%s setverbosity" % nest_verbosity) if "spike_precision" in extra_params: simulator.state.spike_precision = extra_params["spike_precision"] if extra_params["spike_precision"] == 'off_grid': simulator.state.default_recording_precision = 15 nest.SetKernelStatus({'off_grid_spiking': simulator.state.spike_precision=='off_grid'}) if "recording_precision" in extra_params: simulator.state.default_recording_precision = extra_params["recording_precision"] # clear the sli stack, if this is not done --> memory leak cause the stack increases nest.sr('clear') # reset the simulation kernel nest.ResetKernel() # all NEST to erase previously written files (defaut with all the other simulators) nest.SetKernelStatus({'overwrite_files' : True}) # set tempdir tempdir = tempfile.mkdtemp() tempdirs.append(tempdir) # append tempdir to tempdirs list nest.SetKernelStatus({'data_path': tempdir,}) # set kernel RNG seeds num_threads = extra_params.get('threads') or 1 if 'rng_seeds' in extra_params: rng_seeds = extra_params['rng_seeds'] else: rng_seeds_seed = extra_params.get('rng_seeds_seed') or 42 rng = NumpyRNG(rng_seeds_seed) rng_seeds = (rng.rng.uniform(size=num_threads*num_processes())*100000).astype('int').tolist() logger.debug("rng_seeds = %s" % rng_seeds) nest.SetKernelStatus({'local_num_threads': num_threads, 'rng_seeds' : rng_seeds}) # set resolution nest.SetKernelStatus({'resolution': float(timestep)}) # Set min_delay and max_delay for all synapse models for synapse_model in NEST_SYNAPSE_TYPES: nest.SetDefaults(synapse_model, {'delay' : float(min_delay), 'min_delay': float(min_delay), 'max_delay': float(max_delay)}) simulator.reset() return rank()