Exemplo n.º 1
0
def evaluate_netparams(candidates, args):
    fitnessCandidates = []

    for icand, cand in enumerate(candidates):
        # modify network params based on this candidate params (genes)
        tut2.netParams.connParams['S->M']['probability'] = cand[0]
        tut2.netParams.connParams['S->M']['weight'] = cand[1]
        tut2.netParams.connParams['S->M']['delay'] = cand[2]

        # create network
        sim.createSimulate(netParams=tut2.netParams, simConfig=tut2.simConfig)

        # calculate firing rate
        numSpikes = float(len(sim.simData['spkt']))
        numCells = float(len(sim.net.cells))
        duration = tut2.simConfig.duration / 1000.0
        netFiring = numSpikes / numCells / duration

        # calculate fitness for this candidate
        fitness = abs(targetFiring -
                      netFiring)  # minimize absolute difference in firing rate

        # add to list of fitness for each candidate
        fitnessCandidates.append(fitness)

        # print candidate parameters, firing rate, and fitness
        print '\n CHILD/CANDIDATE %d: Network with prob:%.2f, weight:%.2f, delay:%.1f \n  firing rate: %.1f, FITNESS = %.2f \n'\
        %(icand, cand[0], cand[1], cand[2], netFiring, fitness)

    return fitnessCandidates
Exemplo n.º 2
0
def run_sim():
    # Folder that contains x86_64 folder
    NETPYNE_WORKDIR_PATH = "../../../"
    neuron.load_mechanisms(NETPYNE_WORKDIR_PATH)

    netParams = sim.loadNetParams("./netParams.json", None, False)
    simConfig = sim.loadSimCfg("./simConfig.json", None, False)

    sim.createSimulate(netParams, simConfig)
    sim.saveData()
Exemplo n.º 3
0
def run():
    # Folder that contains x86_64 folder
    NETPYNE_WORKDIR_PATH = "../../../"
    neuron.load_mechanisms(NETPYNE_WORKDIR_PATH)

    # read cfg and netParams from command line arguments if available; otherwise use default
    simConfig, netParams = sim.readCmdLineArgs(simConfigDefault="cfg.py",
                                               netParamsDefault="netParams.py")

    # Create network and run simulation
    sim.createSimulate(netParams=netParams, simConfig=simConfig)
    sim.saveData()
