def run_sim(params):
    # get params

    NP, SC = set_params(input_rs_threshold=params)

    sim.createSimulateAnalyze(netParams=NP, simConfig=SC)

    import pylab
    pylab.show(
    )  # this line is only necessary in certain systems where figures appear empty

    exit()
def run_sim(params):
    # get params
    fig_name, net_type, task, seed, weight, dev_list = params
    NP, SC = set_params(fig_name=fig_name,
                        NET_TYPE=net_type,
                        TASK=task,
                        SEED=seed,
                        GABA_W=weight,
                        DEV_LIST=dev_list)

    sim.createSimulateAnalyze(netParams=NP, simConfig=SC)

    import pylab
    pylab.show(
    )  # this line is only necessary in certain systems where figures appear empty

    exit()
Example #3
0
netParams.stimTargetParams['bkg->all'] = {
    'source': 'bkg',
    'conds': {
        'cellType': ['E', 'I']
    },
    'weight': 0.01,
    'delay': 'max(1, normal(5,2))',
    'synMech': 'exc'
}

# Simulation options
simConfig = specs.SimConfig(
)  # object of class SimConfig to store simulation configuration
simConfig.duration = 1 * 1e3  # Duration of the simulation, in ms
simConfig.dt = 0.025  # Internal integration timestep to use
simConfig.verbose = 1  # Show detailed messages
simConfig.recordTraces = {
    'V_soma': {
        'sec': 'soma',
        'loc': 0.5,
        'var': 'v'
    }
}  # Dict with traces to record
simConfig.recordStep = 1  # Step size in ms to save data (eg. V traces, LFP, etc)
simConfig.filename = 'tmp'  # Set file output name
simConfig.saveJson = True

# Create network and run simulation
sim.createSimulateAnalyze(netParams=netParams,
                          simConfig=simConfig)  #, interval = 100)
Example #4
0
import M1  # import parameters file
from netpyne import sim  # import netpyne init module
import math
import sys

np = M1.netParams
np.scale = 0.1
np.sizeX = 300 * math.sqrt(
    np.scale)  # x-dimension (horizontal length) size in um
np.sizeZ = 300 * math.sqrt(
    np.scale)  # z-dimension (horizontal depth) size in um

sc = M1.simConfig
sc.duration = 1000

if '-nogui' in sys.argv:
    import netpyne
    netpyne.__gui__ = False

sim.createSimulateAnalyze(netParams=np,
                          simConfig=sc)  # create and simulate network
Example #5
0
def analyse(net_params: specs.NetParams, sim_config: specs.SimConfig):
    sim.createSimulateAnalyze(netParams=net_params, simConfig=sim_config)
Example #6
0
"""
init.py

Starting script to run NetPyNE-based PT model.

Usage:
    python init.py # Run simulation, optionally plot a raster

MPI usage:
    mpiexec -n 4 nrniv -python -mpi init.py

Contributors: [email protected]
"""

#import matplotlib; matplotlib.use('Agg')  # to avoid graphics error in servers

from netpyne import sim
from cfg import cfg
from netParams import netParams

sim.createSimulateAnalyze(netParams, cfg) #SimulateAnalyze(netParams, cfg)
Example #7
0
import M1  # import parameters file
from netpyne import sim  # import netpyne init module

sim.createSimulateAnalyze(
    netParams=M1.netParams,
    simConfig=M1.simConfig)  # create and simulate network

# check model output
sim.checkOutput('M1')
Example #8
0
import HybridTut  # import parameters file
from netpyne import sim  # import netpyne init module

sim.createSimulateAnalyze(
    netParams=HybridTut.netParams,
    simConfig=HybridTut.simConfig)  # create and simulate network

# check model output
sim.checkOutput('HybridTut')
Example #9
0
import knoxParams  # import parameters file
from netpyne import sim  # import netpyne init module

sim.createSimulateAnalyze(
    netParams=knoxParams.netParams,
    simConfig=knoxParams.simConfig)  # create and simulate network
import HHTut
from netpyne import sim
sim.createSimulateAnalyze(netParams=HHTut.netParams, simConfig=HHTut.simConfig)

# import pylab; pylab.show()  # this line is only necessary in certain systems where figures appear empty
Example #11
0
import sys

if '-nogui' in sys.argv:
    import netpyne
    netpyne.__gui__ = False
    
import M1  # import parameters file
from netpyne import sim  # import netpyne init module

sim.createSimulateAnalyze(netParams = M1.netParams, simConfig = M1.simConfig)  # create and simulate network
Example #12
0
    10,  # each generation of parameter sets will consist of 10 individuals
    maximize=False,  # best fitness corresponds to minimum value
    bounder=ec.Bounder(
        minParamValues, maxParamValues
    ),  # boundaries for parameter set ([probability, weight, delay])
    max_evaluations=50,  # evolutionary algorithm termination at 50 evaluations
    num_selected=
    10,  # number of generated parameter sets to be selected for next generation
    mutation_rate=0.2,  # rate of mutation
    num_inputs=3,  # len([probability, weight, delay])
    num_elites=1
)  # 1 existing individual will survive to next generation if it has better fitness than an individual selected by the tournament selection

