lfpy

Python-module for calculation of extracellular potentials from multicompartment neuron models and networks

https://github.com/lfpy/lfpy

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 29 DOI reference(s) in README
  • Academic publication links
    Links to: frontiersin.org, zenodo.org
  • Committers with academic emails
    3 of 20 committers (15.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.7%) to scientific vocabulary
Last synced: 6 months ago · JSON representation

Repository

Python-module for calculation of extracellular potentials from multicompartment neuron models and networks

Basic Info
  • Host: GitHub
  • Owner: LFPy
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage: https://LFPy.rtfd.io
  • Size: 16.6 MB
Statistics
  • Stars: 79
  • Watchers: 6
  • Forks: 46
  • Open Issues: 12
  • Releases: 35
Created over 13 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing License Citation

README.md

LFPy

Summary

LFPy is a Python module for calculation of extracellular potentials from multicompartment neuron models. It relies on the NEURON simulator (http://www.neuron.yale.edu/neuron) and uses the Python interface (http://www.frontiersin.org/neuroinformatics/10.3389/neuro.11.001.2009/abstract) it provides.

Latest changes

Just updated LFPy? Please check the latest release notes: https://github.com/LFPy/LFPy/releases

Usage

A brief video tutorial on LFPy is available here: https://youtu.be/gCQkyTHZ1lw

LFPy is preinstalled at the EBRAINS collaboratory, and you can test LFPy online without installation, by clicking this button:

Note that you might need to be logged into an EBRAINS account for the link to work. To get a free EBRAINS account, sign up here: https://www.ebrains.eu/page/sign-up

A basic simulation of extracellular potentials of a multicompartment neuron model set up with LFPy:

>>> # import modules
>>> import LFPy
>>> from LFPy import Cell, Synapse, LineSourcePotential
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> # create Cell
>>> cell = Cell(morphology=''.join(LFPy.__path__ +
>>>                                ['/test/ball_and_sticks.hoc']),
>>>             passive=True,  # NEURON 'pas' mechanism
>>>             tstop=100,  # ms
>>>            )
>>> # create Synapse
>>> synapse = Synapse(cell=cell,
>>>                   idx=cell.get_idx("soma[0]"),  # soma segment index
>>>                   syntype='Exp2Syn',  # two-exponential synapse
>>>                   weight=0.005,  # max conductance (uS)
>>>                   e=0,  # reversal potential (mV)
>>>                   tau1=0.5,  # rise time constant
>>>                   tau2=5.,  # decay time constant
>>>                   record_current=True,  # record synapse current
>>>                  )
>>> synapse.set_spike_times(np.array([20., 40]))  # set activation times
>>> # create extracellular predictor
>>> lsp = LineSourcePotential(cell=cell,
>>>                           x=np.zeros(11) + 10,  # x-coordinates of contacts (m)
>>>                           y=np.zeros(11),  # y-coordinates
>>>                           z=np.arange(11)*20,  # z-coordinates
>>>                           sigma=0.3,  # extracellular conductivity (S/m)
>>>                          )
>>> # execute simulation
>>> cell.simulate(probes=[lsp])  # compute measurements at run time
>>> # plot results
>>> fig, axes = plt.subplots(3, 1, sharex=True, figsize=(12, 8))
>>> axes[0].plot(cell.tvec, synapse.i)
>>> axes[0].set_ylabel('i_syn (nA)')
>>> axes[1].plot(cell.tvec, cell.somav)
>>> axes[1].set_ylabel('V_soma (nA)')
>>> axes[2].pcolormesh(cell.tvec, lsp.z, lsp.data, shading='auto')
>>> axes[2].set_ylabel('z (m)')
>>> axes[2].set_xlabel('t (ms)')

Code status

PyPI version flake8 lint Python application Coverage Status Documentation Status Binder DOI

Conda-forge status

Conda Recipe Conda Downloads Conda Version Conda Platforms

Information

LFPy provides a set of easy-to-use Python classes for setting up your model, running your simulations and calculating the extracellular potentials arising from activity in your model neuron. If you have a model working in NEURON (www.neuron.yale.edu) already, it is likely that it can be adapted to work with LFPy.

The extracellular potentials are calculated from transmembrane currents in multicompartment neuron models using the line-source method (Holt & Koch, J Comp Neurosci 1999), but a simpler point-source method is also available. The calculations assume that the neuron are surrounded by an infinite extracellular medium with homogeneous and frequency independent conductivity, and compartments are assumed to be at least at a minimal distance from the electrode (which can be specified by the user). For more information on the biophysics underlying the numerical framework used see this coming book chapter:

The first release of LFPy (v1.x) was mainly designed for simulation extracellular potentials of single neurons, described in our paper on the package in Frontiers in Neuroinformatics entitled "LFPy: A tool for biophysical simulation of extracellular potentials generated by detailed model neurons". The article can be found at https://dx.doi.org/10.3389/fninf.2013.00041. Since version 2 (LFPy v2.x), the tool also facilitates simulations of extracellular potentials and current dipole moment from ongoing activity in recurrently connected networks of multicompartment neurons, prediction of EEG scalp surface potentials, MEG scalp surface magnetic fields, as described in the publication "Multimodal modeling of neural network activity: computing LFP, ECoG, EEG and MEG signals with LFPy2.0" by Espen Hagen, Solveig Naess, Torbjoern V Ness, Gaute T Einevoll, found at https://dx.doi.org/10.3389/fninf.2018.00092.

Citing LFPy

  • LFPy v2.x: Hagen E, Nss 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. https://dx.doi.org/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. https://dx.doi.org/10.3389/fninf.2013.00041

LFPy was developed in the Computational Neuroscience Group, Department of Mathemathical Sciences and Technology (http://www.nmbu.no/imt), at the Norwegian University of Life Sciences (http://www.nmbu.no), in collaboration with the Laboratory of Neuroinformatics (http://www.nencki.gov.pl/en/laboratory-of-neuroinformatics), Nencki Institute of Experimental Biology (http://www.nencki.gov.pl), Warsaw, Poland. The effort was supported by International Neuroinformatics Coordinating Facility (http://incf.org), the Research Council of Norway (http://www.forskningsradet.no/english) (eScience, NevroNor), EU-FP7 (BrainScaleS, http://www.brainscales.org), the European Union Horizon 2020 Framework Programme for Research and Innovation under Specific Grant Agreement No. 785907 and No. 945539 [Human Brain Project (HBP) SGA2, SGA3 and EBRAINS].

For updated information on LFPy and online documentation, see the LFPy homepage (http://lfpy.readthedocs.io).

Tutorial slides on LFPy

Related projects

LFPy has been used extensively in ongoing and published work, and may be a required dependency by the publicly available Python modules:

Requirements

Dependencies should normally be automatically installed. For manual preinstallation of dependencies, the following packages are needed:

Installation

There are few options to install LFPy:

  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:

    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:

    easy_install --user LFPy
    

    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
    (sudo) pip install -r requirements.txt (--user) # install dependencies
    (sudo) python setup.py develop (--user)
    
  5. Anaconda Python (https://www.anaconda.com, macos/linux only):

    Add the conda-forge (https://conda-forge.org) as channel:

    conda config --add channels conda-forge
    conda config --set channel_priority strict  # suggested
    

    Create a new conda environment with LFPy and activate it:

    conda create -n lfpy python=3 pip lfpy  # creates new Python 3.x conda environment named lfpy with pip and LFPy and their dependencies
    conda activate lfpy  # activate the lfpy environment
    python -c "import LFPy; LFPy.run_tests()"  # check that installation is working
    

    LFPy can also be installed in existing conda environments if the dependency tree is solvable:

    conda activate <environment>
    conda install lfpy  # installs LFPy and its dependencies in the current conda environment
    

Uninstall

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

(sudo) pip uninstall LFPy

In case LFPy was installed using conda in an environment, it can be uninstalled by issuing:

conda uninstall lfpy

Docker

We provide a Docker (https://www.docker.com) container recipe file with LFPy. To get started, install Docker and issue either:

# build Dockerfile from GitHub
$ docker build -t lfpy https://raw.githubusercontent.com/LFPy/LFPy/master/Dockerfile
$ docker run -it -p 5000:5000 lfpy:latest

or

# build local Dockerfile (obtained by cloning repo, checkout branch etc.)
$ docker build -t lfpy - < Dockerfile
$ docker run -it -p 5000:5000 lfpy:latest

If the docker file should fail for some reason it is possible to store the build log and avoid build caches by issuing

docker build --no-cache --progress=plain -t lfpy - < Dockerfile 2>&1 | tee lfpy.log

If the build is successful, the --mount option can be used to mount a folder on the host to a target folder as:

docker run --mount type=bind,source="$(pwd)",target=/opt -it -p 5000:5000 lfpy

which mounts the present working dirctory ($(pwd)) to the /opt directory of the container. Try mounting the LFPy source directory for example (by setting source="<path-to-LFPy>"). Various LFPy example files can then be found in the folder /opt/LFPy/examples/ when the container is running.

Jupyter notebook servers running from within the container can be accessed after invoking them by issuing:

cd /opt/LFPy/examples/
jupyter-notebook --ip 0.0.0.0 --port=5000 --no-browser --allow-root

and opening the resulting URL in a browser on the host computer, similar to: http://127.0.0.1:5000/?token=dcf8f859f859740fc858c568bdd5b015e0cf15bfc2c5b0c1

HTML Documentation

To generate the html documentation also hosted at https://lfpy.rtfd.io using Sphinx, issue from the LFPy source code directory:

cd doc
make html

The main html file is in _build/html/index.html. m2r2, Numpydoc and the Sphinx ReadTheDocs theme may be needed:

pip install m2r2 --user
pip install numpydoc --user
pip install sphinx-rtd-theme --user

Physical units in LFPy

Physical units follow the NEURON conventions found here. The units in LFPy for given quantities are:

| Quantity | Symbol | Unit | |----------------------------|-----------|-----------| | Spatial dimensions | x,y,z,d | [m] | | Potential | v, Phi, | [mV] | | Reversal potential | E | [mV] | | Current | i | [nA] | | Membrane capacitance | c_m | [F/cm2] | | Conductance | g | [S/cm2] | | Synaptic conductance | g | [S] | | Extracellular conductivity | sigma, | [S/m] | | Current dipole moment | P | [nA m] | | Magnetic field | H | [nA/m] | | Magnetic permeability | , mu | [T m/A] | | Current Source Density | CSD | [nA/m3] |

Note: resistance, conductance and capacitance are usually specific values, i.e per membrane area (lowercase rm, g, cm) Depending on the mechanism files, some may use different units altogether, but this should be taken care of internally by NEURON.

Owner

  • Name: LFPy
  • Login: LFPy
  • Kind: organization

Local Field Potentials in Python

GitHub Events

Total
  • Create event: 6
  • Release event: 5
  • Issues event: 8
  • Watch event: 8
  • Issue comment event: 14
  • Push event: 3
  • Pull request review event: 2
  • Pull request event: 4
  • Fork event: 1
Last Year
  • Create event: 6
  • Release event: 5
  • Issues event: 8
  • Watch event: 8
  • Issue comment event: 14
  • Push event: 3
  • Pull request review event: 2
  • Pull request event: 4
  • Fork event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 740
  • Total Committers: 20
  • Avg Commits per committer: 37.0
  • Development Distribution Score (DDS): 0.727
Past Year
  • Commits: 9
  • Committers: 1
  • Avg Commits per committer: 9.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
ehagen e****n@g****m 202
Espen Hagen 2****n@u****m 184
ehagen e****n@u****m 176
Espen Hagen e****n@f****e 59
Torbjørn Vefferstad Ness t****s@g****m 30
Henrik Lindén h****n@u****m 22
Espen Hagen e****e@f****o 17
Alessio Buccino a****7@g****m 12
solveignaess s****s@u****m 11
enorhe n****d@g****m 10
Henrik Lindén h****n@s****k 4
Svenn-Arne Dragly s@d****m 3
Solveig s****s@g****m 2
Robin De Schepper r****3@g****m 2
Loïc Bertrand l****d@t****u 1
szleski s****i@g****m 1
AlexStasik 3****k@u****m 1
Min RK b****k@g****m 1
szleski s****i@2****2 1
Alexis Mélot a****t@u****a 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 69
  • Total pull requests: 51
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 days
  • Total issue authors: 13
  • Total pull request authors: 5
  • Average comments per issue: 1.59
  • Average comments per pull request: 1.37
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 2
  • Average time to close issues: about 23 hours
  • Average time to close pull requests: 3 days
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 0.33
  • Average comments per pull request: 1.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • espenhgn (55)
  • acyang (2)
  • Alexis-Melot (2)
  • alejoe91 (2)
  • torbjone (2)
  • arashgmn (1)
  • sanjayankur31 (1)
  • somogyvari (1)
  • darshanmandge (1)
  • Vince0226 (1)
  • ziadaali (1)
  • DavidALloyd (1)
Pull Request Authors
  • espenhgn (41)
  • torbjone (7)
  • alejoe91 (1)
  • darshanmandge (1)
  • Alexis-Melot (1)
Top Labels
Issue Labels
enhancement (29) bug (16) no-issue-activity (15) Installation (6) release (4) proposal (3) feature (2) documentation (2) LFPykit (1)
Pull Request Labels
enhancement (26) bugfix (10) feature (4) Installation (4) documentation (3) release (1) LFPykit (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 2,913 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 3
    (may contain duplicates)
  • Total versions: 54
  • Total maintainers: 1
pypi.org: lfpy

A module for modeling extracellular potentials of multicompartment neuron models built on NEURON

  • Versions: 40
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 2,913 Last month
Rankings
Dependent packages count: 10.0%
Average: 10.9%
Downloads: 11.0%
Dependent repos count: 11.6%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: lfpy

LFPy provides a set of easy-to-use Python classes for setting up your model, running your simulations and calculating the extracellular potentials arising from activity in your model neuron. If you have a model working in NEURON or NeuroML2 already, it is likely that it can be adapted to work with LFPy.

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Dependent repos count: 24.4%
Forks count: 27.6%
Average: 35.4%
Stargazers count: 38.1%
Dependent packages count: 51.6%
Last synced: 7 months ago

Dependencies

doc/environment.yml conda
  • c-compiler
  • cxx-compiler
  • m2r2
  • mpi4py
  • numpy
  • numpydoc
  • pip
  • pthread-stubs
  • python 3.8.*
  • sphinx_rtd_theme
doc/requirements.txt pypi
  • numpy >=1.8.2
  • numpydoc *
  • sphinx *
requirements.txt pypi
  • Cython >=0.20
  • h5py >=2.5
  • lfpykit master
  • matplotlib >=2.0
  • mpi4py >=1.2
  • neuron >=7.7.2
  • numpy >=1.8
  • scipy >=0.14
  • setuptools >=23.1.0
setup.py pypi
  • Cython >=0.20
  • h5py >=2.5
  • lfpykit *
  • mpi4py >=1.2
  • neuron >=7.7.2
  • numpy >=1.8
  • scipy >=0.14
.github/workflows/docker.yaml actions
  • actions/checkout v1 composite
  • reviewdog/action-hadolint v1 composite
.github/workflows/flake8.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • reviewdog/action-flake8 v3 composite
.github/workflows/greetings.yml actions
  • actions/first-interaction v1 composite
.github/workflows/python-app.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/pythonpublish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/stale.yml actions
  • actions/stale v3 composite
Dockerfile docker
  • buildpack-deps jammy build