Skip to content

Commit

Permalink
Merge pull request #460 from apdavison/nest-dev
Browse files Browse the repository at this point in the history
Merge nest-dev into master, support for NEST 2.12.0
  • Loading branch information
apdavison committed Mar 9, 2017
2 parents 3270908 + 4e50b8d commit 45f348d
Show file tree
Hide file tree
Showing 25 changed files with 685 additions and 88 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ after_success:
- coveralls
cache:
directories:
- $HOME/nest-2.10.0
- $HOME/nest-master
- $HOME/nrn-7.4
- $HOME/build/nest-2.10.0
- $HOME/build/nest-master
- $HOME/build/nrn-7.4
- $HOME/.cache/pip
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The following people have contributed to PyNN. Their affiliations at the time of
* Oliver Breitwieser [2]
* Jannis Schücker [16]
* Maximilian Schmidt [16]
* Christian Roessert [13]

1. Unité de Neuroscience, Information et Complexité, CNRS, Gif sur Yvette, France
2. Kirchhoff Institute for Physics, University of Heidelberg, Heidelberg, Germany
Expand Down
52 changes: 28 additions & 24 deletions ci/install_nest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@ set -e # stop execution in case of errors

if [ "$TRAVIS_PYTHON_VERSION" == "2.7" ] || [ "$TRAVIS_PYTHON_VERSION" == "3.5" ]; then
echo -e "\n========== Installing NEST ==========\n"
export NEST_VERSION="2.10.0"
export NEST="nest-$NEST_VERSION"
pip install cython
if [ ! -f "$HOME/$NEST_VERSION/configure" ]; then
wget https://github.com/nest/nest-simulator/releases/download/v$NEST_VERSION/$NEST.tar.gz -O $HOME/$NEST.tar.gz;
pushd $HOME;
tar xzf $NEST.tar.gz;
popd;
else
echo 'Using cached version of NEST sources.';
fi
#export NEST_VERSION="master"
export NEST_VERSION="2.12.0"
export NEST="nest-simulator-$NEST_VERSION"
pip install cython==0.23.4
#wget https://github.com/nest/nest-simulator/archive/$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz;
wget https://github.com/nest/nest-simulator/releases/download/v$NEST_VERSION/nest-$NEST_VERSION.tar.gz -O $HOME/$NEST.tar.gz
pushd $HOME;
tar xzf $NEST.tar.gz;
ls;
popd;

mkdir -p $HOME/build/$NEST
pushd $HOME/build/$NEST
if [ ! -f "$HOME/build/$NEST/config.log" ]; then
export VENV=`python -c "import sys; print(sys.prefix)"`;
$HOME/$NEST/configure --with-mpi --prefix=$VENV;
make;
else
echo 'Using cached NEST build directory.';
echo "$HOME/$NEST";
ls $HOME/$NEST;
echo "$HOME/build/$NEST";
ls $HOME/build/$NEST;
export VENV=`python -c "import sys; print(sys.prefix)"`;
ln -s /opt/python/2.7.12/lib/libpython2.7.so $VENV/lib/libpython2.7.so;
ln -s /opt/python/3.5.2/lib/libpython3.5m.so $VENV/lib/libpython3.5.so;
export PYTHON_INCLUDE_DIR=$VENV/include/python${TRAVIS_PYTHON_VERSION}
if [ "$TRAVIS_PYTHON_VERSION" == "3.5" ]; then
export PYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}m;
fi
make install
popd

cython --version;
cmake --version;
cmake -DCMAKE_INSTALL_PREFIX=$VENV \
-Dwith-mpi=ON \
-DPYTHON_LIBRARY=$VENV/lib/libpython${TRAVIS_PYTHON_VERSION}.so \
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} \
$HOME/$NEST;
make;
make install;
popd;
python -c "import nest";
fi
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MockNESTModule(mock.Mock):
# General information about the project.
project = u'PyNN'
authors = u'the PyNN community'
copyright = u'2006-2016, ' + authors
copyright = u'2006-2017, ' + authors

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -80,7 +80,7 @@ class MockNESTModule(mock.Mock):
# The short X.Y version.
version = '0.8'
# The full version, including alpha/beta/rc tags.
release = '0.8.2'
release = '0.8.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 3 additions & 3 deletions doc/developers/contributing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ We try to stay fairly close to PEP8_. Please note in particular:
- some function/method names in PyNN use ``mixedCase``, but these will
gradually be deprecated and replaced with ``lower_case_with_underscores``.
Any new functions or methods should use the latter.
- we currently target versions 2.6, 2.7 and 3.4
- we currently target versions 2.6, 2.7 and 3.3-3.6