#configure plotting
pylab.legend(loc='best')
pylab.show()

# plot raster of top solutions
final_pop.sort(
    reverse=True
)  # sort final population so best fitness (minimum difference) is first in list
bestCand = final_pop[0].candidate  # bestCand <-- individual @ start of list
tut2.simConfig.analysis['plotRaster'] = True  # plotting
tut2.netParams.connParams['S->M']['probability'] = bestCand[
    0]  # set tut2 values to corresponding best candidate values
tut2.netParams.connParams['S->M']['weight'] = bestCand[1]  #
tut2.netParams.connParams['S->M']['delay'] = bestCand[2]  #
sim.createSimulateAnalyze(
    netParams=tut2.netParams,
    simConfig=tut2.simConfig)  # run simulation of best candidate
Example #13
0
    'e': -80
}
par.stimSourceParams['bkg'] = {'type': 'NetStim', 'rate': 50, 'noise': 0.5}
par.stimTargetParams['bkg->all'] = {
    'source': 'bkg',
    'conds': {
        'pop': 'hop'
    },
    'weight': 0.1,
    'delay': 1,
    'synMech': 'exc'
}
par.connParams['hop->hop'] = {
    'preConds': {
        'pop': 'hop'
    },
    'postConds': {
        'pop': 'hop'
    },
    'weight': 0.2,
    'synMech': 'inh',
    'delay': 5
}

cfg.duration, cfg.dt = 500, 0.025
cfg.analysis['plotRaster'] = {
    'syncLines': True
}
# cfg.analysis['plotTraces']={'include': [1]}; cfg.analysis['plot2Dnet']=True
sim.createSimulateAnalyze(netParams=par, simConfig=cfg)
Example #14
0
from netpyne import sim  # import netpyne init module
from neuron import h

simConfig, netParams = sim.readCmdLineArgs(
    simConfigDefault='cfg.py', netParamsDefault='netParams_SGGA_markov.py')

###############################################################################
# create, simulate, and analyse network
###############################################################################
sim.createSimulateAnalyze(netParams=netParams, simConfig=simConfig)

## Plot comparison to original
import json
import matplotlib.pyplot as plt

with open('./data/original/NaV_0.json', 'rb') as f:
    data = json.load(f)

plt.figure(figsize=(10, 6))
plt.plot(data['simData']['t'],
         data['simData']['V_soma']['cell_0'],
         label='V_soma_B_Na',
         linestyle='dotted')
plt.plot(sim.simData['t'],
         sim.simData['V_soma']['cell_0'],
         label='V_soma_Na1.3a',
         linewidth=2)
plt.xlabel('Time(ms)')
plt.ylabel('voltage (mV)')
plt.legend()
plt.savefig(simConfig.saveFolder + '/' + simConfig.simLabel)
Example #15
0
    num_inputs=5,  # len([na11a, na12, na13a, na16])
    num_elites=1,  #10
    #statistics_file = stat_file,
    #indiduals_file = ind_file
)  # 1 existing individual will survive to next generation if it has better fitness than an individual selected by the tournament selection

#stat_file.close()
#ind_file.close()

#configure plotting
pylab.legend(loc='best')
pylab.show()

# plot raster of top solutions
final_pop.sort(
    reverse=True
)  # sort final population so best fitness (minimum difference) is first in list
bestCand = final_pop[0].candidate  # bestCand <-- individual @ start of list
cfg.analysis['plotRaster'] = False  # plotting
netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na11a'][
    'gbar'] = bestCand[0]
netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na12a'][
    'gbar'] = bestCand[1]
netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na13a'][
    'gbar'] = bestCand[2]
netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na16a'][
    'gbar'] = bestCand[3]
netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['KDRI'][
    'gkbar'] = bestCand[4]
sim.createSimulateAnalyze(netParams=netParams_SGGA_markov.netParams,
                          simConfig=cfg)  # run simulation of best candidate
Example #16
0
import sys

if '-nogui' in sys.argv:
    import netpyne
    netpyne.__gui__ = False

import HHSmall  # import parameters file
from netpyne import sim  # import netpyne sim module

sim.createSimulateAnalyze(
    netParams=HHSmall.netParams,
    simConfig=HHSmall.simConfig)  # create and simulate network
Example #17
0
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 = True  # show detailed messages

# Recording
simConfig.recordCells = [10]  # which cells to record from
simConfig.recordTraces = {'Vsoma_0': {'sec': 'soma_0', 'loc': 0.5, 'var': 'v'}}
simConfig.recordStim = True  # record spikes of cell stims
simConfig.recordStep = 0.1  # Step size in ms to save data (eg. V traces, LFP, etc)

