How to use the netpyne.specs function in netpyne

To help you get started, we’ve selected a few netpyne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MetaCell / NetPyNE-UI / neuron_ui / netpyne_init.py View on Github external
import logging
from netpyne import specs
from netpyne.tests import tests
from netpyne.metadata import metadata
from netpyne.metadata import api
import json
from neuron_ui import neuron_utils
from jupyter_geppetto.geppetto_comm import GeppettoJupyterModelSync

netParams = specs.NetParams()
simConfig = specs.SimConfig()

neuron_utils.createProject(name='SampleProject')

GeppettoJupyterModelSync.current_model.original_model = json.dumps({'netParams': netParams.__dict__,
                                                                    'simConfig': simConfig.__dict__,
                                                                    'metadata': metadata.metadata,
                                                                    'requirement': 'from neuron_ui.netpyne_init import *'})

logging.debug(GeppettoJupyterModelSync.current_model.original_model)
github Neurosim-lab / netpyne / netpyne / sim / load.py View on Github external
def loadNetParams (filename, data=None, setLoaded=True):
    if not data: data = _loadFile(filename)
    print('Loading netParams...')
    if 'net' in data and 'params' in data['net']:
        if setLoaded:
            setup.setNetParams(data['net']['params'])
        else:
            return specs.NetParams(data['net']['params'])
    else:
        print(('netParams not found in file %s'%(filename)))

    pass
github Neurosim-lab / netpyne / examples / evolutionary / batchRun.py View on Github external
# parameters space to explore
	
	if networkType == 'simple':
		## simple net
		params = specs.ODict()
		params['prob'] = [0.01, 0.5]
		params['weight'] = [0.001, 0.1]
		params['delay'] = [1, 20]

		pops = {} 
		pops['S'] = {'target': 5, 'width': 2, 'min': 2}
		pops['M'] = {'target': 15, 'width': 2, 'min': 0.2}

	elif networkType == 'complex':
		# complex net
		params = specs.ODict()
		params['probEall'] = [0.05, 0.2] # 0.1
		params['weightEall'] = [0.0025, 0.0075] #5.0
		params['probIE'] = [0.2, 0.6] #0.4
		params['weightIE'] = [0.0005, 0.002]
		params['probLengthConst'] = [100,200]
		params['stimWeight'] = [0.05, 0.2]

		pops = {} 
		pops['E2'] = {'target': 5, 'width': 2, 'min': 1}
		pops['I2'] = {'target': 10, 'width': 5, 'min': 2}
		pops['E4'] = {'target': 30, 'width': 10, 'min': 1}
		pops['I4'] = {'target': 10, 'width': 3, 'min': 2}
		pops['E5'] = {'target': 40, 'width': 4, 'min': 1}
		pops['I5'] = {'target': 25, 'width': 5, 'min': 2}

	# fitness function
github Neurosim-lab / netpyne / examples / intervalSaving / M1.py View on Github external
"""
This is copied from example/M1

params.py 

netParams is a dict containing a set of network parameters using a standardized structure

simConfig is a dict containing a set of simulation configurations using a standardized structure

Contributors: salvadordura@gmail.com
"""

from netpyne import specs

netParams = specs.NetParams()   # object of class NetParams to store the network parameters
simConfig = specs.SimConfig()   # object of class SimConfig to store the simulation configuration

###############################################################################
#
# M1 6-LAYER ynorm-BASED MODEL
#
###############################################################################

###############################################################################
# SIMULATION CONFIGURATION
###############################################################################

# Simulation parameters
simConfig.duration = 30*1e3 # Duration of the simulation, in ms
simConfig.dt = 0.1 # Internal integration timestep to use
simConfig.seeds = {'conn': 1, 'stim': 1, 'loc': 1} # Seeds for randomizers (connectivity, input stimulation and cell locations)
github Neurosim-lab / netpyne / doc / source / code / hopbrodnetpyne.py View on Github external
# execfile('hopbrodnetpyne.py')
# notebook: ~/nrniv/notebooks/nbnetpyne.dol
from netpyne import specs, sim

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 and connections
netParams.addPopParams('hop', {'cellType': 'PYR', 'cellModel': 'HH', 'numCells': 1})
netParams.addConnParams('hop->hop', {'preConds': {'pop': 'hop'}, 'postConds': {'pop': 'hop'}, 'weight': 0.0, 'synMech': 'inh', 'delay': 5})
netParams.addStimSourceParams('bg', {'type': 'IClamp', 'delay': 10, 'dur': int(1000), 'amp': 0.5})

