Skip to content

Commit

Permalink
Merge pull request #183 from Neurosim-lab/development
Browse files Browse the repository at this point in the history
PR from development to master (version 0.6.4)
  • Loading branch information
salvadord authored Dec 2, 2016
2 parents a48ce2a + 07208e4 commit 1434629
Show file tree
Hide file tree
Showing 31 changed files with 2,440 additions and 530 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ umac
/examples/NeuroMLImport/LEMS_SimpleNet_nrn.py
/examples/NeuroMLImport/LEMS_SimpleNet_pynn.py
/examples/NeuroMLImport/LEMS_SimpleNet_pynn.py_main.json
/nb-configuration.xml
51 changes: 27 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,56 @@ addons:
- python-numpy
- python-scipy
- python-matplotlib
- python-tk
- python-sympy
- python-tables

language: python
python: 2.7

env:
virtualenv:
system_site_packages: true

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

install:
# Install OMV to facilitate installation of packages below
- pip install git+https://github.com/OpenSourceBrain/osb-model-validation

# Need to pre install NEURON so nrnivmodl can be run targeting mod files in a different directory
- omv install NEURON
# Need to pre install pyNeuroML to test export to NeuroML 2
- omv install pyNeuroML
# Main install for NetPyNE
- python setup.py install
- export NEURON_HOME=/home/travis/neuron/nrn/x86_64/


script:
- cp examples/HHTut/HHTut.py doc/source/code/
- cd doc/source/code/
- $NEURON_HOME/bin/nrnivmodl mod
- python tut1.py
- python tut2.py
- python tut3.py
- python tut5.py
- python tut6.py
- python tut_import.py
- cd ../../../examples
- python HHTut/HHTut_run.py
- python HybridTut/HybridTut_run.py
- cd M1
- python tut2.py -nogui
- python tut3.py -nogui
- python tut5.py -nogui
- python tut6.py -nogui
- python tut7.py -nogui
# - python tut_import.py
- cd ../../../examples/HHTut
- python HHTut_run.py -nogui
- cd ../HybridTut
- $NEURON_HOME/bin/nrnivmodl
- python M1/M1_run.py
- cd ../RL_arm
- python HybridTut_run.py -nogui
- cd ../M1
- $NEURON_HOME/bin/nrnivmodl
- python RL_arm/main.py
- python M1_run.py -nogui
- cd ../M1
- $NEURON_HOME/bin/nrnivmodl
- python M1_run.py -nogui

# - cd ../RL_arm
# - $NEURON_HOME/bin/nrnivmodl
# - python main.py


notifications:
email: false
slack: neurosim:pj4DaRn3CrmH6hSRV0zBhfjS
#slack: neurosim:pj4DaRn3CrmH6hSRV0zBhfjS



Expand Down Expand Up @@ -201,4 +204,4 @@ notifications:
# - $HOME/nrn-7.3
# - $HOME/build/nest-2.6.0
# - $HOME/build/nrn-7.3
# - $HOME/.cache/pip
# - $HOME/.cache/pip
40 changes: 40 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# Version 0.6.4

