Skip to content

Commit

Permalink
Issue #113 fixes (#114)
Browse files Browse the repository at this point in the history
* updated/added install instructions for Ubuntu 18.04 LTS

* docstring fformatting

* adding Python 3.7 to travis testing

* 3.7 not ready for prime time

* documentation updates, updated recipe for NEURON source install on Ubuntu

* removed use of h.SectionList.allsec method

* build NEURON against github master

* fix test with NEURON@github:master

* prep next release 2.0.1

* debug py27 travis build

* debug travis python27

* send NEURON .configure output to null

* v2.0.1 version number

* removed csa from dependency_links list

* neuron 7.6.4 a requirement for this version

* add NEURON >= v7.6.4 version testing

* Update README.md

* Update README.md

* LFPy.__version__ = '2.0.1'
  • Loading branch information
espenhgn committed Jan 3, 2019
1 parent 2e5797a commit 2e0db05
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 138 deletions.
2 changes: 1 addition & 1 deletion LFPy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* run_simulations - Functions to run NEURON simulations
"""

__version__ = "2.0.0"
__version__ = "2.0.1"

from .pointprocess import Synapse, PointProcess, StimIntElectrode
from .recextelectrode import RecExtElectrode, RecMEAElectrode
Expand Down
17 changes: 15 additions & 2 deletions LFPy/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
from .run_simulation import _collect_geometry_neuron
from .alias_method import alias_method

# check neuron version:
try:
try:
assert(neuron.version >= '7.6.4')
except AttributeError:
warn('LFPy could not read NEURON version info. v7.6.4 or newer required')
except AssertionError:
warn('LFPy requires NEURON v7.6.4 or newer. Found v{}'.format(neuron.version))


class Cell(object):
"""
Expand Down Expand Up @@ -2169,7 +2178,7 @@ def get_axial_currents_from_vmem(self, timepoints=None):
self.zend - self.zmid]