Testing
Expand Down Expand Up @@ -166,7 +166,7 @@ Making a release
================

To make a release of PyNN requires you to have permissions to upload PyNN
packages to the `Python Package Index`_ and the INCF Software Center, and to
packages to the `Python Package Index`_, and to
upload documentation to the neuralensemble.org server. If you are interested
in becoming release manager for PyNN, please contact us via the `mailing list`_.

Expand All @@ -177,7 +177,7 @@ last time:
:file:`test/unittests` and :file:`test/system` and running :command:`make doctest` in
:file:`doc`. You should do this on at least two Linux systems -- one a very
recent version and one at least a year old, and on at least one version of
Mac OS X. You should also do this with Python 2.6, 2.7 and 3.4 or 3.5.
Mac OS X. You should also do this with Python 2.6, 2.7 and 3.4, 3.5 or 3.6.
* do all the example scripts generate the correct output? Run the
:file:`run_all_examples.py` script in :file:`examples/tools` and then visually
check the :file:`.png` files generated in :file:`examples/tools/Results`. Again,
Expand Down
10 changes: 5 additions & 5 deletions doc/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install and run PyNN on Windows, but this has not been tested.

Installing PyNN requires:

* Python (version 2.6, 2.7, 3.3, 3.4 or 3.5)
* Python (version 2.6, 2.7, 3.3-3.6)
* a recent version of the NumPy_ package
* the lazyarray_ package
* the Neo_ package
Expand All @@ -32,8 +32,8 @@ If you are running Debian or Ubuntu, there are :doc:`binary packages <download>`
available. If you would prefer to install manually, :doc:`download the latest
source distribution <download>`, then run the setup script, e.g.::

$ tar xzf PyNN-0.8.2.tar.gz
$ cd PyNN-0.8.2
$ tar xzf PyNN-0.8.3.tar.gz
$ cd PyNN-0.8.3
$ python setup.py install

This will install it to your Python :file:`site-packages` directory, and may
Expand Down Expand Up @@ -111,7 +111,7 @@ If you run into problems, check out the `NEURON Forum`_.
Installing NEST and PyNEST
==========================

NEST 2.10 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
NEST 2.12 can be downloaded from `<http://www.nest-simulator.org/download/>`_.
Earlier versions of NEST will not work with this version of PyNN.
The full installation instructions are available in the file INSTALL, which you can find in the NEST source package,
or at `<http://www.nest-simulator.org/installation/>`_.
Expand All @@ -138,7 +138,7 @@ Now try it out::
-- N E S T --