# Saving
simConfig.filename = 'msn_net'  # Set file output name
simConfig.saveFileStep = 1000  # step size in ms to save data to disk
simConfig.savePickle = False  # Whether or not to write spikes etc. to a .mat file

# Analysis and plotting
simConfig.analysis['plotRaster'] = True  # Plot raster
simConfig.analysis['plotTraces'] = {'include': [('D1MSN', 0)]}
# simConfig.analysis['plotTraces'] = {'include': [('D1MSN',0)]}
simConfig.analysis['plot2Dnet'] = True  # Plot 2D net cells and connections

#simConfig.recordLFP = [[-15, y, 1.0*netParams_d2.sizeZ] for y in range(netParams_d2.sizeY/5, netParams_d2.sizeY, netParams_d2.sizeY/5)]
#simConfig.analysis['plotLFP'] = True

sim.createSimulateAnalyze(netParams_d1, simConfig)
Example #18
0
"""
init.py

Starting script to run NetPyNE-based model.

Usage:  python init.py  # Run simulation, optionally plot a raster

MPI usage:  mpiexec -n 4 nrniv -python -mpi init.py

Contributors: [email protected]
"""

from netpyne import sim

cfg, netParams = sim.readCmdLineArgs()					# read cfg and netParams from command line arguments
sim.createSimulateAnalyze(simConfig = cfg, netParams = netParams)
Example #19
0
    'synMech': 'esyn',
    'gapJunction': True,
    'sec': 'soma',
    'loc': 0.5,
    'preSec': 'soma',
    'preLoc': 0.5
}

###############################################################################
# SIMULATION PARAMETERS
###############################################################################

# Simulation parameters
simConfig.duration = 1 * 1e3  # Duration of the simulation, in ms
simConfig.dt = 0.1  # Internal integration timestep to use
simConfig.createNEURONObj = 1  # create HOC objects when instantiating network
simConfig.createPyStruct = 1  # create Python structure (simulator-independent) when instantiating network
simConfig.verbose = 0  #False  # show detailed messages

# Recording
simConfig.recordTraces = {'Vsoma': {'sec': 'soma', 'loc': 0.5, 'var': 'v'}}

# # Analysis and plotting
simConfig.analysis['plotRaster'] = True

###############################################################################
# RUN SIM
###############################################################################

sim.createSimulateAnalyze()
Example #20
0
	'delay': 5,					# transmission delay (ms) 
	'synMech':'AMPA',
	'sec': 'soma'}				"""

netParams.connParams['recurrent'] = {
	'preConds': {'cellType': 'PYR'}, 'postConds': {'cellType': 'PYR'},  #  PYR -> PYR random
	'connFunc': 'convConn', 	# connectivity function (random)
	'convergence': 'uniform(0,10)', 			# max number of incoming conns to cell
	'weight': 0.001, 			# synaptic weight 
	'delay': 5,					# transmission delay (ms) 
	'sec': 'soma'}				# section to connect to


# Simulation options
simConfig = specs.SimConfig()					# object of class SimConfig to store simulation configuration
simConfig.duration = 1*1e3 			# Duration of the simulation, in ms
simConfig.dt = 0.025 				# Internal integration timestep to use
simConfig.verbose = False			# Show detailed messages 
simConfig.recordTraces = {'V_soma':{'sec':'soma','loc':0.5,'var':'v'}}  # Dict with traces to record
simConfig.recordStep = 1 			# Step size in ms to save data (eg. V traces, LFP, etc)
simConfig.filename = 'model_output'  # Set file output name
simConfig.savePickle = False 		# Save params, network and sim output to pickle file

simConfig.analysis['plotRaster'] = {'orderInverse': True}			# Plot a raster
simConfig.analysis['plotTraces'] = {'include':[3]}


# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)    
   
#import pylab; pylab.show()  # this line is only necessary in certain systems where figures appear empty
import sys

if '-nogui' in sys.argv:
    import netpyne
    netpyne.__gui__ = False
    
import HybridTut  # import parameters file
from netpyne import sim 

sim.createSimulateAnalyze(netParams = HybridTut.netParams, simConfig = HybridTut.simConfig)  # create and simulate network
Example #22
0
import sandbox  # import parameters file
from netpyne import sim # import netpyne sim module

# netParams = sandbox.netParams
# simConfig = sandbox.simConfig
# sim.create()  # create and simulate network

sim.createSimulateAnalyze(netParams = sandbox.netParams, simConfig = sandbox.simConfig)  # create and simulate network
Example #23
0
import sys

if '-nogui' in sys.argv:
    import netpyne
    netpyne.__gui__ = False
    
import HHSmall  # import parameters file 
from netpyne import sim  # import netpyne sim module

sim.createSimulateAnalyze(netParams = HHSmall.netParams, simConfig = HHSmall.simConfig)  # create and simulate network