Skip to content

Commit

Permalink
Merge pull request #158 from Neurosim-lab/development
Browse files Browse the repository at this point in the history
PR from development to master - VERSION 0.6.0
  • Loading branch information
salvadord authored Sep 2, 2016
2 parents 2dfa513 + df96a06 commit fe7e20c
Show file tree
Hide file tree
Showing 21 changed files with 775 additions and 442 deletions.
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Version 0.6.0

- Added option to shape conn weights dynamically to create temporal patterns (issue #33)

- Store all params of synMechs exhaustively instead of by reference (issue #139)

- Added netParams.importCellParamsFromNet() to import parameters of multiple cells from existing network (issue #154)

- Added modifySynMechs function

- Added option to record from all synMechs of a type (eg. 'AMPA')

- Fixed bugs and improved efficiency of modify, modifyConns and modifyStims function

- Fixed bug plotting traces

# Version 0.5.9

- Improved NeuroML2 import functions (issue #12)
Expand Down
34 changes: 17 additions & 17 deletions doc/source/code/tut2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@
netParams = specs.NetParams() # object of class NetParams to store the network parameters

## Population parameters
netParams.addPopParams('S', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'})
netParams.addPopParams('M', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'})
netParams.addPopParams('background', {'rate': 10, 'noise': 0.5, 'cellModel': 'NetStim'})
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
netParams.popParams['M'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
netParams.popParams['background'] = {'rate': 10, 'noise': 0.5, 'cellModel': 'NetStim'}

## 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.addCellParams('PYRrule', cellRule) # add dict to list of cell params
netParams.cellParams['PYRrule'] = cellRule # add dict to list of cell params

## Synaptic mechanism parameters
netParams.addSynMechParams('exc', {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 5.0, 'e': 0}) # excitatory synaptic mechanism
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 5.0, 'e': 0} # excitatory synaptic mechanism

## Cell connectivity rules
netParams.addConnParams('S->M', # S -> M label
{'preConds': {'popLabel': 'S'}, # conditions of presyn cells
netParams.connParams['S->M'] = { # S -> M label
'preConds': {'popLabel': 'S'}, # conditions of presyn cells
'postConds': {'popLabel': 'M'}, # conditions of postsyn cells
'probability': 0.5, # probability of connection
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'synMech': 'exc'}) # synaptic mechanism
'probability': 0.5, # probability of connection
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'synMech': 'exc'} # synaptic mechanism

netParams.addConnParams('bg->PYR', # background -> PYR label
{'preConds': {'popLabel': 'background'},
netParams.connParams['bg->PYR'] = { # background -> PYR label
'preConds': {'popLabel': 'background'},
'postConds': {'cellType': 'PYR'},
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'synMech': 'exc'}) # synaptic mechanism
'synMech': 'exc'} # synaptic mechanism


# Simulation options
Expand All @@ -46,9 +46,9 @@
simConfig.filename = 'model_output' # Set file output name
simConfig.savePickle = False # Save params, network and sim output to pickle file

simConfig.addAnalysis('plotRaster', True) # Plot a raster
simConfig.addAnalysis('plotTraces', {'include': [1]}) # Plot recorded traces for this list of cells
simConfig.addAnalysis('plot2Dnet', True) # plot 2D visualization of cell positions and connections
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


# Create network and run simulation
Expand Down
24 changes: 12 additions & 12 deletions doc/source/code/tut3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
netParams = specs.NetParams() # object of class NetParams to store the network parameters

## Population parameters
netParams.addPopParams('S', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'})
netParams.addPopParams('M', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'})
netParams.addPopParams('background', {'rate': 10, 'noise': 0.5, 'cellModel': 'NetStim'})
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
netParams.popParams['M'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
netParams.popParams['background'] = {'rate': 10, 'noise': 0.5, 'cellModel': 'NetStim'}

## Cell property rules
cellRule = {'conds': {'cellType': 'PYR'}, 'secs': {}} # cell rule dict
Expand All @@ -17,27 +17,27 @@
cellRule['secs']['dend']['geom'] = {'diam': 5.0, 'L': 150.0, 'Ra': 150.0, 'cm': 1} # dend geometry
cellRule['secs']['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0} # dend topology
cellRule['secs']['dend']['mechs']['pas'] = {'g': 0.0000357, 'e': -70} # dend mechanisms
netParams.addCellParams('PYRrule', cellRule) # add dict to list of cell parameters
netParams.cellParams['PYRrule'] = cellRule # add dict to list of cell parameters


## Synaptic mechanism parameters
netParams.addSynMechParams('exc', {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0}) # excitatory synaptic mechanism


## Cell connectivity rules
netParams.addConnParams('S->M', {'preConds': {'popLabel': 'S'}, 'postConds': {'popLabel': 'M'}, # S -> M
netParams.connParams['S->M'] = {'preConds': {'popLabel': 'S'}, 'postConds': {'popLabel': 'M'}, # S -> M
'probability': 0.5, # probability of connection
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'sec': 'dend', # section to connect to
'loc': 1.0, # location of synapse
'synMech': 'exc'}) # target synaptic mechanism
'loc': 1.0, # location of synapse
'synMech': 'exc'} # target synaptic mechanism

netParams.addConnParams('bg->PYR', {'preConds': {'popLabel': 'background'},
netParams.connParams['bg->PYR'] = {'preConds': {'popLabel': 'background'},
'postConds': {'cellType': 'PYR'}, # background -> PYR
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'synMech': 'exc'}) # target synapse
'synMech': 'exc'} # target synapse


# Simulation options
Expand All @@ -51,9 +51,9 @@
simConfig.filename = 'model_output' # Set file output name
simConfig.savePickle = False # Save params, network and sim output to pickle file

simConfig.addAnalysis('plotRaster', True) # Plot a raster
simConfig.addAnalysis('plotTraces', {'include': [1]}) # Plot recorded traces for this list of cells
simConfig.addAnalysis('plot2Dnet', True) # plot 2D visualization of cell positions and connections
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


# Create network and run simulation
Expand Down
52 changes: 26 additions & 26 deletions doc/source/code/tut4.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@
netParams = specs.NetParams() # object of class NetParams to store the network parameters

## Population parameters
netParams.addPopParams('S', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'Izhi2007b'})
netParams.addPopParams('M', {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'})
netParams.addPopParams('background', {'rate': 100, 'noise': 0.5, 'cellModel': 'NetStim'})
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'Izhi2007b'}
netParams.popParams['M'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
netParams.popParams['background'] = {'rate': 100, 'noise': 0.5, 'cellModel': 'NetStim'}

## Cell property rules
cellRule = {'conds': {'cellType': 'PYR', 'cellModel': 'HH'}, '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 mechanisms
cellRule['secs']['dend'] = {'geom': {}, 'topol': {}, 'mechs': {}} # dend params dict
cellRule['secs']['dend']['geom'] = {'diam': 5.0, 'L': 150.0, 'Ra': 150.0, 'cm': 1} # dend geometry
cellRule['secs']['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0} # dend topology
cellRule['secs']['dend']['mechs']['pas'] = {'g': 0.0000357, 'e': -70} # dend mechanisms
netParams.addCellParams('PYR_HH_rule', cellRule) # add dict to list of cell parameters
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 mechanisms
cellRule['secs']['dend'] = {'geom': {}, 'topol': {}, 'mechs': {}} # dend params dict
cellRule['secs']['dend']['geom'] = {'diam': 5.0, 'L': 150.0, 'Ra': 150.0, 'cm': 1} # dend geometry
cellRule['secs']['dend']['topol'] = {'parentSec': 'soma', 'parentX': 1.0, 'childX': 0} # dend topology
cellRule['secs']['dend']['mechs']['pas'] = {'g': 0.0000357, 'e': -70} # dend mechanisms
netParams.cellParams['PYR_HH_rule'] = cellRule # add dict to list of cell parameters

cellRule = {'conds': {'cellType': 'PYR', 'cellModel': 'Izhi2007b'}, 'secs': {}} # cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'pointps': {}} # soma params dict
cellRule['secs']['soma']['geom'] = {'diam': 10.0, 'L': 10.0, 'cm': 31.831} # soma geometry
cellRule = {'conds': {'cellType': 'PYR', 'cellModel': 'Izhi2007b'}, 'secs': {}} # cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'pointps': {}} # soma params dict
cellRule['secs']['soma']['geom'] = {'diam': 10.0, 'L': 10.0, 'cm': 31.831} # soma geometry
cellRule['secs']['soma']['pointps']['Izhi'] = {'mod':'Izhi2007b', 'C':1, 'k':0.7,
'vr':-60, 'vt':-40, 'vpeak':35, 'a':0.03, 'b':-2, 'c':-50, 'd':100, 'celltype':1} # soma hh mechanisms
netParams.addCellParams('PYR_Izhi_rule', cellRule) # add dict to list of cell parameters
'vr':-60, 'vt':-40, 'vpeak':35, 'a':0.03, 'b':-2, 'c':-50, 'd':100, 'celltype':1} # soma hh mechanisms
netParams.cellParams['PYR_Izhi_rule'] = cellRule # add dict to list of cell parameters


## Synaptic mechanism parameters
netParams.addSynMechParams('exc', {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0}) # excitatory synapse
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 1.0, 'tau2': 5.0, 'e': 0} # excitatory synapse


## Cell connectivity rules
netParams.addConnParams('S->M',
{'preConds': {'popLabel': 'S'}, 'postConds': {'popLabel': 'M'}, # S -> M
netParams.connParams['S->M'] = {
'preConds': {'popLabel': 'S'}, 'postConds': {'popLabel': 'M'}, # S -> M
'probability': 0.1, # probability of connection
'weight': 0.005, # synaptic weight
'delay': 5, # transmission delay (ms)
'sec': 'dend', # section to connect to
'loc': 1.0,
'synMech': 'exc'}) # target synapse
'synMech': 'exc'} # target synapse

netParams.addConnParams('bg->PYR',
{'preConds': {'popLabel': 'background'}, 'postConds': {'cellType': 'PYR'}, # background -> PYR
netParams.connParams['bg->PYR'] = {
'preConds': {'popLabel': 'background'}, 'postConds': {'cellType': 'PYR'}, # background -> PYR
'weight': 0.01, # synaptic weight
'delay': 5, # transmission delay (ms)
'synMech': 'exc'}) # target synapse
'synMech': 'exc'} # target synapse


# Simulation options
Expand All @@ -58,9 +58,9 @@
simConfig.filename = 'model_output' # Set file output name
simConfig.savePickle = False # Save params, network and sim output to pickle file

simConfig.addAnalysis('plotRaster', True) # Plot a raster
simConfig.addAnalysis('plotTraces', {'include': [1]}) # Plot recorded traces for this list of cells
simConfig.addAnalysis('plot2Dnet', True) # plot 2D visualization of cell positions and connections
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


# Create network and run simulation
Expand Down
54 changes: 27 additions & 27 deletions doc/source/code/tut5.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,70 +11,70 @@


## Population parameters
netParams.addPopParams('E2', {'cellType': 'E', 'numCells': 50, 'yRange': [100,300], 'cellModel': 'HH'})
netParams.addPopParams('I2', {'cellType': 'I', 'numCells': 50, 'yRange': [100,300], 'cellModel': 'HH'})
netParams.addPopParams('E4', {'cellType': 'E', 'numCells': 50, 'yRange': [300,600], 'cellModel': 'HH'})
netParams.addPopParams('I4', {'cellType': 'I', 'numCells': 50, 'yRange': [300,600], 'cellModel': 'HH'})
netParams.addPopParams('E5', {'cellType': 'E', 'numCells': 50, 'ynormRange': [0.6,1.0], 'cellModel': 'HH'})
netParams.addPopParams('I5', {'cellType': 'I', 'numCells': 50, 'ynormRange': [0.6,1.0], 'cellModel': 'HH'})
netParams.addPopParams('background', {'rate': 20, 'noise': 0.3, 'cellModel': 'NetStim'})
netParams.popParams['E2'] = {'cellType': 'E', 'numCells': 50, 'yRange': [100,300], 'cellModel': 'HH'}
netParams.popParams['I2'] = {'cellType': 'I', 'numCells': 50, 'yRange': [100,300], 'cellModel': 'HH'}
netParams.popParams['E4'] = {'cellType': 'E', 'numCells': 50, 'yRange': [300,600], 'cellModel': 'HH'}
netParams.popParams['I4'] = {'cellType': 'I', 'numCells': 50, 'yRange': [300,600], 'cellModel': 'HH'}
netParams.popParams['E5'] = {'cellType': 'E', 'numCells': 50, 'ynormRange': [0.6,1.0], 'cellModel': 'HH'}
netParams.popParams['I5'] = {'cellType': 'I', 'numCells': 50, 'ynormRange': [0.6,1.0], 'cellModel': 'HH'}
netParams.popParams['background'] = {'rate': 20, 'noise': 0.3, 'cellModel': 'NetStim'}


## Cell property rules
cellRule = {'conds': {'cellType': 'E'}, 'secs': {}} # cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'mechs': {}} # soma params dict
cellRule['secs']['soma']['geom'] = {'diam': 15, 'L': 14, 'Ra': 120.0} # soma geometry
cellRule['secs']['soma']['mechs']['hh'] = {'gnabar': 0.13, 'gkbar': 0.036, 'gl': 0.003, 'el': -70} # soma hh mechanism
netParams.addCellParams('Erule', cellRule) # add dict to list of cell params
netParams.cellParams['Erule'] = cellRule # add dict to list of cell params

cellRule = {'conds': {'cellType': 'I'}, 'secs': {}} # cell rule dict
cellRule['secs']['soma'] = {'geom': {}, 'mechs': {}} # soma params dict
cellRule['secs']['soma']['geom'] = {'diam': 10.0, 'L': 9.0, 'Ra': 110.0} # soma geometry
cellRule['secs']['soma']['mechs']['hh'] = {'gnabar': 0.11, 'gkbar': 0.036, 'gl': 0.003, 'el': -70} # soma hh mechanism
netParams.addCellParams('Irule', cellRule) # add dict to list of cell params
netParams.cellParams['Irule'] = cellRule # add dict to list of cell params


## Synaptic mechanism parameters
netParams.addSynMechParams('exc', {'mod': 'Exp2Syn', 'tau1': 0.8, 'tau2': 5.3, 'e': 0}) # NMDA synaptic mechanism
netParams.addSynMechParams('inh', {'mod': 'Exp2Syn', 'tau1': 0.6, 'tau2': 8.5, 'e': -75}) # GABA synaptic mechanism
netParams.synMechParams['exc'] = {'mod': 'Exp2Syn', 'tau1': 0.8, 'tau2': 5.3, 'e': 0} # NMDA synaptic mechanism
netParams.synMechParams['inh'] = {'mod': 'Exp2Syn', 'tau1': 0.6, 'tau2': 8.5, 'e': -75} # GABA synaptic mechanism


## Cell connectivity rules
netParams.addConnParams('bg->all',
{'preConds': {'popLabel': 'background'}, 'postConds': {'cellType': ['E', 'I']}, # background -> all
netParams.connParams['bg->all'] = {
'preConds': {'popLabel': 'background'}, 'postConds': {'cellType': ['E', 'I']}, # background -> all
'weight': 0.01, # synaptic weight
'delay': 'max(1, gauss(5,2))', # transmission delay (ms)
'synMech': 'exc'}) # synaptic mechanism
'synMech': 'exc'} # synaptic mechanism

netParams.addConnParams('E->all',
{'preConds': {'cellType': 'E'}, 'postConds': {'y': [100,1000]}, # E -> all (100-1000 um)
netParams.connParams['E->all'] = {
'preConds': {'cellType': 'E'}, 'postConds': {'y': [100,1000]}, # E -> all (100-1000 um)
'probability': 0.1 , # probability of connection
'weight': '0.005*post_ynorm', # synaptic weight
'delay': 'dist_3D/propVelocity', # transmission delay (ms)
'synMech': 'exc'}) # synaptic mechanism
'synMech': 'exc'} # synaptic mechanism

netParams.addConnParams('I->E',
{'preConds': {'cellType': 'I'}, 'postConds': {'popLabel': ['E2','E4','E5']}, # I -> E
netParams.connParams['I->E'] = {
'preConds': {'cellType': 'I'}, 'postConds': {'popLabel': ['E2','E4','E5']}, # I -> E
'probability': '0.4*exp(-dist_3D/probLengthConst)', # probability of connection
'weight': 0.001, # synaptic weight
'delay': 'dist_3D/propVelocity', # transmission delay (ms)
'synMech': 'inh'}) # synaptic mechanism
'weight': 0.001, # synaptic weight
'delay': 'dist_3D/propVelocity', # transmission delay (ms)
'synMech': 'inh'} # synaptic mechanism


# 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.05 # Internal integration timestep to use
simConfig.dt = 0.05 # 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.addAnalysis('plotRaster', {'orderBy': 'y', 'orderInverse': True}) # Plot a raster
simConfig.addAnalysis('plotTraces', {'include': [('E2',0), ('E4', 0), ('E5', 5)]}) # Plot recorded traces for this list of cells
simConfig.addAnalysis('plot2Dnet', True) # plot 2D visualization of cell positions and connections
simConfig.addAnalysis('plotConn', True) # plot connectivity matrix
simConfig.analysis['plotRaster'] = {'orderBy': 'y', 'orderInverse': True} # Plot a raster
simConfig.analysis['plotTraces'] = {'include': [('E2',0), ('E4', 0), ('E5', 5)]} # Plot recorded traces for this list of cells
simConfig.analysis['plot2Dnet'] = True # plot 2D visualization of cell positions and connections
simConfig.analysis['plotConn'] = True # plot connectivity matrix

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)
Expand Down
Loading

0 comments on commit fe7e20c

Please sign in to comment.