Copyright (C) 2004 The NEST Initiative
Version 2.10.0 Mar 21 2016 21:29:37
Version 2.12.0 Mar 21 2016 21:29:37
...
>>> nest.Models()
(u'ac_generator', u'aeif_cond_alpha', u'aeif_cond_alpha_RK5', u'aeif_cond_alpha_multisynapse',
Expand Down
1 change: 1 addition & 0 deletions doc/release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Release notes
.. toctree::
:maxdepth: 1

releases/0.8.3.txt
releases/0.8.2.txt
releases/0.8.1.txt
releases/0.8.0.txt
Expand Down
31 changes: 31 additions & 0 deletions doc/releases/0.8.3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
========================
PyNN 0.8.3 release notes
========================

8th March 2017

Welcome to PyNN 0.8.3!


NeuroML 2
---------

The `neuroml` module has been completely rewritten, and updated from NeuroML v1 to v2.
This module works like other PyNN "backends", i.e. ``import pyNN.neuroml as sim``...
but instead of running a simulation, it exports the network to an XML file in NeuroML format.

NEST 2.12
---------

This release introduces support for NEST_ 2.12. Previous versions of NEST are no longer supported.


Other changes
-------------

* `A couple of bug fixes`_



.. _Brian: http://briansimulator.org
.. _`A couple of bug fixes`: https://github.com/NeuralEnsemble/PyNN/issues?q=is%3Aclosed+milestone%3A0.8.3
115 changes: 115 additions & 0 deletions examples/gif_neuron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""
Demonstration of the Generalized Integrate-and-Fire model described by Pozzorini et al. (2015)
We simulate four neurons with different parameters:
1. spike-triggered current, fixed threshold, deterministic spiking
2. no spike-triggered current, dynamic threshold, deterministic spiking
3 & 4. no spike-triggered current, fixed threshold, stochastic spiking
Since neurons 1 and 2 have deterministic spiking, they should produce the same spike times with
different simulators. Neurons 3 and 4, being stochastic, should spike at different times.
Reference:
Pozzorini, Christian, Skander Mensi, Olivier Hagens, Richard Naud, Christof Koch, and Wulfram Gerstner (2015)
"Automated High-Throughput Characterization of Single Neurons by Means of Simplified Spiking Models."
PLOS Comput Biol 11 (6): e1004275. doi:10.1371/journal.pcbi.1004275.
"""

import matplotlib
matplotlib.use('Agg')
from pyNN.utility import get_simulator, init_logging, normalized_filename


# === Configure the simulator ================================================

sim, options = get_simulator(("--plot-figure", "Plot the simulation results to a file.", {"action": "store_true"}),
("--debug", "Print debugging information"))

if options.debug:
init_logging(None, debug=True)

sim.setup(timestep=0.01, min_delay=1.0)


# === Build and instrument the network =======================================

t_stop = 300.0

parameters = {
'neurons': {
'v_rest': -65.0, # Resting membrane potential in mV.
'cm': 1.0, # Capacity of the membrane in nF
'tau_m': 20.0, # Membrane time constant in ms.
'tau_refrac': 4.0, # Duration of refractory period in ms.
'tau_syn_E': 5.0, # Decay time of the excitatory synaptic conductance in ms.
'tau_syn_I': 5.0, # Decay time of the inhibitory synaptic conductance in ms.
'e_rev_E': 0.0, # Reversal potential for excitatory input in mV
'e_rev_I': -70.0, # Reversal potential for inhibitory input in mV
'v_reset': -65.0, # Reset potential after a spike in mV.
'i_offset': 0.0, # Offset current in nA
'v_t_star': -55.0, # Threshold baseline in mV.
'lambda0': 1.0, # Firing intensity at threshold in Hz.
'tau_eta1': 1.0, # }
'tau_eta2': 10.0, # } Time constants for spike-triggered current in ms.
'tau_eta3': 100.0, # }
'tau_gamma1': 1.0, # }
'tau_gamma2': 10.0, # } Time constants for spike-frequency adaptation in ms.
'tau_gamma3': 100.0, # }
# the following parameters have different values for each neuron
'delta_v': [1e-6, 1e-6, 0.5, 0.5], # Threshold sharpness in mV.
'a_eta1': [0.1, 0.0, 0.0, 0.0], # }
'a_eta2': [0.1, 0.0, 0.0, 0.0], # } Post-spike increments for spike-triggered current in nA
'a_eta3': [0.1, 0.0, 0.0, 0.0], # }
'a_gamma1': [0.0, 5.0, 0.0, 0.0], # }
'a_gamma2': [0.0, 5.0, 0.0, 0.0], # } Post-spike increments for spike-frequency adaptation in mV
'a_gamma3': [0.0, 5.0, 0.0, 0.0], # }
},
'stimulus': {
'start': 20.0,
'stop': t_stop - 20.0,
'amplitude': 0.6
}
}

neurons = sim.Population(4, sim.GIF_cond_exp(**parameters['neurons']))

electrode = sim.DCSource(**parameters['stimulus'])
electrode.inject_into(neurons)

neurons.record(['v', 'i_eta', 'v_t'])


# === Run the simulation =====================================================

sim.run(t_stop)

# === Save the results, optionally plot a figure =============================

filename = normalized_filename("Results", "gif_neuron", "pkl",
options.simulator, sim.num_processes())
neurons.write_data(filename, annotations={'script_name': __file__})

if options.plot_figure:
from pyNN.utility.plotting import Figure, Panel
figure_filename = filename.replace("pkl", "png")
data = neurons.get_data().segments[0]
v = data.filter(name="v")[0]
v_t = data.filter(name="v_t")[0]
i_eta = data.filter(name="i_eta")[0]
Figure(
Panel(v, ylabel="Membrane potential (mV)",
yticks=True, ylim=[-66, -52]),
Panel(v_t, ylabel="Threshold (mV)",
yticks=True),
Panel(i_eta, ylabel="i_eta (nA)", xticks=True,
xlabel="Time (ms)", yticks=True),
annotations="Simulated with %s" % options.simulator.upper()
).save(figure_filename)
print(figure_filename)


# === Clean up and quit ========================================================

sim.end()
2 changes: 1 addition & 1 deletion pyNN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
:license: CeCILL, see LICENSE for details.
"""

__version__ = '0.8.2'
__version__ = '0.8.3'
__all__ = ["common", "random", "nest", "neuron", "brian",
"recording", "errors", "space", "descriptions",
"standardmodels", "parameters", "core"]
1 change: 1 addition & 0 deletions pyNN/nest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
if logger.level == logging.NOTSET:
logger.setLevel(logging.ERROR)


# ==============================================================================
# Utility functions
# ==============================================================================
Expand Down
3 changes: 2 additions & 1 deletion pyNN/nest/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def get_defaults(model_name):
'recordables', 'state', 't_spike', 'tau_minus', 'tau_minus_triplet',
'thread', 'vp', 'receptor_types', 'events', 'global_id',
'element_type', 'type', 'type_id', 'has_connections', 'n_synapses',
'thread_local_id', 'synaptic_elements']
'thread_local_id', 'node_uses_wfr', 'supports_precise_spikes',
'synaptic_elements']
default_params = {}
default_initial_values = {}
for name, value in defaults.items():
Expand Down
12 changes: 12 additions & 0 deletions pyNN/nest/populations.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,24 @@ def _build_params(parameter_space, mask_local, size=None, extra_parameters=None)
for name, val in cell_parameters.items():
if isinstance(val, Sequence):
cell_parameters[name] = val.value
# The following is a temporary hack to get the gif_cond_exp model working.
# Longer-term, an extension to lazyarray would be the best approach
if 'tau_sfa1' in cell_parameters:
cell_parameters['tau_sfa'] = (cell_parameters.pop('tau_sfa1'), cell_parameters.pop('tau_sfa2'), cell_parameters.pop('tau_sfa3'))
cell_parameters['q_sfa'] = (cell_parameters.pop('q_sfa1'), cell_parameters.pop('q_sfa2'), cell_parameters.pop('q_sfa3'))
cell_parameters['tau_stc'] = (cell_parameters.pop('tau_stc1'), cell_parameters.pop('tau_stc2'), cell_parameters.pop('tau_stc3'))
cell_parameters['q_stc'] = (cell_parameters.pop('q_stc1'), cell_parameters.pop('q_stc2'), cell_parameters.pop('q_stc3'))
else:
parameter_space.evaluate(mask=mask_local)
cell_parameters = list(parameter_space) # may not be the most efficient way.
# Might be best to set homogeneous parameters on creation,
# then inhomogeneous ones using SetStatus. Need some timings.
for D in cell_parameters:
if 'tau_sfa1' in D: # temporary hack
D['tau_sfa'] = (D.pop('tau_sfa1'), D.pop('tau_sfa2'), D.pop('tau_sfa3'))
D['q_sfa'] = (D.pop('q_sfa1'), D.pop('q_sfa2'), D.pop('q_sfa3'))
D['tau_stc'] = (D.pop('tau_stc1'), D.pop('tau_stc2'), D.pop('tau_stc3'))
D['q_stc'] = (D.pop('q_stc1'), D.pop('q_stc2'), D.pop('q_stc3'))
for name, val in D.items():
if isinstance(val, Sequence):
D[name] = val.value
Expand Down
5 changes: 3 additions & 2 deletions pyNN/nest/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
from pyNN import recording
from pyNN.nest import simulator

# todo: this information should come from the cell type classes
VARIABLE_MAP = {'v': 'V_m', 'gsyn_exc': 'g_ex', 'gsyn_inh': 'g_in', 'u': 'U_m',
'w': 'w'}
'w': 'w', 'i_eta': 'I_stc', 'v_t': 'E_sfa'}
REVERSE_VARIABLE_MAP = dict((v, k) for k, v in VARIABLE_MAP.items())
SCALE_FACTORS = {'v': 1, 'gsyn_exc': 0.001, 'gsyn_inh': 0.001, 'w': 0.001}
SCALE_FACTORS = {'v': 1, 'gsyn_exc': 0.001, 'gsyn_inh': 0.001, 'w': 0.001, 'i_eta': 0.001, 'v_t': 1}

logger = logging.getLogger("PyNN")

Expand Down
Loading

0 comments on commit 45f348d

Please sign in to comment.