Skip to content

Commit

Permalink
Merge pull request #604 from Neurosim-lab/development: PR from develo…
Browse files Browse the repository at this point in the history
…pment to master - VERSION 1.0.0

PR from development to master - VERSION 1.0.0
  • Loading branch information
joewgraham authored May 13, 2021
2 parents dc60324 + 189ae65 commit b9ec505
Show file tree
Hide file tree
Showing 64 changed files with 2,196 additions and 1,541 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run NetPyNE tests
on: [push]
jobs:
Run-Tests:
runs-on: ubuntu-18.04

strategy:
matrix:
python-version: [3.7]

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Update apt-get
run: sudo apt-get update

- name: Install packages
run: sudo apt-get install python-tk python3-tables

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Test with pytest
run: |
source tests/test.sh
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ i386
*.dll
umac
.DS_Store
venv/

/examples/HybridTut/*.nml
/examples/HybridTut/*.mod
Expand Down Expand Up @@ -50,4 +51,4 @@ umac
/examples/M1/*.png
/examples/M1/*.pov
/examples/HHTut/temp.json
.vscode
.vscode
31 changes: 31 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Version 1.0.0

**New features**

- Added wrapper for distributed saving; can now simply replace 'sim.gatherData()' with 'sim.gatherDataFromNodes()'

- Added distributed saving/loading ability (save/load data by MPI node)

- Allowed to specify 'cellModel' and point neuron params in netParams.cellParams (not only in netParams.popParams)

- Added cellsVisualizationSpacingMultiplier property to netParams

- Improved Granger plot, renamed it plotGranger

- Added interactive Granger plot (iplotGranger)

- Implemented testing in GitHub Actions with pytest (thanks Daniel!)

- Improved sim.clearAll such that it works even before a sim is run

- Properly formatted all module docstrings

**Bug fixes**

- Fixed bug in TupleToStr function

- Fixed broken links in tutorials

- Bokeh update required changing options from None to 'auto'


# Version 0.9.9.1

**Bug fixes**
Expand Down
8 changes: 4 additions & 4 deletions doc/source/code/tut5.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@


simConfig.analysis['plotRaster'] = {'orderBy': 'y', 'orderInverse': True, 'saveFig': True} # Plot a raster
simConfig.analysis['plotTraces'] = {'include': [('E2',0), ('E4', 0), ('E5', 5)], 'saveFig': True} # Plot recorded traces for this list of cells
simConfig.analysis['plot2Dnet'] = {'saveFig': True} # plot 2D cell positions and connections
simConfig.analysis['plotConn'] = {'saveFig': True} # plot connectivity matrix

# simConfig.analysis['plotTraces'] = {'include': [('E2',0), ('E4', 0), ('E5', 5)], 'saveFig': True} # Plot recorded traces for this list of cells
# simConfig.analysis['plot2Dnet'] = {'saveFig': True} # plot 2D cell positions and connections
# simConfig.analysis['plotConn'] = {'saveFig': True} # plot connectivity matrix
#simConfig.analysis['plot2Dfiring'] = {'saveFig': True, 'showFig': True}

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/code/tut7.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
netParams.cellParams['PYR'] = {'secs': secs} # add dict to list of cell properties

# Population parameters
netParams.popParams['hop'] = {'cellType': 'PYR', 'cellModel': 'HH', 'numCells': 50} # add dict with params for this pop
netParams.popParams['hop'] = {'cellType': 'PYR', 'numCells': 50} # add dict with params for this pop
#netParams.popParams['background'] = {'cellModel': 'NetStim', 'rate': 50, 'noise': 0.5} # background inputs

# Synaptic mechanism parameters
Expand Down
1 change: 0 additions & 1 deletion doc/source/code/tut8_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def batchTauWeight():
# fill in with parameters to explore and range of values (key has to coincide with a variable in simConfig)
params['synMechTau2'] = [3.0, 5.0, 7.0]
params['connWeight'] = [0.005, 0.01, 0.15]
params[('analysis', 'plotTraces', 'saveFig')] = [True, False]

# create Batch object with parameters to modify, and specifying files to use
b = Batch(params=params, cfgFile='tut8_cfg.py', netParamsFile='tut8_netParams.py',)
Expand Down
41 changes: 24 additions & 17 deletions doc/source/code/tut_artif.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@
###############################################################################

# Population parameters
netParams.popParams['PYR1'] = {'cellModel': 'HH', 'cellType': 'PYR', 'numCells': 100} # pop of HH cells
netParams.popParams['artif1'] = {'cellModel': 'NetStim', 'numCells': 100, 'rate': 50, 'noise': 0.8, 'start': 1, 'seed': 2} # pop of NetStims
netParams.popParams['artif2'] = {'cellModel': 'IntFire2', 'numCells': 100, 'ib': 0.0} # pop of IntFire2
netParams.popParams['artif3'] = {'cellModel': 'IntFire4', 'numCells': 100, 'taue': 1.0} # pop of IntFire4
netParams.popParams['artif4'] = {'cellModel': 'VecStim', 'numCells': 100, 'rate': 5, 'noise': 0.5, 'start': 50,
netParams.popParams['PYR1'] = {'cellType': 'PYR', 'numCells': 100} # pop of HH cells
netParams.popParams['artif1'] = {'cellType': 'artif_NetStim', 'numCells': 100} # pop of NetStims
netParams.popParams['artif2'] = {'cellType': 'artif_IntFire2', 'numCells': 100} # pop of IntFire2
netParams.popParams['artif3'] = {'cellType': 'artif_IntFire4', 'numCells': 100} # pop of IntFire4
netParams.popParams['artif4'] = {'cellType': 'artif_VecStim', 'numCells': 100} # pop of Vecstims with 2 pulses

# Cell parameters
## PYR cell properties
cellParams = Dict()
cellParams.secs.soma.geom = {'diam': 18.8, 'L': 18.8, 'Ra': 123.0}
cellParams.secs.soma.mechs.hh = {'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.003, 'el': -70}
netParams.cellParams['PYR'] = cellParams

netParams.cellParams['artif_NetStim'] = {'cellModel': 'NetStim', 'rate': 50, 'noise': 0.8, 'start': 1, 'seed': 2} # pop of NetStims
netParams.cellParams['artif_IntFire2'] = {'cellModel': 'IntFire2', 'ib': 0.0} # pop of IntFire2
netParams.cellParams['artif3_IntFire4'] = {'cellModel': 'IntFire4', 'taue': 1.0} # pop of IntFire4
netParams.cellParams['artif4_Vecstim'] = {'cellModel': 'VecStim', 'rate': 5, 'noise': 0.5, 'start': 50,
'pulses': [{'start': 200, 'end': 300, 'rate': 60, 'noise':0.2}, {'start': 500, 'end': 800, 'rate': 30, 'noise': 0.5}]} # pop of Vecstims with 2 pulses


# Synaptic mechanism parameters
netParams.synMechParams['AMPA'] = {'mod': 'Exp2Syn', 'tau1': 0.1, 'tau2': 1.0, 'e': 0}

Expand All @@ -32,31 +45,25 @@
netParams.stimTargetParams['bkg->PYR1'] = {'source': 'background', 'conds': {'pop': 'PYR1'}, 'sec':'soma', 'loc': 0.5, 'weight': 0.5, 'delay': 1}


# Cell parameters
## PYR cell properties
cellParams = Dict()
cellParams.secs.soma.geom = {'diam': 18.8, 'L': 18.8, 'Ra': 123.0}
cellParams.secs.soma.mechs.hh = {'gnabar': 0.12, 'gkbar': 0.036, 'gl': 0.003, 'el': -70}
cellParams.conds = {'cellType': 'PYR'}
netParams.cellParams['PYR'] = cellParams


# Connections
netParams.connParams['artif1->PYR1'] = {
'preConds': {'pop': 'artif1'}, 'postConds': {'pop': 'PYR1'},
'preConds': {'pop': 'artif1'},
'postConds': {'pop': 'PYR1'},
'convergence': 8,
'weight': 0.005,
'synMech': 'AMPA',
'delay': 'uniform(1,5)'}

netParams.connParams['PYR1->artif2'] = {
'preConds': {'pop': 'PYR1'}, 'postConds': {'pop': 'artif2'},
'preConds': {'pop': 'PYR1'},
'postConds': {'pop': 'artif2'},
'probability': 0.2,
'weight': 0.2,
'delay': 'uniform(1,5)'}

netParams.addConnParams('artif2->artif3',
{'preConds': {'pop': 'artif2'}, 'postConds': {'pop': 'artif3'},
{'preConds': {'pop': 'artif2'},
'postConds': {'pop': 'artif3'},
'divergence': 20,
'weight': 0.05,
'delay': 3})
Expand Down
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
# built documents.
#
# The short X.Y version.
version = '0.9.9.1'
version = '1.0.0'
# The full version, including alpha/beta/rc tags.
release = '0.9.9.1'
release = '1.0.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ The first example ( :download:`cell_lfp.py <../../examples/LFPrecording/cell_lfp
:width: 60%
:align: center

The second example ( :download:`net_lfp.py <<../../examples/LFPrecording/net_lfp.py>`) shows LFP recording for a network very similar to that shown in Tutorial 5. However, in this case, the cells have been replaced with a more realistic model: a 6-compartment M1 corticostriatal neuron with multiple ionic channels. The cell parameters are loaded from a .json file. Cell receive NetStim inputs and include excitatory and inhibitory connections. Four LFP electrodes are placed at different cortical depths. The raster plot and LFP time-resolved signal, PSD, spectrogram and 3D locations of the electrodes are plotted:
The second example ( :download:`net_lfp.py <../../examples/LFPrecording/net_lfp.py>`) shows LFP recording for a network very similar to that shown in Tutorial 5. However, in this case, the cells have been replaced with a more realistic model: a 6-compartment M1 corticostriatal neuron with multiple ionic channels. The cell parameters are loaded from a .json file. Cell receive NetStim inputs and include excitatory and inhibitory connections. Four LFP electrodes are placed at different cortical depths. The raster plot and LFP time-resolved signal, PSD, spectrogram and 3D locations of the electrodes are plotted:

.. image:: figs/lfp_net.png
:width: 90%
Expand All @@ -937,7 +937,7 @@ Tutorial 10: Network with Reaction-Diffusion (RxD)
NetPyNE's high-level specifications also supports `NEURON's reaction-diffusion (RxD) <https://www.neuron.yale.edu/neuron/static/docs/rxd/index.html>`_ components. RxD enables to specify the diffusion of molecules (\eg\ calcium, potassium or IP3) intracellularly, subcellularly (by including organelles such as endoplasmic reticulum and mitochondria), and extracellularly is the context of signaling and enzymatic processing -- \eg\ metabolism, phosphorylation, buffering, second messenger cascades.
This helps to couple molecular-level chemophysiology to the classical electrophysiology at subcellular, cellular and network scales.

The ``netParams.rxdParams`` dictionary can be used to define the different RxD components: ``regions``, ``species``, ``states``, ``reactions``, ``multicompartmentReactions`` and ``rates``. Example models that include RxD components in single cells and networks are included in the \examples folder: `RxD buffering example <https://github.com/Neurosim-lab/netpyne/tree/development/examples/rxd_buffering>`_ and `RxD network example <https://github.com/Neurosim-lab/netpyne/tree/development/examples/rxd_network>`_. RxD also works with parallel simulations.
The ``netParams.rxdParams`` dictionary can be used to define the different RxD components: ``regions``, ``species``, ``states``, ``reactions``, ``multicompartmentReactions`` and ``rates``. Example models that include RxD components in single cells and networks are included in the \examples folder: `RxD buffering example <https://github.com/Neurosim-lab/netpyne/tree/development/examples/rxd_buffering>`_ and `RxD network example <https://github.com/Neurosim-lab/netpyne/tree/development/examples/rxd_net>`_. RxD also works with parallel simulations.



Expand Down
16 changes: 8 additions & 8 deletions examples/HybridTut/HybridTut.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
###############################################################################

# Population parameters
netParams.popParams['PYR_HH'] = {'cellModel': 'HH', 'cellType': 'PYR', 'numCells': 50} # add dict with params for this pop
netParams.popParams['PYR_Izhi'] = {'cellModel': 'Izhi', 'cellType': 'PYR', 'numCells': 50} # add dict with params for this pop
netParams.popParams['PYR_HH_pop'] = {'cellType': 'PYR_HH', 'numCells': 50} # add dict with params for this pop
netParams.popParams['PYR_Izhi_pop'] = {'cellType': 'PYR_Izhi', 'numCells': 50} # add dict with params for this pop


# Cell parameters list
## PYR cell properties (HH)
cellRule = {'conds': {'cellType': 'PYR', 'cellModel': 'HH'}, 'secs': {}}
cellRule = {'secs': {}}
cellRule['secs']['soma'] = {'geom': {}, 'topol': {}, 'mechs': {}} # soma properties
cellRule['secs']['soma']['geom'] = {'diam': 6.3, 'L': 5, 'Ra': 123.0, 'pt3d':[]}
cellRule['secs']['soma']['geom']['pt3d'].append((0, 0, 0, 20))
Expand All @@ -43,7 +43,7 @@
netParams.cellParams['PYR_HH'] = cellRule # add dict to list of cell properties

## PYR cell properties (Izhi)
cellRule = {'conds': {'cellType': 'PYR', 'cellModel': 'Izhi'}, 'secs': {}}
cellRule = {'secs': {}}
cellRule['secs']['soma'] = {'geom': {}, 'pointps':{}} # soma properties
cellRule['secs']['soma']['geom'] = {'diam': 10, 'L': 10, 'cm': 31.831}
cellRule['secs']['soma']['pointps']['Izhi'] = {'mod':'Izhi2007b',
Expand All @@ -57,15 +57,16 @@

# Stimulation parameters
netParams.stimSourceParams['bkg'] = {'type': 'NetStim', 'rate': 10, 'noise': 0.5}
netParams.stimTargetParams['bg->PYR_Izhi'] = {'source': 'bkg', 'conds': {'cellType': 'PYR', 'cellModel': 'Izhi'},
netParams.stimTargetParams['bg->PYR_Izhi'] = {'source': 'bkg', 'conds': {'cellType': 'PYR_Izhi'},
'weight': 1, 'delay': 'uniform(1,5)', 'synMech': 'AMPA'}
netParams.stimTargetParams['bg->PYR_HH'] = {'source': 'bkg', 'conds': {'cellType': 'PYR', 'cellModel': 'HH'},
netParams.stimTargetParams['bg->PYR_HH'] = {'source': 'bkg', 'conds': {'cellType': 'PYR_HH'},
'weight': 1, 'synMech': 'AMPA', 'sec': 'dend', 'loc': 1.0, 'delay': 'uniform(1,5)'}


# Connectivity parameters
netParams.connParams['PYR->PYR'] = {
'preConds': {'cellType': 'PYR'}, 'postConds': {'cellType': 'PYR'},
'preConds': {'cellType': ['PYR_HH', 'PYR_Izhi']},
'postConds': {'cellType': ['PYR_HH', 'PYR_Izhi']},
'weight': 0.2, # weight of each connection
'delay': '0.2+normal(13.0,1.4)', # delay min=0.2, mean=13.0, var = 1.4
'threshold': 10, # threshold
Expand Down Expand Up @@ -112,4 +113,3 @@
# Analysis and plotting
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'], 'smooth': 10} # plot recorded traces for this list of cells
4 changes: 2 additions & 2 deletions examples/LFPrecording/cell_lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

simConfig.analysis['plotTraces'] = {'include': [('E',0)], 'oneFigPer':'cell', 'overlay': True, 'figSize': (5,3),'saveFig': True} # Plot recorded traces for this list of cells
simConfig.analysis['plotLFP'] = {'includeAxon': False, 'plots': ['timeSeries', 'locations'], 'figSize': (5,9), 'saveFig': True}
simConfig.analysis['getCSD'] = {'timeRange': [10,45],'spacing_um': 150, 'vaknin': True}
simConfig.analysis['plotCSD'] = {'LFP_overlay':True}
#simConfig.analysis['getCSD'] = {'timeRange': [10,45],'spacing_um': 150, 'vaknin': True}
simConfig.analysis['plotCSD'] = {'timeRange': [10,45]}
#sim.analysis.getCSD(...args...)
#simConfig.analysis['plotCSD'] = {}

Expand Down
4 changes: 2 additions & 2 deletions examples/LFPrecording/net_lfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# Simulation configuration
simConfig = specs.SimConfig() # object of class SimConfig to store simulation configuration
simConfig.duration = 3.0*1e3 # Duration of the simulation, in ms
simConfig.duration = 300 #3.0*1e3 # Duration of the simulation, in ms
simConfig.dt = 0.1 # Internal integration timestep to use
simConfig.verbose = False # Show detailed messages
simConfig.recordStep = 1 # Step size in ms to save data (eg. V traces, LFP, etc)
Expand All @@ -59,7 +59,7 @@
simConfig.analysis['plotLFP'] = {'includeAxon': False, 'figSize': (6,10), 'timeRange': [100,3000], 'saveFig': True}
#simConfig.analysis['getCSD'] = {'spacing_um': 200, 'timeRange': [100,3000], 'vaknin': True}
#simConfig.analysis['plotLFP'] = {'includeAxon': False, 'figSize': (6,10), 'timeRange':[100,900], 'minFreq': 10, 'maxFreq':60, 'norm':1, 'plots': ['spectrogram'], 'showFig': True}
simConfig.analysis['plotCSD'] = {'timeRange':[100,3000]}
simConfig.analysis['plotCSD'] = {'timeRange':[100,200]}

# Create network and run simulation
sim.createSimulateAnalyze(netParams = netParams, simConfig = simConfig)
Expand Down
2 changes: 1 addition & 1 deletion netpyne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
NetPyNE consists of a number of sub-packages and modules.
"""

__version__ = '0.9.9.1'
__version__ = '1.0.0'
import os, sys
display = os.getenv('DISPLAY')
nogui = (sys.argv.count('-nogui')>0)
Expand Down
9 changes: 5 additions & 4 deletions netpyne/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
# Import utils methods
# -------------------------------------------------------------------------------------------------------------------
from .utils import exception, _showFigure, _saveFigData, getCellsInclude, getCellsIncludeTags, _roundFigures, \
_smooth1d, syncMeasure, invertDictMapping
_smooth1d, syncMeasure, invertDictMapping, checkAvailablePlots


# -------------------------------------------------------------------------------------------------------------------
# Import connectivity-related functions
# -------------------------------------------------------------------------------------------------------------------
from .network import plotConn, _plotConnCalculateFromSim, _plotConnCalculateFromFile, plot2Dnet, plotShape, calculateDisynaptic
from .network import plotConn, _plotConnCalculateFromSim, _plotConnCalculateFromFile, plot2Dnet, plotShape, calculateDisynaptic, \
plot2Dfiring


# -------------------------------------------------------------------------------------------------------------------
Expand All @@ -53,7 +54,7 @@
# -------------------------------------------------------------------------------------------------------------------
# Import information theory-related functions
# -------------------------------------------------------------------------------------------------------------------
from .info import nTE, granger
from .info import nTE, granger, plotGranger


# -------------------------------------------------------------------------------------------------------------------
Expand All @@ -67,7 +68,7 @@
# -------------------------------------------------------------------------------------------------------------------

try:
from .interactive import iplotDipole, iplotDipoleSpectrogram, iplotDipolePSD, iplotRaster, iplotSpikeHist, iplotRatePSD, iplotTraces, iplotLFP, iplotConn, iplotRxDConcentration, iplot2Dnet, iplotSpikeStats
from .interactive import iplotDipole, iplotDipoleSpectrogram, iplotDipolePSD, iplotRaster, iplotSpikeHist, iplotRatePSD, iplotTraces, iplotLFP, iplotConn, iplotRxDConcentration, iplot2Dnet, iplotSpikeStats, iplotGranger
except:
print('Warning: could not import interactive plotting functions; make sure the "bokeh" package is installed.')

Expand Down
Loading

0 comments on commit b9ec505

Please sign in to comment.