- Added analysis.nTE() function to calculate normalized transfer entropy (issue #42)

- Added analysis.granger() function to calculate and plot Spectral Granger Causality (issue #42)

- Added analysis.plotRatePSD() to plot firing rate power spectral density

- Added analysis.plotShape() to plot 3D morphology of cell and synapse locations

- Added option to fix soma depth for subcellular distributions based on 1d and 2d maps

- Added support for gap junction (electrical synapse) connections

- Improved import of multicompartmental cells from NeuroML2

- Added option to turn off graphics by adding -nogui from command line

- Added option to skip batch sims if output file already exists

- Added option to overlay pop labels and show avg rates to plotRaster() (issue #111)

- All section now include argument cell=self to differentiate them

- Fixed travis script so checks all tuts and examples after each commit (issue #37)

- Fixed bug positioning cells with 3d geom

- Fixed bug in sim.clearAll by closing all figures instead of current (issue #168)

- Fixed bug: cache_efficient was not being turned on

- Fixed bug setting simConfig loaded from file

- Fixed bug in plotRaster inverseOrder option

- Fixed str vs basestring in analysis.py and simFuncs.py

- Fixed bug due to not inserting ions in section

# Version 0.6.3

- Added cvode_active simConfig option to set variable time step (issue #116)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Several example model parameters are provided, including:
Additional details of the modelling framework can be found here:

* [NetPyNE Documentation](http://neurosimlab.org/netpyne/)
* [SFN'15 poster](http://neurosimlab.org/salvadord/sfn15-sal-final.pdf)
* [CNS'16 poster](http://neurosimlab.org/salvadord/CNS16_poster.pdf)
* [slides](https://drive.google.com/file/d/0B8v-knmZRjhtVl9BOFY2bzlWSWs/view?usp=sharing)

Expand Down
7 changes: 5 additions & 2 deletions doc/source/code/tut7.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@
'secs': {'soma': {'geom': {'L': 160}}}})

sim.simulate()
sim.analysis.plotRaster(syncLines=True)
sim.analysis.plotTraces(include = [1])

from netpyne import gui
if gui:
sim.analysis.plotRaster(syncLines=True)
sim.analysis.plotTraces(include = [1])



Expand Down
16 changes: 15 additions & 1 deletion doc/source/code/tut_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,26 @@
'delay': 5, # transmission delay (ms)
'sec': 'soma'} # section to connect to

netParams.connParams['HH->izhi07a'] = {
'preConds': {'popLabel': 'HH_pop'}, 'postConds': {'popLabel': 'Izhi07a_pop'}, # background -> PYR (weight=0.1)
'connFunc': 'fullConn', # connectivity function (all-to-all)
'weight': 5, # synaptic weight
'delay': 5, # transmission delay (ms)
'sec': 'soma'}

netParams.connParams['izhi07a->HH'] = {
'preConds': {'popLabel': 'Izhi07a_pop'}, 'postConds': {'popLabel': 'HH_pop'}, # background -> PYR (weight=0.1)
'connFunc': 'fullConn', # connectivity function (all-to-all)
'weight': 0.1, # synaptic weight
'delay': 5, # transmission delay (ms)
'sec': 'soma'}


# 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.verbose = 0 # 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
Expand Down
76 changes: 75 additions & 1 deletion doc/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ Misc/utilities:
Analysis-related functions
^^^^^^^^^^^^^^^^^^^^^^^^^^
* **analysis.plotRaster** (include = ['allCells'], timeRange = None, maxSpikes = 1e8, orderBy = 'gid', orderInverse = False, spikeHist = None, spikeHistBin = 5, syncLines = False, figSize = (10,8), saveData = None, saveFig = None, showFig = True)
* **analysis.plotRaster** (include = ['allCells'], timeRange = None, maxSpikes = 1e8, orderBy = 'gid', orderInverse = False, labels = 'legend', popRates = False, spikeHist = None, spikeHistBin = 5, syncLines = False, figSize = (10,8), saveData = None, saveFig = None, showFig = True)
Plot raster (spikes over time) of network cells. Optional arguments:
Expand All @@ -766,6 +766,8 @@ Analysis-related functions
- *maxSpikes*: maximum number of spikes that will be plotted (int)
- *orderBy*: Unique numeric cell property to order y-axis by, e.g. 'gid', 'ynorm', 'y' ('gid'|'y'|'ynorm'|...)
- *orderInverse*: Invert the y-axis order (True|False)
- *labels*: Show population labels in a legend or overlayed on one side of raster ('legend'|'overlay'))
- *popRates*: Include population rates ('legend'|'overlay')
- *spikeHist*: overlay line over raster showing spike histogram (spikes/bin) (None|'overlay'|'subplot')
- *spikeHistBin*: Size of bin in ms to use for histogram (int)
- *syncLines*: calculate synchorny measure and plot vertical lines for each spike to evidence synchrony (True|False)
Expand Down Expand Up @@ -795,6 +797,23 @@ Analysis-related functions
- Returns figure handle
* **analysis.plotSpikePSD** (include = ['allCells', 'eachPop'], timeRange = None, binSize = 5, Fs = 200, overlay=True, yaxis = 'rate', figSize = (10,8), saveData = None, saveFig = None, showFig = True)
Plot spikes power spectral density (PSD). Optional arguments:
- *include*: List of data series to include. Note: one line per item, not grouped (['all'|,'allCells'|,'allNetStims'|,120|,'L4'|,('L2', 56)|,('L5',[4,5,6])])
- *timeRange*: Time range of spikes shown; if None shows all ([start:stop])
- *binSize*: Size in ms of each bin (int)
- *Fs*: PSD sampling frequency used to calculate the Fourier frequencies (float)
- *overlay*: Whether to overlay the data lines or plot in separate subplots (True|False)
- *figSize*: Size of figure ((width, height))
- *saveData*: File name where to save the final data used to generate the figure (None|'fileName')
- *saveFig*: File name where to save the figure (None|'fileName')
- *showFig*: Whether to show the figure or not (True|False)
- Returns figure handle and power array
* **analysis.plotTraces** (include = [], timeRange = None, overlay = False, oneFigPer = 'cell', rerun = False, figSize = (10,8), saveData = None, saveFig = None, showFig = True)
Plot recorded traces (specified in ``simConfig.recordTraces)`. Optional arguments:
Expand All @@ -812,6 +831,19 @@ Analysis-related functions
- Returns figure handles
* **plotShape** (showSyns = True, include = [], style = '.', siz=10, figSize = (10,8), saveData = None, saveFig = None, showFig = True):
Plot 3D cell shape using NEURON Interview PlotShape
- *showSyns*: Show synaptic connections in 3D (True|False)
- *figSize*: Size of figure ((width, height))
- *saveData*: File name where to save the final data used to generate the figure (None|'fileName')
- *saveFig*: File name where to save the figure (None|'fileName')
- *showFig*: Whether to show the figure or not (True|False)
- Returns figure handles
* **analysis.plotConn** (include = ['all'], feature = 'strength', orderBy = 'gid', figSize = (10,10), groupBy = 'pop', saveData = None, saveFig = None, showFig = True)
Plot network connectivity. Optional arguments:
Expand Down Expand Up @@ -842,6 +874,48 @@ Analysis-related functions
- Returns figure handles
* **analysis.nTE** (cells1 = [], cells2 = [], spks1 = None, spks2 = None, timeRange = None, binSize = 20, numShuffle = 30)
Calculate normalized transfer entropy
- *cells1*: Subset of cells from which to obtain spike train 1 (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])])
- *cells2*: Subset of cells from which to obtain spike train 2 (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])])
- *spks1*: Spike train 1; list of spike times; if omitted then obtains spikes from cells1 (list)
- *spks2*: Spike train 2; list of spike times; if omitted then obtains spikes from cells2 (list)
- *timeRange*: Range of time to calculate nTE in ms ([min, max])
- *binSize*: Bin size used to convert spike times into histogram (int)
- *numShuffle*: Number of times to shuffle spike train 1 to calculate TEshuffled; note: nTE = (TE - TEShuffled)/H(X2F|X2P) (int)
- Returns nTE: normalized transfer entropy (float)
* **analysis.granger** (cells1 = [], cells2 = [], spks1 = None, spks2 = None, label1 = 'spkTrain1', label2 = 'spkTrain2',
timeRange = None, binSize=5, plotFig = True, saveData = None, saveFig = None, showFig = True):
Calculate and optionally plot Granger Causality
- *cells1*: Subset of cells from which to obtain spike train 1 (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])])
- cells2: Subset of cells from which to obtain spike train 2 (['all',|'allCells','allNetStims',|,120,|,'E1'|,('L2', 56)|,('L5',[4,5,6])])
- *spks1*: Spike train 1; list of spike times; if omitted then obtains spikes from cells1 (list)
- *spks2*: Spike train 2; list of spike times; if omitted then obtains spikes from cells2 (list)
- *label1*: Label for spike train 1 to use in plot (string)
- *label2*: Label for spike train 2 to use in plot (string)
- *timeRange*: Range of time to calculate nTE in ms ([min, max])
- *binSize*: Bin size used to convert spike times into histogram
- *plotFig*: Whether to plot a figure showing Granger Causality Fx2y and Fy2x (True|False)
- *saveData*: File name where to save the final data used to generate the figure (None|'fileName')
- *saveFig*: File name where to save the figure (None|'fileName')
- *showFig*: Whether to show the figure or not (True|False)
Returns:
- *F*: list of freqs
- *Fx2y*: causality measure from x to y
- *Fy2x*: causality from y to x
- *Fxy*: instantaneous causality between x and y
- *fig*: Figure handle
NOTE: The *include* argument can have the following values:
- 'all': all cells and netstims
- 'allCells': only all cells
Expand Down
6 changes: 4 additions & 2 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The image below illustrates this process:
:width: 50%
:align: center

We will now create a new model file (call it ``tut2.py``) where we will specify from scratch all the network parameters. To create the structures that will hold the network parameters add the following code:
We will now create a new model file (call it ``tut2.py``) where we will specify from scratch all the network parameters. To create the structures that will hold the network parameters add the following code::

from netpyne import specs, sim

Expand All @@ -129,7 +129,9 @@ First, we need to create some populations for our network, by adding items to th

* ``cellModel`` - an attribute or tag that will be assigned to cells in this population, can later be used to set specific cell model implementation for cells with this tag. Eg. 'HH' (standard Hodkgin-Huxley type cell model) or 'Izhi2007b' (Izhikevich 2007 point neuron model). Cell models can be defined by the user or imported.

We will start by creating 2 populations labeled ``S`` (sensory) and ``M`` (motor), with ``20`` cells each, of type ``PYR`` (pyramidal), and using ``HH`` cell model (standard compartmental Hodgkin-Huxley type cell).
We will start by creating 2 populations labeled ``S`` (sensory) and ``M`` (motor), with ``20`` cells each, of type ``PYR`` (pyramidal), and using ``HH`` cell model (standard compartmental Hodgkin-Huxley type cell).

::

## Population parameters
netParams.popParams['S'] = {'cellType': 'PYR', 'numCells': 20, 'cellModel': 'HH'}
Expand Down
4 changes: 2 additions & 2 deletions examples/HHTut/HHTut_run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HHTut # import parameters file
import HHTut # import parameters file
from netpyne import sim # import netpyne sim module

sim.createSimulateAnalyze(netParams = HHTut.netParams, simConfig = HHTut.simConfig) # create and simulate network
sim.createSimulateAnalyze(netParams = HHTut.netParams, simConfig = HHTut.simConfig) # create and simulate network
5 changes: 3 additions & 2 deletions examples/HybridTut/HybridTut.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@


# Analysis and plotting
simConfig.analysis['plotRaster'] = True # Whether or not to plot a raster
simConfig.analysis['plotTraces'] = {'include': [1,51]} # plot recorded traces for this list of cells
simConfig.analysis['plotRaster'] = {'orderInverse': False} #True # Whether or not to plot a raster
#simConfig.analysis['plotTraces'] = {'include': [1,51]} # plot recorded traces for this list of cells
simConfig.analysis['plotRatePSD'] = {'include': ['allCells', 'PYR_HH', 'PYR_Izhi'], 'Fs': 200, 'smooth': 10} # plot recorded traces for this list of cells

2 changes: 1 addition & 1 deletion examples/NeuroMLImport/LEMS_SimpleNet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v0.2.0 (libNeuroML v0.2.20)
This LEMS file has been automatically generated using PyNeuroML v0.2.2 (libNeuroML v0.2.23)
-->

Expand Down
6 changes: 3 additions & 3 deletions examples/NeuroMLImport/SimpleNet.net.nml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2beta5.xsd" id="SimpleNet">
<notes>

This NeuroML 2 file was generated by OpenCortex v0.0.6 using:
libNeuroML v0.2.20
pyNeuroML v0.2.0
This NeuroML 2 file was generated by OpenCortex v0.0.7 using:
libNeuroML v0.2.23
pyNeuroML v0.2.2

</notes>
<property tag="Python random seed" value="1234"/>
Expand Down
6 changes: 3 additions & 3 deletions examples/NeuroMLImport/poissonFiringSyn.mod
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ NET_RECEIVE(flag) {
: This child is a synapse; defining weight
weight = 1

: paramMappings: {syn0={g=syn0_g, tauDecay=syn0_tauDecay, waveformFactor=syn0_waveformFactor, A=syn0_A, B=syn0_B, erev=syn0_erev, gbase=syn0_gbase, peakTime=syn0_peakTime, tauRise=syn0_tauRise, i=syn0_i}, poissonFiringSyn={isi=isi, tsince=tsince, averageRate=averageRate, averageIsi=averageIsi, i=i}}
: paramMappings: {poissonFiringSyn={averageRate=averageRate, i=i, tsince=tsince, isi=isi, averageIsi=averageIsi}, syn0={A=syn0_A, tauRise=syn0_tauRise, gbase=syn0_gbase, erev=syn0_erev, B=syn0_B, peakTime=syn0_peakTime, g=syn0_g, i=syn0_i, tauDecay=syn0_tauDecay, waveformFactor=syn0_waveformFactor}}
? state_discontinuity(syn0_A, syn0_A + (weight * syn0_waveformFactor ))
syn0_A = syn0_A + (weight * syn0_waveformFactor )

: paramMappings: {syn0={g=syn0_g, tauDecay=syn0_tauDecay, waveformFactor=syn0_waveformFactor, A=syn0_A, B=syn0_B, erev=syn0_erev, gbase=syn0_gbase, peakTime=syn0_peakTime, tauRise=syn0_tauRise, i=syn0_i}, poissonFiringSyn={isi=isi, tsince=tsince, averageRate=averageRate, averageIsi=averageIsi, i=i}}
: paramMappings: {poissonFiringSyn={averageRate=averageRate, i=i, tsince=tsince, isi=isi, averageIsi=averageIsi}, syn0={A=syn0_A, tauRise=syn0_tauRise, gbase=syn0_gbase, erev=syn0_erev, B=syn0_B, peakTime=syn0_peakTime, g=syn0_g, i=syn0_i, tauDecay=syn0_tauDecay, waveformFactor=syn0_waveformFactor}}
? state_discontinuity(syn0_B, syn0_B + (weight * syn0_waveformFactor ))
syn0_B = syn0_B + (weight * syn0_waveformFactor )

Expand Down Expand Up @@ -156,8 +156,8 @@ PROCEDURE rates() {
rate_tsince = 1 ? Note units of all quantities used here need to be consistent!


rate_syn0_B = - syn0_B / syn0_tauDecay ? Note units of all quantities used here need to be consistent!
rate_syn0_A = - syn0_A / syn0_tauRise ? Note units of all quantities used here need to be consistent!
rate_syn0_B = - syn0_B / syn0_tauDecay ? Note units of all quantities used here need to be consistent!



Expand Down
Loading

0 comments on commit 1434629

Please sign in to comment.