Exemplo n.º 4
0
def evaluate_netparams(candidates, args):
    global fitnessCandidates, fitness
    fitnessCandidates = []

    for icand, cand in enumerate(candidates):
        # modify network params based on this candidate params (genes)
        netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na11a'][
            'gbar'] = cand[0]
        netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na12a'][
            'gbar'] = cand[1]
        netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na13a'][
            'gbar'] = cand[2]
        netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['na16a'][
            'gbar'] = cand[3]
        netParams_SGGA_markov.SGcellRule['secs']['soma']['mechs']['KDRI'][
            'gkbar'] = cand[2]

        # create network
        sim.createSimulate(netParams=netParams_SGGA_markov.netParams,
                           simConfig=cfg)

        # calculate FIRING RATE for comparison
        # numSpikes = float(len(sim.simData['spkt']))
        # numCells = float(len(sim.net.cells))
        # duration = cfg.duration/1000.0
        # netFiring = numSpikes/numCells/duration

        # # calculate fitness for this candidate
        # fitness = abs(targetFiring - netFiring)  # minimize absolute difference in firing rate

        ### this is the comparison of sum of current traces
        # target membrane voltage trace from the previous data
        # obs_data = open("model_output_ori_ina.json", "r")               # CHECK for the REFERENCE!!!
        # obs_data = json.load(obs_data)
        # targetCurr_ = obs_data["simData"]["B_Na"]["cell_0"]

        # # calculate MEMBRANE VOLTAGE at interesting point for comparison
        # sum_curr = np.array([])
        # for i in range(len(sim.simData["t"])):
        #     sum_curr = sim.simData["na1.1"]["cell_0"][i] + sim.simData["na1.2"]["cell_0"][i] + sim.simData["na1.6"]["cell_0"][i]
        #     diff_curr = abs(targetCurr_[i] - sum_curr)
        #     sum_curr = np.append(sum_curr, diff_curr)

        # fitness = sum(sum_curr) / 600

        # this is the comparison of membrane voltage traces
        #target membrane voltage trace from the previous data
        obs_data = open("model_output_ori_ina_10ms.json",
                        "r")  # CHECK for the REFERENCE!!!
        obs_data = open("./data/original/NaV_0.json", "r")
        obs_data = json.load(obs_data)
        targetMemb_ = obs_data["simData"]["V_soma"]["cell_0"]

        # # calculate MEMBRANE VOLTAGE at interesting point for comparison
        sum_vol = []
        for i in range(len(sim.simData["t"])):
            diff_vol_ = abs(targetMemb_[i] -
                            sim.simData["V_soma"]["cell_0"][i])
            diff_vol = np.array(diff_vol_)
            sum_vol.append(diff_vol)

        # #sum_vol_ext = sum_vol[499:999]    # extract values from 10ms to 20ms
        fitness = sum(sum_vol) / 600

        # add to list of fitness for each candidate
        fitnessCandidates.append(fitness)

        # print candidate parameters, firing rate, and fitness
        #print('\n CHILD/CANDIDATE %d: Network with na11:%.2f, na12:%.2f, na16:%.2f \n FITNESS = %.2f \n'\
        #%(icand, cand[0], cand[1], cand[2], netFiring, fitness))

        # original print candidate parameters, firing rate, and fitness
        print('\n CHILD/CANDIDATE %d: Network with na12a:%.2f, KDRI:%.2f \n  firing rate: %.1f, FITNESS = %.2f \n'\
        %(icand, cand[0], cand[1], fitness))
        #print('\n CHILD/CANDIDATE %d: Network with na11a:%.2f, na12a:%.2f, na13a:%.1f, na16a:%.1f, KDRI:%.1f \n  firing rate: %.1f, FITNESS = %.2f \n'\
        #%(icand, cand[0], cand[1], cand[2], cand[3], cand[4], netFiring, fitness))

    return fitnessCandidates
Exemplo n.º 5
0
import neuron

from netpyne import sim

# Folder that contains x86_64 folder
NETPYNE_WORKDIR_PATH = '../../../'
neuron.load_mechanisms(NETPYNE_WORKDIR_PATH)

sim.load("./model_output.json")
sim.createSimulate()
sim.saveData()
Exemplo n.º 6
0
        'var': 'v'
    }
}  # Dict with traces to record
simConfig.recordStep = 0.01  #0.025 						# Step size in ms to save data (eg. V traces, LFP, etc)
simConfig.filename = 'model_output'  # Set file output name
simConfig.saveMat = True
# Save .mat file after simulation
simConfig.timestampFilename = True  # Add time stamp to filename

#simConfig.analysis['plotRaster'] = True #{'orderInverse': True, 'saveFig': 'tut_import_raster.png'}								# Plot a raster
#simConfig.analysis['plotTraces'] = {'include': [('PN_A', [4,5,6]),('PN_B', [4,5,6])], 'overlay':True} 								# Plot recorded traces for this list of cells
#simConfig.analysis['plotTraces'] = {'include': [77]} 																				# Plot recorded traces for this list of cells
#simConfig.analysis['plot2Dnet'] = True           																					# Plot 2D visualization of cell positions and connections

# Create network and run simulation
sim.createSimulate(netParams=netParams, simConfig=simConfig)
sim.saveData()
import pylab

pylab.show(
)  # this line is only necessary in certain systems where figures appear empty
'''
# Methods to modify your network
modifyCells(params) 				# Modify the cells in your network
modifySynMechs(params) 				# Modify the Synapse Mechanisms
modifyConns(params)					# Modify the connections of your network
modifyStims(params)					# Modify the stimulations of you network
'''
'''
#### Simulation setup to run multiple runs at once
simConfig = specs.SimConfig()								# Object of class SimConfig to store simulation configuration