children_dict = self.get_dict_of_children_idx()
for sec in self.allseclist.allsec():
for sec in self.allseclist:
if not neuron.h.SectionRef(sec.name()).has_parent():
if sec.nseg == 1:
# skip soma, since soma is an orphan
Expand Down Expand Up @@ -2262,6 +2271,7 @@ def get_axial_currents_from_vmem(self, timepoints=None):
def get_axial_resistance(self):
"""
Return NEURON axial resistance for all cell compartments.
Returns
-------
ri_list : ndarray, dtype=float
Expand Down Expand Up @@ -2289,6 +2299,7 @@ def get_axial_resistance(self):
def get_dict_of_children_idx(self):
"""
Return dictionary with children segment indices for all sections.
Returns
-------
children_dict : dictionary
Expand All @@ -2298,7 +2309,7 @@ def get_dict_of_children_idx(self):
sibling of a segment.
"""
children_dict = {}
for sec in self.allseclist.allsec():
for sec in self.allseclist:
children_dict[sec.name()] = []
for child in neuron.h.SectionRef(sec.name()).child:
# add index of first segment of each child
Expand All @@ -2310,6 +2321,7 @@ def get_dict_of_children_idx(self):
def get_dict_parent_connections(self):
"""
Return dictionary with parent connection point for all sections.
Returns
-------
connection_dict : dictionary
Expand All @@ -2330,6 +2342,7 @@ def _parent_and_segment_current(self, seg_idx, parent_idx, bottom_seg,
"""
Return axial current from segment (seg_idx) mid to segment start,
and current from parent segment (parent_idx) end to parent segment mid.
Parameters
----------
seg_idx : int
Expand Down
16 changes: 8 additions & 8 deletions LFPy/test/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def test_cell_get_axial_currents_from_vmem_14(self):
dend1.connect(soma(1), 0)
dend2.connect(soma(1), 0)
morphology = neuron.h.SectionList()
morphology.wholetree()
morphology.wholetree(sec=soma)
cell = cell_w_synapse_from_sections(morphology)
iaxial, d_list, pos_list = cell.get_axial_currents_from_vmem()
new_x = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
Expand All @@ -925,7 +925,7 @@ def test_cell_get_axial_currents_from_vmem_14(self):
cell._collect_geometry()
cell2 = cell_w_synapse_from_sections(morphology)
iaxial2, d_list2, pos_list2 = cell2.get_axial_currents_from_vmem()
mid_current_positions = np.array([[0., 0., 5], [0., 0., 12.5], [0., 0., 5.], [0., 0., 20.]])
mid_current_positions = np.array([[0., 0., 5], [0., 0., 20], [0., 0., 5.], [0., 0., 12.5]])
np.testing.assert_almost_equal(mid_current_positions, pos_list2, decimal=9)
np.testing.assert_allclose(mid_current_positions, pos_list2, rtol=1E-4)

Expand All @@ -942,7 +942,7 @@ def test_cell_get_axial_currents_from_vmem_15(self):
dend2.connect(dend1(1.), 0)
dend3.connect(dend1(.5), 0)
morphology = neuron.h.SectionList()
morphology.wholetree()
morphology.wholetree(sec=soma)
cell = cell_w_synapse_from_sections(morphology)
iaxial1, d_list1, pos_list1 = cell.get_axial_currents_from_vmem()
new_x = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 5, 10]]
Expand All @@ -961,8 +961,8 @@ def test_cell_get_axial_currents_from_vmem_15(self):
cell2 = cell_w_synapse_from_sections(morphology)
iaxial2, d_list2, pos_list2 = cell2.get_axial_currents_from_vmem()
mid_current_positions = np.array([[0., 0., 5.], [0., 0., 12.5],
[0., 0., 17.5], [0., 0., 25],
[0., 0., 15.],[2.5, 0., 15.]])
[0., 0., 15.], [2.5, 0., 15.],
[0., 0., 17.5], [0, 0., 25.]])
np.testing.assert_almost_equal(mid_current_positions, pos_list2, decimal=9)
np.testing.assert_allclose(mid_current_positions, pos_list2, rtol=1E-4)

Expand Down Expand Up @@ -991,7 +991,7 @@ def test_cell_simulate_recorder_00(self):
self.assertTrue(np.all(stick.vmem == stick.v_init))
self.assertTrue(np.all(stick.imem == 0.))
self.assertTrue(np.all(stick.current_dipole_moment == 0.))


def test_cell_simulate_recorder_01(self):
stickParams = {
Expand Down Expand Up @@ -1068,7 +1068,7 @@ def test_cell_simulate_recorder_03(self):
self.assertTrue(np.all(stick.vmem == stick.v_init))
self.assertTrue(np.all(stick.imem == 0.))
self.assertTrue(np.all(stick.current_dipole_moment == 0.))


def test_cell_simulate_recorder_04(self):
stickParams = {
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def test_cell_with_recextelectrode_02(self):
self.assertTrue(stick.tvec.size == stick.imem.shape[1] ==
electrode.LFP.shape[1] == electrode1.LFP.shape[1] ==
int(stick.tstop/stick.dt)+1)

def test_cell_with_recextelectrode_03(self):
stickParams = {
'morphology' : os.path.join(LFPy.__path__[0], 'test', 'stick.hoc'),
Expand Down
29 changes: 9 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MEG scalp surface magnetic fields, as described in the bioRXiv preprint "Multimo

Citing LFPy:

- LFPy v2.x: Hagen E, Naess S, Ness TV and Einevoll GT (2018). Multimodal modeling of neural network activity: computing LFP, ECoG, EEG and MEG signals with LFPy2.0. bioRXiv. doi: 10.1101/281717
- LFPy v2.x: Hagen E, Næss S, Ness TV and Einevoll GT (2018) Multimodal Modeling of Neural Network Activity: Computing LFP, ECoG, EEG, and MEG Signals With LFPy 2.0. Front. Neuroinform. 12:92. doi: 10.3389/fninf.2018.00092
- LFPy v1.x: Linden H, Hagen E, Leski S, Norheim ES, Pettersen KH and Einevoll GT (2013). LFPy: A tool for biophysical simulation of extracellular potentials generated by detailed model neurons. Front. Neuroinform. 7:41. doi: 10.3389/fninf.2013.00041

LFPy was developed in the Computational Neuroscience Group, Department of Mathemathical Sciences and Technology (http://www.nmbu.no/imt),
Expand All @@ -47,11 +47,11 @@ Requirements

To install LFPy you will need the following:

- Python modules numpy, scipy and matplotlib
- NEURON (from http://www.neuron.yale.edu) compiled as a Python module, so the following should execute without error in Python console::
- Python modules numpy, scipy, matplotlib, h5py, mpi4py, csa, Cython
- NEURON (from http://www.neuron.yale.edu, v7.6.4 or newer) and corresponding Python module. The following should execute without error in a Python console:

import neuron
neuron.test()
import neuron
neuron.test()

- Cython (C-extensions for python, http://cython.org) to speed up simulations of extracellular fields

Expand All @@ -61,46 +61,38 @@ Installation

There are few options to install LFPy:

1. From the Python Package Index with only local access using pip
::
1. From the Python Package Index with only local access using pip:

pip install LFPy --user

as sudoer (in general not recommended as system Python files may be overwritten):
::

sudo pip install LFPy

Upgrading LFPy from the Python package index (without attempts at upgrading dependencies):
::

pip install --upgrade --no-deps LFPy --user

LFPy release candidates can be installed as
::
LFPy release candidates can be installed as:

pip install --pre --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple LFPy --user


2. From the Python Package Index with only local access using easy_install
::
2. From the Python Package Index with only local access using easy_install:

easy_install --user LFPy

as sudoer:
::
As sudoer:

sudo easy_install LFPy

3. From source:
::

tar -xzf LFPy-x.x.tar.gz
cd LFPy-x.x
(sudo) python setup.py develop (--user)

4. Development version from the GitHub repository:
::

git clone https://github.com/LFPy/LFPy.git
cd LFPy
Expand All @@ -112,7 +104,6 @@ Uninstall
=========

To remove installed LFPy files it should suffice to issue (repeat until no more LFPy files are found):
::

(sudo) pip uninstall LFPy

Expand All @@ -121,12 +112,10 @@ Documentation
=============

To generate the html documentation using Sphinx, issue from the LFPy source code directory:
::

sphinx-build -b html <path to LFPy>/doc <path to output>

The main html file is in ``<path to output>/index.html``. Numpydoc and the ReadTheDocs theme may be needed:
::

pip install numpydoc --user
pip install sphinx-rtd-theme --user
Expand Down
8 changes: 4 additions & 4 deletions continuous_integration/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
export PATH=$HOME/.local/nrn/x86_64/bin:$PATH

cd $HOME
wget https://neuron.yale.edu/ftp/neuron/versions/v7.5/nrn-7.5.tar.gz
tar -xf nrn-7.5.tar.gz
cd nrn-7.5
wget https://github.com/neuronsimulator/nrn/archive/master.tar.gz
tar -xf master.tar.gz
cd nrn-master
echo "installing NEURON:"
echo "running sh build.sh"
sh build.sh > /dev/null
echo "running ./configure"
./configure --prefix=$HOME/.local/nrn --without-iv --with-nrnpython --with-mpi > /dev/null
./configure --prefix=$HOME/.local/nrn --without-iv --with-nrnpython=python --with-mpi > /dev/null
echo "running make"
make > /dev/null
echo "running make install"
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# The short X.Y version.
version = '2.0'
# The full version, including alpha/beta/rc tags.
release = '2.0.0'
release = '2.0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down

0 comments on commit 2e0db05

Please sign in to comment.