def __init__(self): self.model_interpreter = NetPyNEModelInterpreter() # Geppetto model of a created network self.geppetto_model = None self.netParams = specs.NetParams() self.simConfig = specs.SimConfig() self.run_config = model.RunConfig() self.experiments = experiments model.register(metadata) synchronization.startSynchronization(self.__dict__) logging.debug("Initializing the original model") jupyter_geppetto.context = {'netpyne_geppetto': self} # Set running experiments without any subprocess to ERRROR experiments.get_experiments() running_exps = experiments.get_by_states([ model.ExperimentState.PENDING, model.ExperimentState.SIMULATING, model.ExperimentState.INSTANTIATING ]) if not simulations.local.is_running(): [experiments.set_to_error(e) for e in running_exps]
def test_getGeppettoModelSimpleNetwork(self): # object of class NetParams to store the network parameters netParams = specs.NetParams() # object of class SimConfig to store the simulation configuration simConfig = specs.SimConfig() # add dict with params for this pop netParams.popParams['PYR'] = { 'cellModel': 'HH', 'cellType': 'PYR', 'numCells': 20} cellRule = {'conds': {'cellModel': 'HH', 'cellType': 'PYR'}, 'secs': {}} # cell rule dict # soma params dict cellRule['secs']['soma'] = {'geom': {}, 'mechs': {}} cellRule['secs']['soma']['geom'] = { 'diam': 18.8, 'L': 18.8, 'Ra': 123.0} # soma geometry cellRule['secs']['soma']['mechs']['hh'] = { 'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.003, 'el': -70} # soma hh mechanism cellRule['secs']['soma']['vinit'] = -71 # add dict to list of cell params netParams.cellParams['PYR'] = cellRule netParams.synMechParams['AMPA'] = { 'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': 0} netParams.stimSourceParams['bkg'] = { 'type': 'NetStim', 'rate': 10, 'noise': 0.5, 'start': 1} netParams.stimTargetParams['bkg->PYR1'] = {'source': 'bkg', 'conds': { 'pop': 'PYR'}, 'weight': 0.1, 'delay': 'uniform(1,5)'} netParams.connParams['PYR->PYR'] = { 'preConds': {'pop': 'PYR'}, 'postConds': {'pop': 'PYR'}, 'weight': 0.002, # weight of each connection # delay min=0.2, mean=13.0, var = 1.4 'delay': '0.2+normal(13.0,1.4)', 'threshold': 10, # threshold 'convergence': 'uniform(1,15)'} # convergence (num presyn targeting postsyn) is uniformly distributed between 1 and 15 self.getGeppettoModel(netParams, simConfig)
def deleteModel(self, modelParams): try: with redirect_stdout(sys.__stdout__): self.netParams = specs.NetParams() self.simConfig = specs.SimConfig() sim.initialize(specs.NetParams(), specs.SimConfig()) self.geppetto_model = None except Exception: message = "Error while exporting the NetPyNE model" logging.exception(message) return utils.getJSONError(message, sys.exc_info()) try: sim.clearAll() except: logging.exception("Failed to clear simulation") return utils.getJSONReply()
def __init__(self): self.model_interpreter = NetPyNEModelInterpreter() self.netParams = specs.NetParams() self.simConfig = specs.SimConfig() synchronization.startSynchronization(self.__dict__) logging.debug("Initializing the original model") jupyter_geppetto.context = {'netpyne_geppetto': self}
def deleteModel(self, modelParams): try: with redirect_stdout(sys.__stdout__): self.netParams = specs.NetParams() self.simConfig = specs.SimConfig() sim.initialize(specs.NetParams(), specs.SimConfig()) self.geppetto_model = None except: return utils.getJSONError( "Error while exporting the NetPyNE model", sys.exc_info()) try: # This function fails is some keys don't exists # sim.clearAll() # TODO: as part of #264 we should remove the method and use clearAll intstead self.clearSim() except: pass return utils.getJSONReply()
def run_batch(experiment): # Map params to netpyne format params = specs.ODict() grouped_params = [] for param in experiment["params"]: params[param["mapsTo"]] = param["values"] if param["inGroup"]: grouped_params.append(param["mapsTo"]) with open("netParams.json", "r") as f: net_params = json.load(f) net_params = specs.NetParams(net_params["net"]["params"]) with open("simConfig.json", "r") as f: sim_config = json.load(f) sim_config = specs.SimConfig(sim_config["simConfig"]) batch = Batch( cfg=sim_config, netParams=net_params, params=params, groupedParams=grouped_params, seed=experiment.get("seed", None), ) # Label will be subfolder of saveFolder batch.batchLabel = experiment.get("name", "batch_template_run") # Have to overwrite the saveFolder, default goes to root folder which is not always allowed by OS batch.saveFolder = os.getcwd() # For now, we only support grid|list batch.method = experiment.get("method", "grid") # for now, we only support mpi_direct or bulletinboard # * mpi_direct can be started by running batch.py # * mpi_bulletin requires to run "mpiexec -n 4 nrniv -mpi batch.py", otherwise runs in single core run_cfg = experiment.get("runCfg", None) cores = run_cfg.get("cores", None) cores = int(cores) if cores else None if run_cfg: batch.runCfg = { "type": run_cfg.get("type", "mpi_bulletin"), "script": run_cfg.get("script", "run.py"), "skip": run_cfg.get("skip", True), "cores": cores, } batch.run() return batch
def deleteModel(self, modelParams): try: with redirect_stdout(sys.__stdout__): self.netParams = specs.NetParams() self.simConfig = specs.SimConfig() self.netParams.todict() self.netParams.todict() if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() self.geppetto_model = None return utils.getJSONReply() except: return utils.getJSONError( "Error while exporting the NetPyNE model", sys.exc_info())
def main(): args = init() net_params = specs.NetParams() sim_cfg = specs.SimConfig() logging.info("Opening cells") with open(args.cells, "r") as f: cells = json.load(f) logging.debug(cells) logging.info("Init cells") #cell_config.init_cells(net_params, cells) # Load single cell (For debug purposes) cell_config.load_cell(label=cells[0]["label"], cell_name=cells[0]["cell_name"], load_biophysic=True, net_params=net_params) logging.info("Init network parameters") net_config.init_net_params(net_params, cells) logging.info("Init simulation config") sim_config.init_sim_config(sim_cfg) logging.info("Analysing") # These commands can be used to initialize the network simulation before analysis and simulations sim.initialize(simConfig=sim_config, netParams=net_params) sim.net.createPops() sim.net.createCells() sim.net.connectCells() logging.debug("Cells") logging.debug(sim._gatherAllCellTags()[0]) logging.debug(net_params.cellParams.keys()) logging.debug(net_params.popParams.keys()) logging.debug(net_params.synMechParams.keys()) logging.debug("Number of synapse mechanisms: {}".format( len(net_params.synMechParams.keys()))) # TODO: Create synMechs, populations, connections # Simulate and create analysis analysis.analyse(net_params, sim_cfg)
def setNetParams(): """ netParams.py -High-level specifications for M1 network model using NetPyNE """ netParams = specs.NetParams( ) # object of class NetParams to store the network parameters netParams.version = 26 # Cell parameters ## PT cell params (full) netParams.loadCellParamsRule(label='PT_full', fileName=dataFolder + 'PT_full_cellParams.pkl') netParams.popParams['PT5B'] = { 'cellModel': 'HH_full', 'cellType': 'PT', 'numCells': 1, 'y': [700, 750] } ## IT5A cell params (full) netParams.loadCellParamsRule(label='IT5A_full', fileName=dataFolder + 'IT_full_BS1578_cellParams.pkl') netParams.popParams['IT5A'] = { 'cellModel': 'HH_full', 'cellType': 'IT5A', 'numCells': 1, 'y': [700, 750] } ## IT cell params (full) netParams.loadCellParamsRule(label='IT5B_full', fileName=dataFolder + 'IT_full_BS1579_cellParams.pkl') netParams.popParams['IT5B'] = { 'cellModel': 'HH_full', 'cellType': 'IT5B', 'numCells': 1, 'yRange': [700, 750] } return netParams
def set_params(fig_name, NET_TYPE, TASK, SEED, GABA_W, DEV_LIST): seed = SEED GABA_W = GABA_W netParams = specs.NetParams( ) # object of class NetParams to store the network parameters simConfig = specs.SimConfig( ) # object of class SimConfig to store the simulation configuration ############################################################################ # NETWORK PARAMETERS ############################################################################ #### NETWORK PARAMETERS #### # Size and scale - ## The size of the network is defined as a 3D matrix, the scale governs the ## porportion between the stimuli and the network size weights netParams.sizeX, netParams.sizeY, netParams.sizeZ = SIM_PARAMS[NET_TYPE][ 'size'] netParams.scaleConnWeight = SIM_PARAMS[NET_TYPE]['scale'] netParams.scaleConnWeightNetStims = SIM_PARAMS[NET_TYPE]['scale'] # Population parameters ## excitatory cells layer 2/3 - prediction layer netParams.popParams['PYR23'] = { 'cellModel': 'PYR_Hay_asym', 'cellType': 'PYR_asym', 'gridSpacing': 40.0, 'xRange': [20, netParams.sizeX], 'yRange': [.1 * netParams.sizeY, .1 * netParams.sizeY], 'color': 'blue' } ## excitatory cells layer 4 - prediction error layer netParams.popParams['PYR4'] = { 'cellModel': 'PYR_Hay_four', 'cellType': 'PYR_four', 'gridSpacing': 40.0, 'xRange': [20, netParams.sizeX], 'yRange': [.2 * netParams.sizeY, .2 * netParams.sizeY], 'color': 'green' } ## excitatory cells - memory layer netParams.popParams['PYR_memory'] = { 'cellModel': 'PYR_Hay_mem', 'cellType': 'PYR_mem', 'gridSpacing': 40.0, 'xRange': [20, netParams.sizeX], 'yRange': [1 * netParams.sizeY, 1 * netParams.sizeY], 'color': 'purple' } ## inhibitory cells layer 2/3- prediction layer netParams.popParams['BASK23'] = { 'cellModel': 'BASK_Vierling', 'cellType': 'BASK', 'gridSpacing': 80.0, 'yRange': [.1 * netParams.sizeY, .1 * netParams.sizeY], 'color': 'red' } ## inhibitory cells layer 4 - prediction error layer netParams.popParams['BASK4'] = { 'cellModel': 'BASK_Vierling', 'cellType': 'BASK', 'gridSpacing': 80.0, 'yRange': [.2 * netParams.sizeY, .2 * netParams.sizeY], 'color': 'yellow' } #### CELLULAR PARAMETERS #### ## PYR cell of layer 4 properties - defined by the four compartment model cellRule = netParams.importCellParams(label='PYR4', conds={ 'cellType': 'PYR_four', 'cellModel': 'PYR_Hay_four' }, fileName='Cells/fourcompartment.hoc', cellName='fourcompartment') cellRule['secs']['soma']['vinit'] = -80.0 cellRule['secs']['dend']['vinit'] = -80.0 cellRule['secs']['apic_0']['vinit'] = -80.0 cellRule['secs']['apic_1']['vinit'] = -80.0 ## PYR cell 2/3 properties - defined by the asymetrical stripped model cellRule = netParams.importCellParams( label='PYR23', conds={ 'cellType': 'PYR_asym', 'cellModel': 'PYR_Hay_asym' }, fileName='Cells/pyr_23_asym_stripped.hoc', cellName='pyr_23_asym_stripped') ## PYR cell of memory layer - defined by the four compartment model cellRule = netParams.importCellParams( label='PYR_mem', conds={ 'cellType': 'PYR_mem', 'cellModel': 'PYR_Hay_mem' }, fileName='Cells/pyr_23_asym_stripped.hoc', cellName='pyr_23_asym_stripped') # BASK cell properties (all layers) - defined by the fast spiking model cellRule = netParams.importCellParams(label='BASK', conds={ 'cellType': 'BASK', 'cellModel': 'BASK_Vierling' }, fileName='Cells/FS.hoc', cellName='Layer2_basket') #### BIOPHYSICAL PARAMETERS #### # synapic mechanisms ## AMPA // GABA is defined by the Exp2Syn model # It is a two state kinetic scheme synapse where # rise time - tau1, # decay time- tau2 # reversal potential - e # synaptic current- I (dynamic in the simulation) netParams.synMechParams['AMPA'] = { 'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 3.0, 'e': 0.0 } netParams.synMechParams['GABA'] = { 'mod': 'Exp2Syn', 'tau1': 5.0, 'tau2': 12.0, 'e': -75.0 } # AMPASTD is defined by the FDSExp2Syn model # It is a two state kinetic scheme synapse where # rise time - tau1, # decay time- tau2 # facilitation constant - f # facilitation time - tauF # reversal potential - e # fast depression - firing will lower the d1% of the initial # spike within tau_d1 ms # slow depression - firing will lower the d1% of the initial # spike within tau_d1 ms # synaptic current- I (dynamic in the simulation) netParams.synMechParams['AMPASTD'] = { 'mod': 'FDSExp2Syn', 'tau1': 1.0, 'tau2': 3.0, 'e': 0.0, 'f': 0.0, 'tau_F': 94.0, 'd1': 1, 'tau_D1': 380, 'd2': 0.76, 'tau_D2': 2500 } # only depression ## NMDA is defined by the NMDA model # It is a simple synaptic mechanism, first order kinetics of # binding of transmitter to postsynaptic receptors. where # forward (binding) rate - alpha # backward (unbinding) rate - beta # reversal potential - e # (max)conductance - (max)g # synaptic current- I (dynamic in the simulation) netParams.synMechParams['NMDA'] = { 'mod': 'NMDA', 'Alpha': 10.0, 'Beta': 0.015, 'e': 45.0, 'g': 1, 'gmax': 1 } ############################################################################### # STIMULI PARAMETERS ############################################################################### #### STIMULI GENERATION #### # stimuli handler given the network's params s_handler = Simulation_stimuli_Handler( net_x_size=netParams.sizeX, n_pulses=SIM_PARAMS[NET_TYPE]['n_pulses'], spacing=40.0, dev_indexes=DEV_LIST, task=TASK) s_handler.set_task_stimuli() # set external stimuli (i.e sensory input) # and internal stimuli (i.e memory trace) external_pulses_info = s_handler.get_formatted_pulse(external=True) external_pulses_time = s_handler.get_pulse_time(external=True) internal_pulses_info = s_handler.get_formatted_pulse(external=False) internal_pulses_time = s_handler.get_pulse_time(external=False) # set dynamic weights base_stimuli_weight = 0.02 weights_confidence_multiplier = [] added_confidence = 0 for pulse_index in range(SIM_PARAMS[NET_TYPE]['n_pulses']): weights_confidence_multiplier.append(1 + (added_confidence * 0.15)) added_confidence = added_confidence + 1 if pulse_index == DEV_LIST[0]: added_confidence = 0 weights = [i * base_stimuli_weight for i in weights_confidence_multiplier] # generate pulses for t_pulse in external_pulses_info.keys(): # External sensory stimuli # set stimulus name ext_stim_pop_name='Stim_' + \ str(external_pulses_info[t_pulse]['pop_name']) +"_"+\ str(t_pulse) # parametarize stimulus netParams.popParams[ext_stim_pop_name] = { 'cellModel': 'VecStim', 'numCells': 24, 'spkTimes': [0], 'pulses': [{ 'start': t_pulse * 1000.0 + external_pulses_time[0], 'end': t_pulse * 1000.0 + external_pulses_time[1], 'rate': 200, 'noise': 1.0 }] } # set stimulus column ext_x_pyr, ext_x_bask = external_pulses_info[t_pulse]['values'] # connect stimulus to pyramidal cells in layer 4 netParams.connParams[ext_stim_pop_name + '->PYR4'] = { 'preConds': { 'popLabel': ext_stim_pop_name }, 'postConds': { 'popLabel': 'PYR4', 'x': ext_x_pyr }, 'convergence': 1, 'weight': 0.02, 'threshold': 10, 'synMech': 'AMPA' } # connect stimulus to basket cells in layer 4 netParams.connParams[ext_stim_pop_name + '->BASK4'] = { 'preConds': { 'popLabel': ext_stim_pop_name }, 'postConds': { 'popLabel': 'BASK4', 'x': ext_x_bask }, 'convergence': 1, 'weight': 0.02, 'threshold': 10, 'synMech': 'AMPA' } # Internal stimuli - memory trace # set stimulus name int_stim_pop_name='internal_' + \ str(internal_pulses_info[t_pulse]['pop_name']) +"_"+ str(t_pulse) # parametarize stimulus netParams.popParams[int_stim_pop_name] = { 'cellModel': 'VecStim', 'numCells': 24, 'spkTimes': [0], 'pulses': [{ 'start': t_pulse * 1000.0 + internal_pulses_time[0], 'end': t_pulse * 1000.0 + internal_pulses_time[1], 'rate': 200, 'noise': 1.0 }] } # set stimulus column int_x_pyr, int_x_bask = internal_pulses_info[t_pulse]['values'] # connect stimulus to pyramidal cells in memory layer netParams.connParams[int_stim_pop_name + '->'] = { 'preConds': { 'popLabel': int_stim_pop_name }, 'postConds': { 'popLabel': 'PYR_memory', 'x': int_x_pyr }, 'convergence': 1, 'weight': weights[ t_pulse], ## increase weight of internal stim with confidence 'threshold': 10, 'synMech': 'AMPA' } ############################################################################### # CONNECTIVITY PARAMETERS ############################################################################### # Layer 4 intra-laminar connections netParams.connParams['PYR4->PYR4'] = { 'preConds': { 'popLabel': 'PYR4' }, 'postConds': { 'popLabel': 'PYR4' }, 'sec': 'apic_1', 'probability': '0.15*exp(-dist_3D/(4*40.0))', 'weight': [0.0012, 0.0006], 'threshold': 10, 'synMech': ['AMPA', 'NMDA'] } netParams.connParams['PYR4->BASK4'] = { 'preConds': { 'popLabel': 'PYR4' }, 'postConds': { 'popLabel': 'BASK4' }, 'probability': '0.45*exp(-dist_3D/(4*40.0))', 'weight': [0.0012, 0.00013], 'threshold': 10, 'synMech': ['AMPA', 'NMDA'] } netParams.connParams['BASK4->PYR4'] = { 'preConds': { 'popLabel': 'BASK4' }, 'postConds': { 'popLabel': 'PYR4' }, 'probability': '0.6*exp(-dist_3D/(4*40.0))', 'weight': 0.003 * GABA_W, 'threshold': 10, 'synMech': 'GABA' } ''' netParams.connParams['BASK4->BASK4']={ 'preConds': {'popLabel': 'BASK4'}, 'postConds': {'popLabel': 'BASK4'}, 'probability': '0.6*exp(-dist_3D/(4*40.0))', 'weight': 0.0, 'threshold': 10, 'synMech': 'GABA'} ''' # Layer 2/3 intra-laminar connections netParams.connParams['PYR23->PYR23'] = { 'preConds': { 'popLabel': 'PYR23' }, 'postConds': { 'popLabel': 'PYR23' }, 'sec': 'oblique2b', 'probability': '0.15*exp(-dist_3D/(1*40.0))', 'weight': [0.0024, 0.0012], 'threshold': 10, 'synMech': ['AMPA', 'NMDA'] } netParams.connParams['PYR23->BASK23'] = { 'preConds': { 'popLabel': 'PYR23' }, 'postConds': { 'popLabel': 'BASK23' }, 'probability': '0.45*exp(-dist_3D/(4*40.0))', 'weight': [0.0012, 0.00013], 'threshold': 10, 'synMech': ['AMPA', 'NMDA'] } netParams.connParams['BASK23->PYR23'] = { 'preConds': { 'popLabel': 'BASK23' }, 'postConds': { 'popLabel': 'PYR23' }, 'sec': 'oblique2a', 'probability': '0.6*exp(-dist_3D/(2*40.0))', 'weight': 0.1 * GABA_W, 'threshold': 10, 'synMech': 'GABA' } '''netParams.connParams['BASK23->BASK23']={ 'preConds': {'popLabel': 'BASK23'}, 'postConds': {'popLabel': 'BASK23'}, 'probability': '0.6*exp(-dist_3D/(4*40.0))', 'weight': 0.0, 'threshold': 10, 'synMech': 'GABA'}''' ## memory layer netParams.connParams['PYR_memory->PYR_memory'] = { 'preConds': { 'popLabel': 'PYR_memory' }, 'postConds': { 'popLabel': 'PYR_memory' }, 'sec': 'oblique2b', 'probability': '0.15*exp(-dist_3D/(1*40.0))', 'weight': [0.0012, 0.0006], 'threshold': 10, 'synMech': ['AMPA', 'NMDA'] } ### inter-laminar connections netParams.connParams['PYR4->PYR23'] = { 'preConds': { 'popLabel': 'PYR4' }, 'postConds': { 'popLabel': 'PYR23' }, 'sec': 'basal2b', 'probability': '.5*exp(-dist_2D/(1*40.0))', #'0.5*exp(-dist_2D/(2*40.0))', 'weight': 0.03, #3 #0.15 #0.03 #0.3 'threshold': 10, 'synMech': 'AMPASTD' } netParams.connParams['PYR4->BASK23'] = { 'preConds': { 'popLabel': 'PYR4' }, 'postConds': { 'popLabel': 'BASK23' }, 'probability': '0.8*exp(-dist_2D/(2*40.0))', 'weight': 0.00015, 'threshold': 10, 'synMech': 'AMPASTD' } netParams.connParams['PYR_memory->BASK23'] = { 'preConds': { 'popLabel': 'PYR_memory' }, 'postConds': { 'popLabel': 'BASK23' }, 'probability': '0.8*exp(-dist_3D/(2*40.0))', # 0.8*exp(-dist_3D/(3*40.0))... 'weight': 0.01, #0.015,#0.00015, 'threshold': 10, 'synMech': 'AMPASTD' } ######################################################################## # SIMULATION PARAMETERS ######################################################################## # Simulation parameters simConfig.hParams['celsius'] = 30.0 simConfig.duration = SIM_PARAMS[NET_TYPE][ 'duration'] # Duration of the simulation, in ms simConfig.dt = 0.05 # Internal integration timestep to use simConfig.seeds = { 'conn': seed, 'stim': seed, 'loc': seed } # Seeds for randomizers (conn., input stim. and cell loc.) simConfig.createNEURONObj = 1 # create HOC objects when instantiating network simConfig.createPyStruct = 1 # create Python structure (simulator-independent) when instantiating network simConfig.verbose = False # show detailed messages simConfig.hParams['cai0_ca_ion'] = 0.0001 simConfig.printPopAvgRates = True # Recording simConfig.recordCells = ['all'] # which cells to record from #recod membrane potential ''' simConfig.recordTraces={} simConfig.recordTraces['BASK23'] = {'sec':'soma','loc':0.5,'var':'v', 'conds':{'pop':'BASK23', 'cellType':'BASK'}} simConfig.recordTraces['PYR4_PYR23'] =\ {'Vsoma':{'sec':'soma','loc':0.5,'var':'v'}, 'PYR4-PYR23':{'sec':'basal2b','loc':0.5, 'var':'AMPASTD','conds':{'cellType':'PYR23'}}} simConfig.recordTraces['PYR23_PYR23_AMPA'] =\ {'Vsoma':{'sec':'soma','loc':0.5,'var':'v'}, 'PYR23-PYR23':{'sec':'oblique2b','loc':0.5, 'var':'AMPA','conds':{'cellType':'PYR23'}}} simConfig.recordTraces['PYR23_PYR23_NMDA'] =\ {'Vsoma':{'sec':'soma','loc':0.5,'var':'v'}, 'PYR23-PYR23':{'sec':'oblique2b','loc':0.5, 'var':'NMDA','conds':{'cellType':'PYR23'}}} ''' simConfig.recordStim = True # record spikes of cell stims simConfig.recordStep = 0.1 # Step size in ms to save data (eg. V traces, LFP, etc) external_input_populations = s_handler.stim_pop_values['external'] x_electrodes_locations=[ [x_value[0]+1, 0, \ netParams.sizeZ/2] for x_value in \ [external_input_populations[ext_pop]['x_values'][0] for ext_pop in external_input_populations] ] # electrodes at the stim frequency simConfig.recordLFP = x_electrodes_locations # Saving simConfig.saveFolder = 'output_files/' simConfig.filename = 'output_files/{}'.format( fig_name) # Set file output name simConfig.saveFileStep = 1000 # step size in ms to save data to disk simConfig.savePickle = False simConfig.saveJson = True # Analysis and plotting simConfig.analysis['plotRaster'] = { 'saveFig': 'output_files/{}_raster.png'.format(fig_name) } #simConfig.analysis['plotSpikeHist']={ # 'include': ['PYR23','PYR_memory'], # 'yaxis':'count', # 'graphType':'line', # 'saveFig': 'output_files/{}_plotSpikeHist.png'.format(fig_name)} simConfig.analysis['plotLFP'] = { 'includeAxon': False, 'plots': ['timeSeries'], 'saveFig': 'output_files/{}_LFP.png'.format(fig_name) } simConfig.analysis['plotConn'] = { 'include': ['all'], 'feature': 'strength', 'orderBy': 'gid', 'figSize': (10, 10), 'groupBy': 'pop', 'saveFig': 'output_files/{}_conn.png'.format(fig_name) } #Plot 2D net cells and connections #simConfig.analysis['plot2Dnet']={'view': 'xy', # 'include': ['PYR23', 'PYR4', 'BASK23', 'BASK4', 'PYR_memory'], # 'showConns': True , # 'saveFig': 'output_files/{}_2Dnet.png'.format(fig_name)} return (netParams, simConfig)
def exportHLS(self, args): def convert2bool(string): return string.replace('true', 'True').replace('false', 'False').replace( 'null', 'False') def header(title, spacer='-'): return '\n# ' + title.upper() + ' ' + spacer * (77 - len(title)) + '\n' try: params = ['popParams', 'cellParams', 'synMechParams'] params += ['connParams', 'stimSourceParams', 'stimTargetParams'] fname = args['fileName'] if args['fileName'][ -3:] == '.py' else args['fileName'] + '.py' with open(fname, 'w') as script: script.write('from netpyne import specs, sim\n') script.write(header('documentation')) script.write( "''' Script generated with NetPyNE-UI. Please visit:\n") script.write( " - https://www.netpyne.org\n - https://github.com/MetaCell/NetPyNE-UI\n'''\n" ) script.write(header('script', spacer='=')) script.write('netParams = specs.NetParams()\n') script.write('simConfig = specs.SimConfig()\n') script.write(header('single value attributes')) for attr, value in list(self.netParams.__dict__.items()): if attr not in params: if value != getattr(specs.NetParams(), attr): script.write('netParams.' + attr + ' = ') script.write( convert2bool(json.dumps(value, indent=4)) + '\n') script.write(header('network attributes')) for param in params: for key, value in list( getattr(self.netParams, param).items()): script.write("netParams." + param + "['" + key + "'] = ") script.write( convert2bool(json.dumps(value, indent=4)) + '\n') script.write(header('network configuration')) for attr, value in list(self.simConfig.__dict__.items()): if value != getattr(specs.SimConfig(), attr): script.write('simConfig.' + attr + ' = ') script.write( convert2bool(json.dumps(value, indent=4)) + '\n') script.write(header('create simulate analyze network')) script.write( '# sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)\n' ) script.write(header('end script', spacer='=')) with open(fname) as f: return f.read() except: return utils.getJSONError( "Error while importing the NetPyNE model", sys.exc_info())
def loadModel(self, args): """ Imports a model stored as file in json format. :param args: :return: """ def remove(dictionary): # remove reserved keys such as __dict__, __Method__, etc # they appear when we do sim.loadAll(json_file) if isinstance(dictionary, dict): for key, value in list(dictionary.items()): if key.startswith('__'): dictionary.pop(key) else: remove(value) if not any([ args[option] for option in ['loadNetParams', 'loadSimCfg', 'loadSimData', 'loadNet'] ]): return utils.getJSONError( "Error while loading data", 'You have to select at least one option') try: owd = os.getcwd() compileModMechFiles(args['compileMod'], args['modFolder']) except: return utils.getJSONError("Error while importing/compiling mods", sys.exc_info()) finally: os.chdir(owd) try: with redirect_stdout(sys.__stdout__): sim.initialize() wake_up_geppetto = False if all([ args[option] for option in ['loadNetParams', 'loadSimCfg', 'loadSimData', 'loadNet'] ]): wake_up_geppetto = True if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.initialize() sim.loadAll(args['jsonModelFolder']) self.netParams = sim.net.params self.simConfig = sim.cfg remove(self.netParams.todict()) remove(self.simConfig.todict()) else: if args['loadNet']: wake_up_geppetto = True if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.initialize() sim.loadNet(args['jsonModelFolder']) if args['loadSimData']: # TODO (https://github.com/Neurosim-lab/netpyne/issues/360) wake_up_geppetto = True if not self.doIhaveInstOrSimData()['haveInstance']: sim.create(specs.NetParams(), specs.SimConfig()) sim.net.defineCellShapes() sim.gatherData(gatherLFP=False) sim.loadSimData(args['jsonModelFolder']) if args['loadSimCfg']: sim.loadSimCfg(args['jsonModelFolder']) self.simConfig = sim.cfg remove(self.simConfig.todict()) if args['loadNetParams']: if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.loadNetParams(args['jsonModelFolder']) self.netParams = sim.net.params remove(self.netParams.todict()) if wake_up_geppetto: if len(sim.net.cells) > 0: section = list(sim.net.cells[0].secs.keys())[0] if 'pt3d' not in list( sim.net.cells[0].secs[section].geom.keys()): sim.net.defineCellShapes() sim.gatherData() sim.loadSimData(args['jsonModelFolder']) sim.gatherData() self.geppetto_model = self.model_interpreter.getGeppettoModel( sim) return json.loads( GeppettoModelSerializer.serialize(self.geppetto_model)) else: return utils.getJSONReply() except: return utils.getJSONError("Error while loading the NetPyNE model", sys.exc_info())
spiketimes.append(np.sort(spikevec)) return spiketimes ################################################################################ ### LOAD MAIN PARAMETER SETS ################################################################################ # Import parameter dictionaries for NETPYNE from TCModel_Params import PopulationParams fullParams = PopulationParams() # Create class NetParams object to store imported parameters netParams = specs.NetParams(netParamsDict=fullParams.netParamsDict) # Importing cell parameters from .hoc files for labels in fullParams.Y_pop_ids: for label_id in labels: label, conds, cellName, fileName = createImports( fullParams.Y_importParams[label_id]) # NOTE: cellParams[X] must be the label and not the label_id netParams.cellParams[label] = netParams.importCellParams( label=label, conds=conds, cellName=cellName, fileName=fileName) ################################################################################ ##### MAIN SIMULATION ################################################################################
from netpyne import specs npar = specs.NetParams() npar.popParams.axA = {'cellType': 'axA', 'cellModel': 'ax', 'numCells': 1} npar.cellParams['PYRrule'] = { 'conds': { 'cellType': 'axA', 'cellModel': 'ax' }, 'secs': { 'axon': { 'geom': { 'diam': 1, 'L': 5000, 'Ra': 123.0, 'nseg': 1000 }, 'ions': { 'k': { 'e': -77.0 }, 'na': { 'e': 50.0 } }, 'mechs': { 'ina2005': { 'gnabar': 0.3 }, 'ik2005': { 'gkfbar': 0.3
def loadModel(self, args): """ Imports a model stored as file in json format. :param args: :return: """ if not any([ args[option] for option in ['loadNetParams', 'loadSimCfg', 'loadSimData', 'loadNet'] ]): return utils.getJSONError( "Error while loading data", 'You have to select at least one option') try: owd = os.getcwd() compileModMechFiles(args['compileMod'], args['modFolder']) except Exception: message = "Error while importing/compiling mods" logging.exception(message) return utils.getJSONError(message, sys.exc_info()) finally: os.chdir(owd) try: with redirect_stdout(sys.__stdout__): sim.initialize() wake_up_geppetto = False if all([ args[option] for option in ['loadNetParams', 'loadSimCfg', 'loadSimData', 'loadNet'] ]): wake_up_geppetto = True if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.initialize() sim.loadAll(args['jsonModelFolder']) self.netParams = sim.net.params self.simConfig = sim.cfg netpyne_ui_utils.remove(self.netParams.todict()) netpyne_ui_utils.remove(self.simConfig.todict()) else: if args['loadNet']: wake_up_geppetto = True if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.initialize() sim.loadNet(args['jsonModelFolder']) # TODO (https://github.com/Neurosim-lab/netpyne/issues/360) if args['loadSimData']: wake_up_geppetto = True if not self.doIhaveInstOrSimData()['haveInstance']: sim.create(specs.NetParams(), specs.SimConfig()) sim.net.defineCellShapes() sim.gatherData(gatherLFP=False) sim.loadSimData(args['jsonModelFolder']) if args['loadSimCfg']: sim.loadSimCfg(args['jsonModelFolder']) self.simConfig = sim.cfg netpyne_ui_utils.remove(self.simConfig.todict()) if args['loadNetParams']: if self.doIhaveInstOrSimData()['haveInstance']: sim.clearAll() sim.loadNetParams(args['jsonModelFolder']) self.netParams = sim.net.params netpyne_ui_utils.remove(self.netParams.todict()) if wake_up_geppetto: self._create3D_shapes(args['jsonModelFolder']) # TODO: Fix me - gatherData will remove allSimData! sim.gatherData() self.geppetto_model = self.model_interpreter.getGeppettoModel( sim) return json.loads( GeppettoModelSerializer.serialize(self.geppetto_model)) else: return utils.getJSONReply() except Exception: message = "Error while loading the NetPyNE model" logging.exception(message) return utils.getJSONError(message, sys.exc_info())
def createPythonScript(fname, netParams, simConfig): """ Function for/to <short description of `netpyne.conversion.pythonScript.createPythonScript`> Parameters ---------- fname : <type> <Short description of fname> **Default:** *required* netParams : <type> <Short description of netParams> **Default:** *required* simConfig : <type> <Short description of simConfig> **Default:** *required* """ import sys import json from netpyne import specs def replace(string): # convert bools and null from json to python return string.replace('true', 'True').replace('false', 'False').replace('null', '""') def remove(dictionary): # remove reserved keys such as __str__, __dict__ if isinstance(dictionary, dict): for key, value in list(dictionary.items()): if key.startswith('__'): dictionary.pop(key) else: remove(value) def addAttrToScript(attr, value, obj_name, class_instance, file): # write line of netpyne code if is different from default value if not hasattr(class_instance, attr) or value != getattr(class_instance, attr): file.write(obj_name + '.' + attr + ' = ' + replace(json.dumps(value, indent=4)) + '\n') def header(title, spacer='-'): # writes a header for the section return '\n# ' + title.upper() + ' ' + spacer * (77 - len(title)) + '\n' if isinstance(netParams, specs.NetParams): # convert netpyne.specs.netParams class to dict class netParams = netParams.todict() if isinstance(simConfig, specs.SimConfig): simConfig = simConfig.todict() # remove reserved keys like __str__, __dict__ remove(netParams) remove(simConfig) # network parameters params = ['popParams', 'cellParams', 'synMechParams'] params += ['connParams', 'stimSourceParams', 'stimTargetParams'] try: with open(fname if fname.endswith('.py') else fname + '.py', 'w') as file: file.write('from netpyne import specs, sim\n') file.write(header('documentation')) file.write("''' Please visit: https://www.netpyne.org '''\n") file.write( "# Python script automatically generated by NetPyNE v%s from netParams and simConfig objects\n" % __version__) file.write(header('script', spacer='=')) file.write('netParams = specs.NetParams()\n') file.write('simConfig = specs.SimConfig()\n') file.write(header('single valued attributes')) for key, value in list(netParams.items()): if key not in params: addAttrToScript(key, value, 'netParams', specs.NetParams(), file) file.write(header('network attributes')) for param in params: for key, value in list(netParams[param].items()): file.write("netParams." + param + "['" + key + "'] = " + replace(json.dumps(value, indent=4)) + '\n') file.write(header('network configuration')) for key, value in list(simConfig.items()): addAttrToScript(key, value, 'simConfig', specs.SimConfig(), file) file.write(header('create simulate analyze network')) file.write('import sys\n') file.write('if not "-neuroml" in sys.argv:\n') file.write( ' sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)\n' ) file.write('else:\n') file.write( ' nml_reference = "NetPyNENetwork" if not simConfig.filename else simConfig.filename\n' ) file.write( ' sim.createExportNeuroML2(netParams=netParams, simConfig=simConfig, reference = nml_reference)\n' ) file.write(header('end script', spacer='=')) print(("script saved on " + fname)) except: print(('error saving file: %s' % (sys.exc_info()[1])))
# -*- coding: utf-8 -*- """ Created on Fri Mar 10 15:48:51 2017 @author: heitor """ from netpyne import sim, specs import numpy as np from matplotlib import pyplot as plt from DetectPA import getSpikes from mu_type import * from QForceFunc import forceFromSpikes from QSOFilter import forceSOF netParams = specs.NetParams() simConfig = specs.SimConfig() netParams.popParams['Pop1'] = { 'cellType': 'MED', 'cellModel': 'NAPP', 'numCells': 1 } cellRule = { 'conds': { 'cellType': 'MED', 'cellModel': 'NAPP' }, 'secs': { 'soma': { 'geom': {
def importModel(self, modelParameters): """ Imports a model stored in form of Python files. :param modelParameters: :return: """ if self.doIhaveInstOrSimData()['haveInstance']: # TODO: this must be integrated into the general lifecycle of "model change -> simulate" # Shouldn't be specific to Import sim.clearAll() try: # Get Current dir owd = os.getcwd() compileModMechFiles(modelParameters['compileMod'], modelParameters['modFolder']) with redirect_stdout(sys.__stdout__): # NetParams net_params_path = str(modelParameters["netParamsPath"]) sys.path.append(net_params_path) os.chdir(net_params_path) # Import Module net_params_module_name = importlib.import_module( str(modelParameters["netParamsModuleName"])) # Import Model attributes self.netParams = getattr( net_params_module_name, str(modelParameters["netParamsVariable"])) if isinstance(self.netParams, dict): self.netParams = specs.NetParams(self.netParams) if isinstance(self.simConfig, dict): self.simConfig = specs.SimConfig(self.simConfig) for key, value in self.netParams.cellParams.items(): if hasattr(value, 'todict'): self.netParams.cellParams[key] = value.todict() # SimConfig sim_config_path = str(modelParameters["simConfigPath"]) sys.path.append(sim_config_path) os.chdir(sim_config_path) # Import Module sim_config_module_name = importlib.import_module( str(modelParameters["simConfigModuleName"])) # Import Model attributes self.simConfig = getattr( sim_config_module_name, str(modelParameters["simConfigVariable"])) # TODO: when should sim.initialize be called? # Only on import or better before every simulation or network instantiation? sim.initialize() return utils.getJSONReply() except Exception: message = "Error while importing the NetPyNE model" logging.exception(message) return utils.getJSONError(message, sys.exc_info()) finally: os.chdir(owd)
def exportHLS(self, args): def convert2bool(string): return string.replace('true', 'True').replace('false', 'False').replace( 'null', 'False') def header(title, spacer='-'): return '\n# ' + title.upper() + ' ' + spacer * (77 - len(title)) + '\n' try: params = ['popParams', 'cellParams', 'synMechParams'] params += ['connParams', 'stimSourceParams', 'stimTargetParams'] fname = args['fileName'] if not fname: # default option fname = 'output.py' if not fname[-3:] == '.py': fname = f"{fname}.py" # TODO: use methods offered by netpyne to create this script! with open(fname, 'w') as script: script.write("from netpyne import specs, sim\n") script.write(header("documentation")) script.write( "Script generated with NetPyNE-UI. Please visit:\n") script.write( " - https://www.netpyne.org\n - https://github.com/MetaCell/NetPyNE-UI\n\n" ) script.write(header("script", spacer="=")) script.write("netParams = specs.NetParams()\n") script.write("simConfig = specs.SimConfig()\n") script.write(header("single value attributes")) for attr, value in list(self.netParams.__dict__.items()): if attr not in params: if value != getattr(specs.NetParams(), attr): script.write("netParams." + attr + " = ") script.write( convert2bool(json.dumps(value, indent=4)) + "\n") script.write(header("network attributes")) for param in params: for key, value in list( getattr(self.netParams, param).items()): script.write("netParams." + param + "[" + key + "] = ") script.write( convert2bool(json.dumps(value, indent=4)) + "\n") script.write(header("network configuration")) for attr, value in list(self.simConfig.__dict__.items()): if value != getattr(specs.SimConfig(), attr): script.write("simConfig." + attr + " = ") script.write( convert2bool(json.dumps(value, indent=4)) + "\n") script.write(header("create simulate analyze network")) script.write( "# sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)\n" ) script.write(header("end script", spacer="=")) with open(fname) as f: file_b64 = base64.b64encode(bytes(f.read(), 'utf-8')).decode() export_info = {"fileContent": file_b64, "fileName": fname} return export_info except Exception: message = "Error while exporting NetPyNE model to python" logging.exception(message) return utils.getJSONError(message, sys.exc_info())
def generate_and_run(simulation, simulator, network=None, return_results=False, base_dir=None, target_dir=None, num_processors=1): """ Generates the network in the specified simulator and runs, if appropriate """ if network == None: network = load_network_json(simulation.network) print_v("Generating network %s and running in simulator: %s..." % (network.id, simulator)) if simulator == 'NEURON': _generate_neuron_files_from_neuroml(network, dir_for_mod_files=target_dir) from neuromllite.NeuronHandler import NeuronHandler nrn_handler = NeuronHandler() for c in network.cells: if c.neuroml2_source_file: src_dir = os.path.dirname( os.path.abspath(c.neuroml2_source_file)) nrn_handler.executeHoc('load_file("%s/%s.hoc")' % (src_dir, c.id)) generate_network(network, nrn_handler, generate_network, base_dir) if return_results: raise NotImplementedError( "Reloading results not supported in Neuron yet...") elif simulator.lower() == 'sonata': # Will not "run" obviously... from neuromllite.SonataHandler import SonataHandler sonata_handler = SonataHandler() generate_network(network, sonata_handler, always_include_props=True, base_dir=base_dir) print_v("Done with Sonata...") elif simulator.lower().startswith('graph'): # Will not "run" obviously... from neuromllite.GraphVizHandler import GraphVizHandler, engines try: if simulator[-1].isalpha(): engine = engines[simulator[-1]] level = int(simulator[5:-1]) else: engine = 'dot' level = int(simulator[5:]) except Exception as e: print_v("Error parsing: %s: %s" % (simulator, e)) print_v( "Graphs of the network structure can be generated at many levels of detail (1-6, required) and laid out using GraphViz engines (d - dot (default); c - circo; n - neato; f - fdp), so use: -graph3c, -graph2, -graph4f etc." ) return handler = GraphVizHandler(level, engine=engine, nl_network=network) generate_network(network, handler, always_include_props=True, base_dir=base_dir) print_v("Done with GraphViz...") elif simulator.lower().startswith('matrix'): # Will not "run" obviously... from neuromllite.MatrixHandler import MatrixHandler try: level = int(simulator[6:]) except: print_v("Error parsing: %s" % simulator) print_v( "Matrices of the network structure can be generated at many levels of detail (1-n, required), so use: -matrix1, -matrix2, etc." ) return handler = MatrixHandler(level, nl_network=network) generate_network(network, handler, always_include_props=True, base_dir=base_dir) print_v("Done with MatrixHandler...") elif simulator.startswith('PyNN'): #_generate_neuron_files_from_neuroml(network) simulator_name = simulator.split('_')[1].lower() from neuromllite.PyNNHandler import PyNNHandler pynn_handler = PyNNHandler(simulator_name, simulation.dt, network.id) syn_cell_params = {} for proj in network.projections: synapse = network.get_child(proj.synapse, 'synapses') post_pop = network.get_child(proj.postsynaptic, 'populations') if not post_pop.component in syn_cell_params: syn_cell_params[post_pop.component] = {} for p in synapse.parameters: post = '' if synapse.pynn_receptor_type == "excitatory": post = '_E' elif synapse.pynn_receptor_type == "inhibitory": post = '_I' syn_cell_params[post_pop.component][ '%s%s' % (p, post)] = synapse.parameters[p] cells = {} for c in network.cells: if c.pynn_cell: cell_params = {} if c.parameters: for p in c.parameters: cell_params[p] = evaluate(c.parameters[p], network.parameters) dont_set_here = [ 'tau_syn_E', 'e_rev_E', 'tau_syn_I', 'e_rev_I' ] for d in dont_set_here: if d in c.parameters: raise Exception( 'Synaptic parameters like %s should be set ' + 'in individual synapses, not in the list of parameters associated with the cell' % d) if c.id in syn_cell_params: cell_params.update(syn_cell_params[c.id]) print_v("Creating cell with params: %s" % cell_params) exec('cells["%s"] = pynn_handler.sim.%s(**cell_params)' % (c.id, c.pynn_cell)) if c.pynn_cell != 'SpikeSourcePoisson': exec( "cells['%s'].default_initial_values['v'] = cells['%s'].parameter_space['v_rest'].base_value" % (c.id, c.id)) pynn_handler.set_cells(cells) receptor_types = {} for s in network.synapses: if s.pynn_receptor_type: receptor_types[s.id] = s.pynn_receptor_type pynn_handler.set_receptor_types(receptor_types) for input_source in network.input_sources: if input_source.pynn_input: pynn_handler.add_input_source(input_source) generate_network(network, pynn_handler, always_include_props=True, base_dir=base_dir) for pid in pynn_handler.populations: pop = pynn_handler.populations[pid] if 'all' in simulation.recordTraces or pop.label in simulation.recordTraces: if pop.can_record('v'): pop.record('v') pynn_handler.sim.run(simulation.duration) pynn_handler.sim.end() traces = {} events = {} if not 'NeuroML' in simulator: from neo.io import PyNNTextIO for pid in pynn_handler.populations: pop = pynn_handler.populations[pid] if 'all' in simulation.recordTraces or pop.label in simulation.recordTraces: filename = "%s.%s.v.dat" % (simulation.id, pop.label) all_columns = [] print_v("Writing data for %s to %s" % (pop.label, filename)) for i in range(len(pop)): if pop.can_record('v'): ref = '%s[%i]' % (pop.label, i) traces[ref] = [] data = pop.get_data('v', gather=False) for segment in data.segments: vm = segment.analogsignals[0].transpose()[i] if len(all_columns) == 0: tt = np.array([ t * simulation.dt / 1000. for t in range(len(vm)) ]) all_columns.append(tt) vm_si = [float(v / 1000.) for v in vm] traces[ref] = vm_si all_columns.append(vm_si) times_vm = np.array(all_columns).transpose() np.savetxt(filename, times_vm, delimiter='\t', fmt='%s') if return_results: _print_result_info(traces, events) return traces, events elif simulator == 'NetPyNE': if target_dir == None: target_dir = './' _generate_neuron_files_from_neuroml(network, dir_for_mod_files=target_dir) from netpyne import specs from netpyne import sim # Note NetPyNE from this branch is required: https://github.com/Neurosim-lab/netpyne/tree/neuroml_updates from netpyne.conversion.neuromlFormat import NetPyNEBuilder import pprint pp = pprint.PrettyPrinter(depth=6) netParams = specs.NetParams() simConfig = specs.SimConfig() netpyne_handler = NetPyNEBuilder(netParams, simConfig=simConfig, verbose=True) generate_network(network, netpyne_handler, base_dir=base_dir) netpyne_handler.finalise() simConfig = specs.SimConfig() simConfig.tstop = simulation.duration simConfig.duration = simulation.duration simConfig.dt = simulation.dt simConfig.seed = simulation.seed simConfig.recordStep = simulation.dt simConfig.recordCells = ['all'] simConfig.recordTraces = {} for pop in netpyne_handler.popParams.values(): if 'all' in simulation.recordTraces or pop.id in simulation.recordTraces: for i in pop['cellsList']: id = pop['pop'] index = i['cellLabel'] simConfig.recordTraces['v_%s_%s' % (id, index)] = { 'sec': 'soma', 'loc': 0.5, 'var': 'v', 'conds': { 'pop': id, 'cellLabel': index } } simConfig.saveDat = True print_v("NetPyNE netParams: ") pp.pprint(netParams.todict()) #print_v("NetPyNE simConfig: ") #pp.pprint(simConfig.todict()) sim.initialize( netParams, simConfig) # create network object and set cfg and net params sim.net.createPops() cells = sim.net.createCells( ) # instantiate network cells based on defined populations for proj_id in netpyne_handler.projection_infos.keys(): projName, prePop, postPop, synapse, ptype = netpyne_handler.projection_infos[ proj_id] print_v("Creating connections for %s (%s): %s->%s via %s" % (projName, ptype, prePop, postPop, synapse)) preComp = netpyne_handler.pop_ids_vs_components[prePop] for conn in netpyne_handler.connections[projName]: pre_id, pre_seg, pre_fract, post_id, post_seg, post_fract, delay, weight = conn #connParam = {'delay':delay,'weight':weight,'synsPerConn':1, 'sec':post_seg, 'loc':post_fract, 'threshold':threshold} connParam = { 'delay': delay, 'weight': weight, 'synsPerConn': 1, 'sec': post_seg, 'loc': post_fract } if ptype == 'electricalProjection': if weight != 1: raise Exception( 'Cannot yet support inputs where weight !=1!') connParam = { 'synsPerConn': 1, 'sec': post_seg, 'loc': post_fract, 'gapJunction': True, 'weight': weight } else: connParam = { 'delay': delay, 'weight': weight, 'synsPerConn': 1, 'sec': post_seg, 'loc': post_fract } #'threshold': threshold} connParam['synMech'] = synapse if post_id in sim.net.gid2lid: # check if postsyn is in this node's list of gids sim.net._addCellConn(connParam, pre_id, post_id) stims = sim.net.addStims( ) # add external stimulation to cells (IClamps etc) simData = sim.setupRecording( ) # setup variables to record for each cell (spikes, V traces, etc) sim.runSim() # run parallel Neuron simulation sim.gatherData() # gather spiking data and cell info from each node sim.saveData( ) # save params, cell info and sim output to file (pickle,mat,txt,etc) if return_results: raise NotImplementedError( "Reloading results not supported in NetPyNE yet...") elif simulator == 'jNeuroML' or simulator == 'jNeuroML_NEURON' or simulator == 'jNeuroML_NetPyNE': from pyneuroml.lems import generate_lems_file_for_neuroml from pyneuroml import pynml lems_file_name = 'LEMS_%s.xml' % simulation.id nml_file_name, nml_doc = generate_neuroml2_from_network( network, base_dir=base_dir, target_dir=target_dir) included_files = ['PyNN.xml'] for c in network.cells: if c.lems_source_file: included_files.append(c.lems_source_file) ''' if network.cells: for c in network.cells: included_files.append(c.neuroml2_source_file) ''' if network.synapses: for s in network.synapses: if s.lems_source_file: included_files.append(s.lems_source_file) print_v("Generating LEMS file prior to running in %s" % simulator) pops_plot_save = [] pops_spike_save = [] gen_plots_for_quantities = {} gen_saves_for_quantities = {} for p in network.populations: if simulation.recordTraces and ('all' in simulation.recordTraces or p.id in simulation.recordTraces): pops_plot_save.append(p.id) if simulation.recordSpikes and ('all' in simulation.recordSpikes or p.id in simulation.recordSpikes): pops_spike_save.append(p.id) if simulation.recordRates and ('all' in simulation.recordRates or p.id in simulation.recordRates): size = evaluate(p.size, network.parameters) for i in range(size): quantity = '%s/%i/%s/r' % (p.id, i, p.component) gen_plots_for_quantities['%s_%i_r' % (p.id, i)] = [quantity] gen_saves_for_quantities['%s_%i.r.dat' % (p.id, i)] = [quantity] if simulation.recordVariables: for var in simulation.recordVariables: to_rec = simulation.recordVariables[var] if ('all' in to_rec or p.id in to_rec): size = evaluate(p.size, network.parameters) for i in range(size): quantity = '%s/%i/%s/%s' % (p.id, i, p.component, var) gen_plots_for_quantities['%s_%i_%s' % (p.id, i, var)] = [ quantity ] gen_saves_for_quantities['%s_%i.%s.dat' % (p.id, i, var)] = [ quantity ] generate_lems_file_for_neuroml( simulation.id, nml_file_name, network.id, simulation.duration, simulation.dt, lems_file_name, target_dir=target_dir if target_dir else '.', nml_doc= nml_doc, # Use this if the nml doc has already been loaded (to avoid delay in reload) include_extra_files=included_files, gen_plots_for_all_v=False, plot_all_segments=False, gen_plots_for_quantities= gen_plots_for_quantities, # Dict with displays vs lists of quantity paths gen_plots_for_only_populations= pops_plot_save, # List of populations, all pops if = [] gen_saves_for_all_v=False, save_all_segments=False, gen_saves_for_only_populations= pops_plot_save, # List of populations, all pops if = [] gen_saves_for_quantities= gen_saves_for_quantities, # Dict with file names vs lists of quantity paths gen_spike_saves_for_all_somas=False, gen_spike_saves_for_only_populations= pops_spike_save, # List of populations, all pops if = [] gen_spike_saves_for_cells= {}, # Dict with file names vs lists of quantity paths spike_time_format='ID_TIME', copy_neuroml=True, lems_file_generate_seed=12345, report_file_name='report.%s.txt' % simulation.id, simulation_seed=simulation.seed if simulation.seed else 12345, verbose=True) lems_file_name = _locate_file(lems_file_name, target_dir) if simulator == 'jNeuroML': results = pynml.run_lems_with_jneuroml( lems_file_name, nogui=True, load_saved_data=return_results, reload_events=return_results) elif simulator == 'jNeuroML_NEURON': results = pynml.run_lems_with_jneuroml_neuron( lems_file_name, nogui=True, load_saved_data=return_results, reload_events=return_results) elif simulator == 'jNeuroML_NetPyNE': results = pynml.run_lems_with_jneuroml_netpyne( lems_file_name, nogui=True, verbose=True, load_saved_data=return_results, reload_events=return_results, num_processors=num_processors) print_v("Finished running LEMS file %s in %s (returning results: %s)" % (lems_file_name, simulator, return_results)) if return_results: traces, events = results _print_result_info(traces, events) return results # traces, events =
def set_params(input_rs_threshold): netParams = specs.NetParams() # object of class NetParams to store the network parameters simConfig = specs.SimConfig() # object of class SimConfig to store the simulation configuration ############################################################################### # NETWORK PARAMETERS ############################################################################### # Population parameters netParams.popParams['PYR'] = {'cellModel': 'PYR', 'cellType': 'PYR', 'numCells': 1, 'color': 'blue'} # Cell parameters ## PYR cell properties cellRule = netParams.importCellParams(label='PYR', conds= {'cellType': 'PYR', 'cellModel': 'PYR'}, fileName='Cells/pyr_23_asym_stripped.hoc', cellName='pyr_23_asym_stripped') ''' cellRule = netParams.importCellParams(label='PYR4', conds={'cellType': 'PYR', 'cellModel': 'PYR_Hay'}, fileName='Cells/fourcompartment.hoc', cellName='fourcompartment') netParams.popParams['BASK4'] = {'cellModel': 'BASK_Vierling', 'cellType': 'BASK', 'gridSpacing': 80.0, 'yRange': [netParams.sizeY, netParams.sizeY], 'color': 'yellow'} ''' currents_rs = [0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3] threshold_rs = input_rs_threshold for i,c in enumerate(currents_rs): current = c + threshold_rs delay = 200 + i*2000 netParams.stimSourceParams['ic'+str(i)] = {'type': 'IClamp', 'delay': delay, 'dur': 1000.0, 'amp': current} netParams.stimTargetParams['ic->PYR'+str(i)] = {'source': 'ic'+str(i), 'conds': {'popLabel': 'PYR'}, 'sec':'soma','loc':0.5} ############################################################################### # SIMULATION PARAMETERS ############################################################################### # Simulation parameters simConfig.hParams['celsius'] = 30.0 simConfig.duration = 20000 # Duration of the simulation, in ms simConfig.dt = 0.025 # Internal integration timestep to use simConfig.seeds = {'conn': 1, 'stim': 1, 'loc': 1} # Seeds for randomizers (connectivity, input stimulation and cell locations) simConfig.createNEURONObj = 1 # create HOC objects when instantiating network simConfig.createPyStruct = 1 # create Python structure (simulator-independent) when instantiating network simConfig.verbose = False # show detailed messages simConfig.printPopAvgRates = True #simConfig.verbose = True # Recording simConfig.recordCells = ['all'] # which cells to record from simConfig.recordStep = 0.1 # Step size in ms to save data (eg. V traces, LFP, etc) simConfig.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'}} simConfig.hParams['cai0_ca_ion'] = 0.0001 # Saving simConfig.filename = 'output_files/orig_ion_channels/Data_{}'.format(input_rs_threshold) # Set file output name simConfig.saveFileStep = 1000 # step size in ms to save data to disk simConfig.saveJson = False # Whether or not to write spikes etc. to a .json file simConfig.analysis['plotShape']= {'includePost':[0], 'showSyns':1, 'synStyle':'.', 'synSiz':3, 'saveFig': 'output_files/asym_Shape.png'} return (netParams, simConfig)
# based on netpyne/doc/source/code/tut7.py from netpyne import sim, specs cfg, par = specs.SimConfig(), specs.NetParams() par.popParams['hop'] = {'cellType': 'PYR', 'cellModel': 'HH', 'numCells': 50} par.cellParams['PYR'] = { 'conds': { 'cellModel': 'HH', 'cellType': 'PYR' }, 'secs': { 'soma': { 'geom': { 'diam': 18.8, 'L': 18.8, 'Ra': 123.0 }, 'mechs': { 'hh': {} }, 'vinit': -70 } } } par.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': 0} par.synMechParams['inh'] = { 'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': -80
""" params.py netParams is an object containing a set of network parameters using a standardized structure simConfig is an object containing a set of simulation configurations using a standardized structure Contributors: [email protected] """ from netpyne import specs netParams = specs.NetParams() # object of class NetParams to store the network parameters try: from __main__ import cfg # import SimConfig object with params from parent module except: from cfg import cfg #------------------------------------------------------------------------------# # M1 6-LAYER ynorm-BASED MODEL # #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # NETWORK PARAMETERS #------------------------------------------------------------------------------ # General network parameters netParams.scale = 1 # Scale factor for number of cells netParams.sizeX = 30 # x-dimension (horizontal length) size in um
def set_netParams(cfg): # ---------------------------------------------------------------------------- # # NETWORK PARAMETERS # # ---------------------------------------------------------------------------- netParams = specs.NetParams() # object of class NetParams to store the network parameters #------------------------------------------------------------------------------ # General network parameters #------------------------------------------------------------------------------ netParams.sizeX = ((cfg.N_pyr_x * cfg.gridSpacingPyr) - 1) * cfg.xzScaling # x-dimension (horizontal length) size in um netParams.sizeY = cfg.sizeY # y-dimension (vertical height or cortical depth) size in um netParams.sizeZ = ((cfg.N_pyr_y * cfg.gridSpacingPyr) - 1) * cfg.xzScaling # z-dimension (horizontal depth) size in um netParams.shape = 'cuboid' # ---------------------------------------------------------------------------- # Population parameters # ---------------------------------------------------------------------------- # layer locations layersE = {'L2': [0.0*cfg.sizeY, 0.0*cfg.sizeY], 'L5': [0.654*cfg.sizeY, 0.654*cfg.sizeY]} # 0.654 = 1308/2000 layersI = {'L2': [0.0*cfg.sizeY-00.0, 0.0*cfg.sizeY-00.0], 'L5': [0.654*cfg.sizeY-00.0, 0.654*cfg.sizeY-00.0]} # Create list of locations for Basket cells based on original ad hoc rules # define relevant x spacings for basket cells xzero = np.arange(0, cfg.N_pyr_x, 3) xone = np.arange(1, cfg.N_pyr_x, 3) yeven = np.arange(0, cfg.N_pyr_y, 2) yodd = np.arange(1, cfg.N_pyr_y, 2) coords = [pos for pos in it.product(xzero, yeven)] + [pos for pos in it.product(xone, yodd)] coords_sorted = sorted(coords, key=lambda pos: pos[1]) L2BasketLocs = [{'x': coord[0]*cfg.xzScaling, 'y': layersI['L2'][0], 'z': coord[1]*cfg.xzScaling} for coord in coords_sorted] L5BasketLocs = [{'x': coord[0]*cfg.xzScaling, 'y': layersI['L5'][0], 'z': coord[1]*cfg.xzScaling} for coord in coords_sorted] # create popParams netParams.popParams['L2Basket'] = {'cellType': 'L2Basket', 'cellModel': 'HH_simple', 'numCells': len(L2BasketLocs), 'cellsList': L2BasketLocs} netParams.popParams['L2Pyr'] = {'cellType': 'L2Pyr', 'cellModel': 'HH_reduced', 'yRange': layersE['L2'], 'gridSpacing': cfg.gridSpacingPyr*cfg.xzScaling} netParams.popParams['L5Basket'] = {'cellType': 'L5Basket', 'cellModel': 'HH_simple', 'numCells': len(L5BasketLocs), 'cellsList': L5BasketLocs} netParams.popParams['L5Pyr'] = {'cellType': 'L5Pyr', 'cellModel': 'HH_reduced', 'yRange': layersE['L5'], 'gridSpacing': cfg.gridSpacingPyr*cfg.xzScaling} # create variables useful for connectivity pops = list(netParams.popParams.keys()) cellsPerPop = {} cellsPerPop['L2Pyr'] = cellsPerPop['L5Pyr'] = int(cfg.N_pyr_x * cfg.N_pyr_x) cellsPerPop['L2Basket'] = cellsPerPop['L5Basket'] = int(np.ceil(cfg.N_pyr_x * cfg.N_pyr_x / cfg.gridSpacingBasket[2]) + 1) #------------------------------------------------------------------------------ # Synaptic mechanism parameters #------------------------------------------------------------------------------ netParams.synMechParams['L2Pyr_AMPA'] = {'mod':'Exp2Syn', 'tau1': cfg.L2Pyr_ampa_tau1, 'tau2': cfg.L2Pyr_ampa_tau2, 'e': cfg.L2Pyr_ampa_e} netParams.synMechParams['L2Pyr_NMDA'] = {'mod': 'Exp2Syn', 'tau1': cfg.L2Pyr_nmda_tau1, 'tau2': cfg.L2Pyr_nmda_tau2, 'e': cfg.L2Pyr_nmda_e} netParams.synMechParams['L2Pyr_GABAA'] = {'mod':'Exp2Syn', 'tau1': cfg.L2Pyr_gabaa_tau1, 'tau2': cfg.L2Pyr_gabaa_tau2, 'e': cfg.L2Pyr_gabaa_e} netParams.synMechParams['L2Pyr_GABAB'] = {'mod':'Exp2Syn', 'tau1': cfg.L2Pyr_gabab_tau1, 'tau2': cfg.L2Pyr_gabab_tau2, 'e': cfg.L2Pyr_gabab_e} netParams.synMechParams['L5Pyr_AMPA'] = {'mod':'Exp2Syn', 'tau1': cfg.L5Pyr_ampa_tau1, 'tau2': cfg.L5Pyr_ampa_tau2, 'e': cfg.L5Pyr_ampa_e} netParams.synMechParams['L5Pyr_NMDA'] = {'mod': 'Exp2Syn', 'tau1': cfg.L5Pyr_nmda_tau1, 'tau2': cfg.L5Pyr_nmda_tau2, 'e': cfg.L5Pyr_nmda_e} netParams.synMechParams['L5Pyr_GABAA'] = {'mod':'Exp2Syn', 'tau1': cfg.L5Pyr_gabaa_tau1, 'tau2': cfg.L5Pyr_gabaa_tau2, 'e': cfg.L5Pyr_gabaa_e} netParams.synMechParams['L5Pyr_GABAB'] = {'mod':'Exp2Syn', 'tau1': cfg.L5Pyr_gabab_tau1, 'tau2': cfg.L5Pyr_gabab_tau2, 'e': cfg.L5Pyr_gabab_e} netParams.synMechParams['AMPA'] = {'mod':'Exp2Syn', 'tau1': 0.5, 'tau2': 5.0, 'e': 0} netParams.synMechParams['NMDA'] = {'mod': 'Exp2Syn', 'tau1': 1, 'tau2': 20, 'e': 0} netParams.synMechParams['GABAA'] = {'mod':'Exp2Syn', 'tau1': 0.5, 'tau2': 5, 'e': -80} netParams.synMechParams['GABAB'] = {'mod':'Exp2Syn', 'tau1': 1, 'tau2': 20, 'e': -80} #------------------------------------------------------------------------------ # Local connectivity parameters #------------------------------------------------------------------------------ # Weight and delay distance-dependent functions (as strings) to use in conn rules weightDistFunc = '{A_weight} * exp(-(dist_2D**2) / ({lamtha}**2))' delayDistFunc = '{A_delay} / exp(-(dist_2D**2) / ({lamtha}**2))' if cfg.localConn: # L2 Pyr -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': cfg.EEgain * cfg.gbar_L2Pyr_L2Pyr_ampa, 'A_delay': 1., 'lamtha': 3.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': cfg.EEgain * cfg.gbar_L2Pyr_L2Pyr_nmda, 'A_delay': 1., 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['L2Pyr->L2Pyr_%d'%(i)] = { 'preConds': {'pop': 'L2Pyr'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), # equivalent to weightDistFunc.format(A_weight=cfg.gbar_L2Pyr_L2Pyr_ampa, lamtha=1.) 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique', ]} # L2 Basket -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_GABAA', 'A_weight': cfg.IEgain * cfg.gbar_L2Basket_L2Pyr_gabaa, 'A_delay': 1., 'lamtha': 50.}, {'synMech': 'L2Pyr_GABAB', 'A_weight': cfg.IEgain * cfg.gbar_L2Basket_L2Pyr_gabab, 'A_delay': 1., 'lamtha': 50.}] for i,synParams in enumerate(synParamsList): netParams.connParams['L2Basket->L2Pyr_%d'%(i)] = { 'preConds': {'pop': 'L2Basket'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L2 Pyr -> L2 Basket synParams = {'synMech': 'AMPA', 'A_weight': cfg.EIgain * cfg.gbar_L2Pyr_L2Basket, 'A_delay': 1., 'lamtha': 3.} netParams.connParams['L2Pyr->L2Basket_%s'%(synParams['synMech'])] = { 'preConds': {'pop': 'L2Pyr'}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L2 Basket -> L2 Basket synParams = {'synMech': 'GABAA', 'A_weight': cfg.IIgain * cfg.gbar_L2Basket_L2Basket, 'A_delay': 1., 'lamtha': 20.} netParams.connParams['L2Basket->L2Basket'] = { 'preConds': {'pop': 'L2Basket'}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L5 Pyr -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': cfg.EEgain * cfg.gbar_L5Pyr_L5Pyr_ampa, 'A_delay': 1., 'lamtha': 3.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': cfg.EEgain * cfg.gbar_L5Pyr_L5Pyr_nmda, 'A_delay': 1., 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['L5Pyr->L5Pyr_%d'%(i)] = { 'preConds': {'pop': 'L5Pyr'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3', 'apical_oblique']} # L5 Basket -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_GABAA', 'A_weight': cfg.IEgain * cfg.gbar_L5Basket_L5Pyr_gabaa, 'A_delay': 1., 'lamtha': 70.}, {'synMech': 'L5Pyr_GABAB', 'A_weight': cfg.IEgain * cfg.gbar_L5Basket_L5Pyr_gabab, 'A_delay': 1., 'lamtha': 70.}] for i,synParams in enumerate(synParamsList): netParams.connParams['L5Basket->L5Pyr_%d'%(i)] = { 'preConds': {'pop': 'L5Basket'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L2 Pyr -> L5 Pyr synParams = {'synMech': 'L5Pyr_AMPA', 'A_weight': cfg.EEgain * cfg.gbar_L2Pyr_L5Pyr, 'A_delay': 1., 'lamtha': 3.} netParams.connParams['L2Pyr->L5Pyr'] = { 'preConds': {'pop': 'L2Pyr'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 4, 'sec': ['basal_2', 'basal_3', 'apical_tuft', 'apical_oblique']} # L2 Basket -> L5 Pyr synParams = {'synMech': 'L5Pyr_GABAA', 'A_weight': cfg.IEgain * cfg.gbar_L2Basket_L5Pyr, 'A_delay': 1., 'lamtha': 50.} netParams.connParams['L2Basket->L5Pyr'] = { 'preConds': {'pop': 'L2Basket'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['apical_tuft']} # L5 Pyr -> L5 Basket synParams = {'synMech': 'AMPA', 'A_weight': cfg.EIgain * cfg.gbar_L5Pyr_L5Basket, 'A_delay': 1., 'lamtha': 3.} netParams.connParams['L5Pyr->L5Basket'] = { 'preConds': {'pop': 'L5Pyr'}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L2 Pyr -> L5 Basket synParams = {'synMech': 'AMPA', 'A_weight': cfg.EIgain * cfg.gbar_L2Pyr_L5Basket, 'A_delay': 1., 'lamtha': 3.} netParams.connParams['L2Pyr->L5Basket'] = { 'preConds': {'pop': 'L2Pyr'}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # L5 Basket -> L5 Basket synParams = {'synMech': 'GABAA', 'A_weight': cfg.IIgain * cfg.gbar_L5Basket_L5Basket, 'A_delay': 1., 'lamtha': 20.} netParams.connParams['L5Basket->L5Basket'] = { 'preConds': {'pop': 'L5Basket'}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} #------------------------------------------------------------------------------ # Rhythmic proximal and distal inputs parameters #------------------------------------------------------------------------------ # Location of external inputs xrange = np.arange(cfg.N_pyr_x) extLocX = xrange[int((len(xrange) - 1) // 2)] zrange = np.arange(cfg.N_pyr_y) extLocZ = xrange[int((len(zrange) - 1) // 2)] extLocY = 650 # positive depth of L5 relative to L2; doesn't affect weight/delay calculations conn1to1Pyr = np.array([range(0,cellsPerPop['L2Pyr']), range(0,cellsPerPop['L2Pyr'])]).T conn1to1Basket = np.array([range(0,cellsPerPop['L2Basket']), range(0,cellsPerPop['L2Basket'])]).T if cfg.rhythmicInputs: # Ad hoc rules copied from original code (need to improve!! -- maybe add to .param files?) ## "if stdev is zero, increase synaptic weights 5 fold to make" ## "single input equivalent to 5 simultaneous input to prevent spiking <<---- SN: WHAT IS THIS RULE!?!?!?" if cfg.f_stdev_prox == 0.0 and cfg.distribution_prox != 'uniform': for key in [k for k in cfg.__dict__ if k.startswith('input_prox_A_weight')]: cfg.__dict__[key] *= 5.0 if cfg.f_stdev_dist == 0.0 and cfg.distribution_dist != 'uniform': for key in [k for k in cfg.__dict__ if k.startswith('input_dist_A_weight')]: cfg.__dict__[key] *= 5.0 ## "if L5 delay is -1, use same delays as L2 unless L2 delay is 0.1 in which case use 1. <<---- SN: WHAT IS THIS RULE!?!?!?" if cfg.input_prox_A_delay_L5 == -1: if cfg.input_prox_A_delay_L2 != 0.1: cfg.input_prox_A_delay_L5 = cfg.input_prox_A_delay_L2 else: cfg.input_prox_A_delay_L5 = 1.0 if cfg.input_dist_A_delay_L5 == -1: if cfg.input_dist_A_delay_L2 != 0.1: cfg.input_dist_A_delay_L5 = cfg.input_dist_A_delay_L2 else: cfg.input_dist_A_delay_L5 = 1.0 # External Rhythmic proximal inputs (1 VecStim per cell for each cell population) netParams.popParams['extRhythmicProximal'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(cfg.prng_seedcore_input_prox), 'spikePattern': { 'type': 'rhythmic', 'start': cfg.t0_input_prox, 'startStd': cfg.t0_input_stdev_prox, 'stop': cfg.tstop_input_prox, 'freq': cfg.f_input_prox, 'freqStd': cfg.f_stdev_prox, 'eventsPerCycle': cfg.events_per_cycle_prox, 'distribution': cfg.distribution_prox, 'repeats': cfg.repeats_prox}} # External Rhythmic distal inputs (population of 1 VecStim) netParams.popParams['extRhythmicDistal'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(cfg.prng_seedcore_input_dist), 'spikePattern': { 'type': 'rhythmic', 'start': cfg.t0_input_dist, 'startStd': cfg.t0_input_stdev_dist, 'stop': cfg.tstop_input_dist, 'freq': cfg.f_input_dist, 'freqStd': cfg.f_stdev_dist, 'eventsPerCycle': cfg.events_per_cycle_dist, 'distribution': cfg.distribution_dist, 'repeats': cfg.repeats_dist}} # Rhytmic proximal -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': cfg.input_prox_A_weight_L2Pyr_ampa, 'A_delay': cfg.input_prox_A_delay_L2, 'lamtha': 100.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': cfg.input_prox_A_weight_L2Pyr_nmda, 'A_delay': cfg.input_prox_A_delay_L2, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicProx->L2Pyr_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicProximal'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Rhythmic distal -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': cfg.input_dist_A_weight_L2Pyr_ampa, 'A_delay': cfg.input_dist_A_delay_L2, 'lamtha': 100.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': cfg.input_dist_A_weight_L2Pyr_nmda, 'A_delay': cfg.input_dist_A_delay_L2, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicDistal->L2Pyr_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicDistal'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['apical_tuft']} # Rhythmic proximal -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': cfg.input_prox_A_weight_L5Pyr_ampa, 'A_delay': cfg.input_prox_A_delay_L5, 'lamtha': 100.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': cfg.input_prox_A_weight_L5Pyr_nmda, 'A_delay': cfg.input_prox_A_delay_L5, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicProx->L5Pyr_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicProximal'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Rhythmic distal -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': cfg.input_dist_A_weight_L5Pyr_ampa, 'A_delay': cfg.input_dist_A_delay_L5, 'lamtha': 100.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': cfg.input_dist_A_weight_L5Pyr_nmda, 'A_delay': cfg.input_dist_A_delay_L5, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicDistal->L5Pyr_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicDistal'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['apical_tuft']} # Rhytmic proximal -> L2 Basket synParamsList = [{'synMech': 'AMPA', 'A_weight': cfg.input_prox_A_weight_L2Basket_ampa, 'A_delay': cfg.input_prox_A_delay_L2, 'lamtha': 100.}, {'synMech': 'NMDA', 'A_weight': cfg.input_prox_A_weight_L2Basket_nmda, 'A_delay': cfg.input_prox_A_delay_L2, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicProx->L2Basket_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicProximal'}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': 'soma'} # Rhytmic proximal -> L5 Basket synParamsList = [{'synMech': 'AMPA', 'A_weight': cfg.input_prox_A_weight_L5Basket_ampa, 'A_delay': cfg.input_prox_A_delay_L5, 'lamtha': 100.}, {'synMech': 'NMDA', 'A_weight': cfg.input_prox_A_weight_L5Basket_nmda, 'A_delay': cfg.input_prox_A_delay_L5, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extRhythmicProx->L5Basket_%d'%(i)] = { 'preConds': {'pop': 'extRhythmicProximal'}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': 'soma'} #------------------------------------------------------------------------------ # Evoked proximal and distal inputs parameters #------------------------------------------------------------------------------ if cfg.evokedInputs: # Evoked proximal inputs (population of 1 VecStim) nprox = len([k for k in cfg.__dict__ if k.startswith('t_evprox')]) ndist = len([k for k in cfg.__dict__ if k.startswith('t_evdist')]) # TEMPORARY CODE TO HARD CODE SAME SPIKE TIMES AS IN ORIGINAL MODEL (ERP TUT) # import json # with open('../input_spikes.json', 'r') as f: # input_spikes = json.load(f) # ev_gids = {'L2Basket': [0,35], 'L2Pyr': [35,135], 'L5Basket': [135,170], 'L5Pyr': [170,270]} # Evoked proximal inputs (population of 1 VecStim) for iprox in range(nprox): for pop in pops: skey = 'evprox_%d'%(iprox+1) netParams.popParams['evokedProximal_%d_%s'%(iprox+1, pop)] = { 'cellModel': 'VecStim', 'numCells': cellsPerPop[pop], 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_' + skey)), #'spkTimes': input_spikes['evprox'+str(iprox+1)][ev_gids[pop][0]:ev_gids[pop][1]]} 'spikePattern': { 'type': 'evoked', 'start': getattr(cfg, 't_' + skey), 'startStd': getattr(cfg, 'sigma_t_' + skey), 'numspikes': getattr(cfg, 'numspikes_' + skey), 'sync': getattr(cfg, 'sync_evinput')}} # Evoked proximal -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Pyr_ampa'), 'A_delay': 0.1, 'lamtha': 3.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Pyr_nmda'), 'A_delay': 0.1, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedProx_%d->L2Pyr_%d'%(iprox+1, i)] = { 'preConds': {'pop': 'evokedProximal_%d_L2Pyr'%(iprox+1)}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Pyr, 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Evoked proximal -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Pyr_ampa'), 'A_delay': 1.0, 'lamtha': 3.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Pyr_nmda'), 'A_delay': 1.0, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedProx_%d->L5Pyr_%d'%(iprox+1, i)] = { 'preConds': {'pop': 'evokedProximal_%d_L5Pyr'%(iprox+1)}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Pyr, 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Evoked proximal -> L2 Basket synParamsList = [{'synMech': 'AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Basket_ampa'), 'A_delay': 0.1, 'lamtha': 3.}, {'synMech': 'NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Basket_nmda'), 'A_delay': 0.1, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedProx_%d->L2Basket_%d'%(iprox+1, i)] = { 'preConds': {'pop': 'evokedProximal_%d_L2Basket'%(iprox+1)}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Basket, 'synsPerConn': 1, 'sec': 'soma'} # Evoked proximal -> L5 Basket synParamsList = [{'synMech': 'AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Basket_ampa'), 'A_delay': 1.0, 'lamtha': 3.}, {'synMech': 'NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Basket_nmda'), 'A_delay': 1.0, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedProx_%d->L5Basket_%d'%(iprox+1, i)] = { 'preConds': {'pop': 'evokedProximal_%d_L5Basket'%(iprox+1)}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Basket, 'synsPerConn': 1, 'sec': 'soma'} # Evoked distal inputs (population of 1 VecStim) for idist in range(ndist): for pop in pops: skey = 'evdist_%d'%(idist+1) netParams.popParams['evokedDistal_%d_%s'%(idist+1, pop)] = { 'cellModel': 'VecStim', 'numCells': cellsPerPop[pop], 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_' + skey)), #'spkTimes': input_spikes['evdist'+str(idist+1)][ev_gids[pop][0]:ev_gids[pop][1]]} 'spikePattern': { 'type': 'evoked', 'start': getattr(cfg, 't_' + skey), 'startStd': getattr(cfg, 'sigma_t_' + skey), 'numspikes': getattr(cfg, 'numspikes_' + skey), 'sync': getattr(cfg, 'sync_evinput')}} # Evoked Distal -> L2 Pyr synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Pyr_ampa'), 'A_delay': 0.1, 'lamtha': 3.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Pyr_nmda'), 'A_delay': 0.1, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedDistal_%d->L2Pyr_%d'%(idist+1, i)] = { 'preConds': {'pop': 'evokedDistal_%d_L2Pyr'%(idist+1)}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Pyr, 'synsPerConn': 1, 'sec': 'apical_tuft'} # Evoked Distal -> L5 Pyr synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Pyr_ampa'), 'A_delay': 0.1, 'lamtha': 3.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L5Pyr_nmda'), 'A_delay': 0.1, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedDistal_%d->L5Pyr_%d'%(idist+1, i)] = { 'preConds': {'pop': 'evokedDistal_%d_L5Pyr'%(idist+1)}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Pyr, 'synsPerConn': 1, 'sec': 'apical_tuft'} # Evoked Distal -> L2 Basket synParamsList = [{'synMech': 'AMPA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Basket_ampa'), 'A_delay': 0.1, 'lamtha': 3.}, {'synMech': 'NMDA', 'A_weight': getattr(cfg, 'gbar_'+skey+'_L2Basket_nmda'), 'A_delay': 0.1, 'lamtha': 3.}] for i,synParams in enumerate(synParamsList): netParams.connParams['evokedDistal_%d->L2Basket_%d'%(idist+1, i)] = { 'preConds': {'pop': 'evokedDistal_%d_L2Basket'%(idist+1)}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'connList': conn1to1Basket, 'synsPerConn': 1, 'sec': 'soma'} #------------------------------------------------------------------------------ # Tonic input parameters #------------------------------------------------------------------------------ if cfg.tonicInputs: # Tonic inputs (IClamp) -> L2Pyr if cfg.Itonic_T_L2Pyr_soma == -1: t_dur = cfg.duration - cfg.Itonic_t0_L2Pyr_soma else: t_dur = cfg.Itonic_T_L2Pyr_soma - cfg.Itonic_t0_L2Pyr_soma netParams.stimSourceParams['ITonic_L2Pyr'] = {'type': 'IClamp', 'del': cfg.Itonic_t0_L2Pyr_soma, 'dur': t_dur, 'amp': cfg.Itonic_A_L2Pyr_soma} netParams.stimTargetParams['ITonic->L2Pyr'] = {'source': 'ITonic_L2Pyr', 'sec':'soma', 'loc': 0.5, 'conds': {'pop': 'L2Pyr'}} # Tonic inputs (IClamp) -> L5Pyr if cfg.Itonic_T_L5Pyr_soma == -1: t_dur = cfg.duration - cfg.Itonic_t0_L5Pyr_soma else: t_dur = cfg.Itonic_T_L5Pyr_soma - cfg.Itonic_t0_L5Pyr_soma netParams.stimSourceParams['ITonic_L5Pyr'] = {'type': 'IClamp', 'del': cfg.Itonic_t0_L5Pyr_soma, 'dur': t_dur, 'amp': cfg.Itonic_A_L5Pyr_soma} netParams.stimTargetParams['ITonic->L5Pyr'] = {'source': 'ITonic_L5Pyr', 'sec':'soma', 'loc': 0.5, 'conds': {'pop': 'L5Pyr'}} # Tonic inputs (IClamp) -> L2Basket if cfg.Itonic_T_L2Basket == -1: t_dur = cfg.duration - cfg.Itonic_t0_L2Basket else: t_dur = cfg.Itonic_T_L2Basket - cfg.Itonic_t0_L2Basket netParams.stimSourceParams['ITonic_L2Basket'] = {'type': 'IClamp', 'del': cfg.Itonic_t0_L2Basket, 'dur': t_dur, 'amp': cfg.Itonic_A_L2Basket} netParams.stimTargetParams['ITonic->L2Basket'] = {'source': 'ITonic_L2Basket', 'sec':'soma', 'loc': 0.5, 'conds': {'pop': 'L2Basket'}} # Tonic inputs (IClamp) -> L5Basket if cfg.Itonic_T_L5Basket == -1: t_dur = cfg.duration - cfg.Itonic_t0_L5Basket else: t_dur = cfg.Itonic_T_L5Basket - cfg.Itonic_t0_L5Basket netParams.stimSourceParams['ITonic_L5Basket'] = {'type': 'IClamp', 'del': cfg.Itonic_t0_L5Basket, 'dur': t_dur, 'amp': cfg.Itonic_A_L5Basket} netParams.stimTargetParams['ITonic->L5Basket'] = {'source': 'ITonic_L5Basket', 'sec':'soma', 'loc': 0.5, 'conds': {'pop': 'L5Basket'}} #------------------------------------------------------------------------------ # Poisson-distributed input parameters #------------------------------------------------------------------------------ if cfg.poissonInputs: # Poisson inputs -> L2 Pyr netParams.popParams['extPoisson_L2Pyr'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extpois')), 'spikePattern': { 'type': 'poisson', 'start': getattr(cfg, 't0_pois'), 'interval': getattr(cfg, 'T_pois'), 'frequency': getattr(cfg, 'L2Pyr_Pois_lamtha')}} synParamsList = [{'synMech': 'L2Pyr_AMPA', 'A_weight': getattr(cfg, 'L2Pyr_Pois_A_weight_ampa'), 'A_delay': 0.1, 'lamtha': 100.}, {'synMech': 'L2Pyr_NMDA', 'A_weight': getattr(cfg, 'L2Pyr_Pois_A_weight_nmda'), 'A_delay': 0.1, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extPoisson->L2Pyr_%d'%(i)] = { 'preConds': {'pop': 'extPoisson_L2Pyr'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Poisson inputs -> L5 Pyr netParams.popParams['extPoisson_L5Pyr'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extpois')), 'spikePattern': { 'type': 'poisson', 'start': getattr(cfg, 't0_pois'), 'interval': getattr(cfg, 'T_pois'), 'frequency': getattr(cfg, 'L5Pyr_Pois_lamtha')}} synParamsList = [{'synMech': 'L5Pyr_AMPA', 'A_weight': getattr(cfg, 'L5Pyr_Pois_A_weight_ampa'), 'A_delay': 0.1, 'lamtha': 100.}, {'synMech': 'L5Pyr_NMDA', 'A_weight': getattr(cfg, 'L5Pyr_Pois_A_weight_nmda'), 'A_delay': 0.1, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extPoisson->L5Pyr_%d'%(i)] = { 'preConds': {'pop': 'extPoisson_L5Pyr'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Poisson inputs -> L2 Basket netParams.popParams['extPoisson_L2Basket'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extpois')), 'spikePattern': { 'type': 'poisson', 'start': getattr(cfg, 't0_pois'), 'interval': getattr(cfg, 'T_pois'), 'frequency': getattr(cfg, 'L2Basket_Pois_lamtha')}} synParamsList = [{'synMech': 'AMPA', 'A_weight': getattr(cfg, 'L2Basket_Pois_A_weight_ampa'), 'A_delay': 1.0, 'lamtha': 100.}, {'synMech': 'NMDA', 'A_weight': getattr(cfg, 'L2Basket_Pois_A_weight_nmda'), 'A_delay': 1.0, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extPoisson->L2Basket_%d'%(i)] = { 'preConds': {'pop': 'extPoisson_L2Basket'}, 'postConds': {'pop': 'L2Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} # Poisson inputs -> L5 Basket netParams.popParams['extPoisson_L5Basket'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extpois')), 'spikePattern': { 'type': 'poisson', 'start': getattr(cfg, 't0_pois'), 'interval': getattr(cfg, 'T_pois'), 'frequency': getattr(cfg, 'L5Basket_Pois_lamtha')}} synParamsList = [{'synMech': 'AMPA', 'A_weight': getattr(cfg, 'L5Basket_Pois_A_weight_ampa'), 'A_delay': 1.0, 'lamtha': 100.}, {'synMech': 'NMDA', 'A_weight': getattr(cfg, 'L5Basket_Pois_A_weight_nmda'), 'A_delay': 1.0, 'lamtha': 100.}] for i,synParams in enumerate(synParamsList): netParams.connParams['extPoisson->L5Basket_%d'%(i)] = { 'preConds': {'pop': 'extPoisson_L5Basket'}, 'postConds': {'pop': 'L5Basket'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 1, 'sec': ['soma']} #------------------------------------------------------------------------------ # Gaussian-distributed inputs parameters #------------------------------------------------------------------------------ if cfg.gaussInputs: # Gaussian inputs -> L2 Pyr netParams.popParams['extGauss_L2Pyr'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extgauss')), 'spikePattern': { 'type': 'gauss', 'mu': getattr(cfg, 'L2Pyr_Gauss_mu'), 'sigma': getattr(cfg, 'L2Pyr_Gauss_sigma')}} synParams = {'synMech': 'L2Pyr_AMPA', 'A_weight': getattr(cfg, 'L2Pyr_Gauss_A_weight'), 'A_delay': 0.1, 'lamtha': 100.} netParams.connParams['extGauss->L2Pyr'] = { 'preConds': {'pop': 'extGauss_L2Pyr'}, 'postConds': {'pop': 'L2Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} # Gaussian inputs -> L5 Pyr netParams.popParams['extGauss_L5Pyr'] = { 'cellModel': 'VecStim', 'numCells': 1, 'xRange': [extLocX, extLocX], 'yRange': [extLocY, extLocY], 'zRange': [extLocZ, extLocZ], 'seed': int(getattr(cfg, 'prng_seedcore_extgauss')), 'spikePattern': { 'type': 'gauss', 'mu': getattr(cfg, 'L5Pyr_Gauss_mu'), 'sigma': getattr(cfg, 'L5Pyr_Gauss_sigma')}} synParams = {'synMech': 'L5Pyr_AMPA', 'A_weight': getattr(cfg, 'L5Pyr_Gauss_A_weight'), 'A_delay': 0.1, 'lamtha': 100.} netParams.connParams['extGauss->L5Pyr'] = { 'preConds': {'pop': 'extGauss_L5Pyr'}, 'postConds': {'pop': 'L5Pyr'}, 'synMech': synParams['synMech'], 'weight': weightDistFunc.format(**synParams), 'delay': delayDistFunc.format(**synParams), 'synsPerConn': 3, 'sec': ['basal_2', 'basal_3','apical_oblique']} return netParams