# cells
netParams.addCellParams('hh_PYR',
  {'conds': {'cellType': 'PYR'}, # could have complex rule here for eg PYR cells in certain loc with particular implementation
   'secs': {'soma': {'geom' :  {'diam': 5, 'L': 5}, 'vinit' : -70.6, 
                         'mechs':  {'hh' : {'gnabar': 0.10, 'gkbar': 0.036, 'gl': 0.003, 'el': -70}}}}}) 
netParams.addSynMechParams('exc', {'mod': 'Exp2Syn', 'tau2': 1.0, 'e': 0})
netParams.addSynMechParams('inh', {'mod': 'Exp2Syn', 'tau2': 1.0, 'e': -80})
netParams.addStimTargetParams('bg->hop', {'source': 'bg', 'sec':'soma', 'loc': 0.5, 'conds': {'pop':'hop'}})
github Neurosim-lab / netpyne / doc / source / code / tut_gap.py View on Github external
"""
tut_gap.py 

Tutorial on using gap junctions
"""

from netpyne import specs, sim
from netpyne.specs import Dict

netParams = specs.NetParams()  # object of class NetParams to store the network parameters
simConfig = specs.SimConfig()  # dictionary to store sets of simulation configurations


###############################################################################
# NETWORK PARAMETERS
###############################################################################

# Population parameters
netParams.popParams['PYR1'] = {'cellModel': 'HH', 'cellType': 'PYR', 'numCells': 1} # add dict with params for this pop 
netParams.popParams['PYR2'] = {'cellModel': 'HH', 'cellType': 'PYR', 'numCells': 1} # add dict with params for this pop 
netParams.popParams['background'] = {'cellModel': 'NetStim', 'numCells': 2, 'rate': 20, 'noise': 0.5, 'start': 1, 'seed': 2}  # background inputs

# Synaptic mechanism parameters
netParams.addSynMechParams('AMPA', {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': 0})
netParams.addSynMechParams('esyn', {'mod': 'ElectSyn', 'g': 0.000049999999999999996})

# Cell parameters
github Neurosim-lab / netpyne / examples / NeuroMLImport / SimpleNet_import.py View on Github external
from netpyne import sim

from netpyne import specs 

specs.SimConfig()

file_name = 'SimpleNet.net.nml'

simConfig = specs.SimConfig()  # dictionary to store simConfig

# Simulation parameters
simConfig.duration = 1000 # Duration of the simulation, in ms
simConfig.dt = 0.025 # Internal integration timestep to use
simConfig.verbose = True

simConfig.recordCells = ['all']  # which cells to record from
simConfig.recordTraces = {'Vsoma':{'sec':'soma','loc':0.5,'var':'v'}}
simConfig.filename = 'SimpleNet'  # Set file output name
simConfig.saveDat = True # save traces
github Neurosim-lab / netpyne / doc / source / code / tut2.py View on Github external
from netpyne import specs, sim

# Network parameters
netParams = specs.NetParams()  # object of class NetParams to store the network parameters

## Population parameters
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'} 
netParams.popParams['M'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'} 

## Cell property rules
cellRule = {'conds': {'cellType': 'PYR'},  'secs': {}} 	# cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'mechs': {}}  														# soma params dict
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
netParams.cellParams['PYRrule'] = cellRule  												# add dict to list of cell params

## Synaptic mechanism parameters
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 5.0, 'e': 0}  # excitatory synaptic mechanism
 
# Stimulation parameters
github Neurosim-lab / netpyne / netpyne / batch / batch.py View on Github external
def setCfgNestedParam(self, paramLabel, paramVal):
        if isinstance(paramLabel, tuple):
            container = self.cfg
            for ip in range(len(paramLabel)-1):
                if isinstance(container, specs.SimConfig):
                    container = getattr(container, paramLabel[ip])
                else:
                    container = container[paramLabel[ip]]
            container[paramLabel[-1]] = paramVal
        else:
            setattr(self.cfg, paramLabel, paramVal) # set simConfig params