Exemplo n.º 1
0
Starting script to run NetPyNE-based M1 model.

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

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

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

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

print("Starting sim ...")

(pops, cells, conns, stims, rxd, simData) = sim.create(netParams,
                                                       cfg,
                                                       output=True)

# saveInterval defines how often the data is saved
sim.runSimWithIntervalFunc(cfg.saveInterval, sim.intervalSave)

# we run fileGather() instead of gather
sim.fileGather()
sim.analyze()

sim.checkOutput('M1detailed')
Exemplo n.º 2
0
simConfig.saveDataInclude = ['simData', 'simConfig', 'netParams']  #, 'net']
simConfig.saveCellSecs = 0  #False
simConfig.saveCellConns = 0
# simConfig.recordLFP = [[150, y, 150] for y in [600, 800, 1000]] # only L5 (Zagha) [[150, y, 150] for y in range(200,1300,100)]

simConfig.analysis['plotRaster'] = True  # Plot a raster
simConfig.analysis['plotTraces'] = {
    'include': [1]
}  # Plot recorded traces for this list of cells
#simConfig.analysis['plot2Dnet'] = True           # plot 2D visualization of cell positions and connections
#simConfig.analysis['plotLFP'] = True
simConfig.printPopAvgRates = True

# def modifyGnabar(t):
#     params = {'conds': {'cellType': 'PYR'}, 'secs': {'soma': {'mechs': {'hh': {'gnabar': 0.0}}}}}
#     sim.net.modifyCells(params)
#     print(sim.net.cells[0].secs['soma']['mechs']['hh'])

# Create network and run simulation
sim.create(netParams=netParams, simConfig=simConfig)
sim.runSimWithIntervalFunc(200, sim.saveSimDataInNode)
#sim.gatherData()                  			# gather spiking data and cell info from each node
sim.fileGather()
sim.saveData(
)  # save params, cell info and sim output to file (pickle,mat,txt,etc)#
sim.analysis.plotData()  # plot spike raster etc

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

# check model output
#sim.checkOutput('tut2')
Exemplo n.º 3
0
simConfig.saveDataInclude = ['simData', 'simConfig', 'netParams']#, 'net']
simConfig.saveCellSecs = 0 #False
simConfig.saveCellConns = 0
simConfig.recordLFP = [[150, y, 150] for y in [600, 800, 1000]] # only L5 (Zagha) [[150, y, 150] for y in range(200,1300,100)]

simConfig.analysis['plotRaster'] = True 			# Plot a raster
simConfig.analysis['plotTraces'] = {'include': [1]} 			# Plot recorded traces for this list of cells
#simConfig.analysis['plot2Dnet'] = True           # plot 2D visualization of cell positions and connections
simConfig.analysis['plotLFP'] = True



def modifyGnabar(t):
    params = {'conds': {'cellType': 'PYR'}, 'secs': {'soma': {'mechs': {'hh': {'gnabar': 0.0}}}}}
    sim.net.modifyCells(params)
    print(sim.net.cells[0].secs['soma']['mechs']['hh'])


# Create network and run simulation
sim.create(netParams=netParams, simConfig=simConfig)
sim.runSimWithIntervalFunc(500, modifyGnabar)
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)#
sim.analysis.plotData()         			# plot spike raster etc



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

# check model output
sim.checkOutput('tut2')
Exemplo n.º 4
0
def saveWeights(t):

    # if a list for weights is not initialized make one
    if not hasattr(sim, 'allWeights'):
        sim.allWeights=[]
    
    # save the weights
    for cell in sim.net.cells:
        for conn in cell.conns:
            sim.allWeights.append(float(conn['hObj'].weight[0]))
    
    # if the sim time matches the saveInterval then save data
    # NOTE: intervalRun must divide evenly into saveInterval (saveInterval % intervalRun == 0)
    if (round(t, 4) % cfg.saveInterval == 0):
            sim.intervalSave(t)
    

print("Starting sim ...")

(pops, cells, conns, stims, rxd, simData) = sim.create(netParams, cfg, output=True)

# we run with an interval function defined above
# if you just want to save the data and not the wieghts you can use the sim.intervalSave function instead of saveWeights
sim.runSimWithIntervalFunc(cfg.intervalRun, saveWeights)  

# we run fileGather() instead of gather       
sim.fileGather()   
sim.analyze()


sim.checkOutput('M1detailed')
Exemplo n.º 5
0
    from pylab import figure, loadtxt, xlabel, ylabel, xlim, ylim, show, pcolor, array, colorbar

    figure()
    weightdata = loadtxt(sim.weightsfilename)
    weightdataT = list(map(list, list(zip(*weightdata))))
    vmax = max([max(row) for row in weightdata])
    vmin = min([min(row) for row in weightdata])
    pcolor(array(weightdataT), cmap='hot_r', vmin=vmin, vmax=vmax)
    xlim((0, len(weightdata)))
    ylim((0, len(weightdata[0])))
    xlabel('Time (weight updates)')
    ylabel('Synaptic connection id')
    colorbar()
    show()


###############################################################################
# Run Network with virtual arm
###############################################################################

sim.runSimWithIntervalFunc(sim.updateInterval,
                           runArm)  # 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)
sim.analysis.plotData()  # plot spike raster
sim.arm.close(sim)

if sim.plotWeights:
    saveWeights(sim)
    plotWeights()
Exemplo n.º 6
0
# )

## First we have to make a dictionary of the arguments we want to feed into plotShape:"

plotArgs = {
    'includePre' : [0], 
    'includePost': [0], 
    'cvar'       : 'voltage', 
    'clim'       : [-70, -20], 
    'saveFig'    : 'movie', 
    'showFig'    : False,
}

## Then we can replace `sim.runSim()` with:

sim.runSimWithIntervalFunc(1.0, sim.analysis.plotShape, timeRange=[10, 20], funcArgs=plotArgs)
 
## This will execute `sim.analysis.plotShape` every 1.0 ms from 10 to 20 ms in the simulation and feed it the plotArgs dictionary we created above.

## Once we're done simulating, we need to wrap up the final steps manually:

sim.gatherData()
sim.saveData()
sim.analysis.plotData()

 
## Once everything is complete, we'll need to install a couple Python packages to make a movie from our frames.

# python3 -m pip install natsort imageio