Skip to main content

NeuRon Virtualizer (NRV)

Project description

PyPI version Documentation Status License: CeCill DOI Binder

NRV

NRV

Python library for Peripheral Nervous System stimulation modeling

NRV (or NeuRon Virtualizer) is a pythonic framework to enable fast and user friendly simulations of the Peripheral Nervous System. Axons models are simulated with the NEURON software, and extracellular fields are computed either from analytic equations such as point source approximation or with a more detailed description of the nerve and electrode geometry and Finite Elements Method, either using COMSOL (additional commercial licence requiered) or the FENICS project. All computations are performed with the quasistatic approximation of the Maxwell equations, no ephaptic coupling. Stimulation waveform can be of random shapes, and any kinds of electrode can be combined to model complex stimulation strategies.

NRV has been optimized for large population of axons, from generating correct population following a specific diameter repartition, through automatic placement to computation and post-processing of the axons activity when a stimulus is applied. Parallel computation, interface with NEURON and COMSOL and FENICS is automatically handled by NRV. For a detailed description and full help on installation, basic usage and API documentation, please visit ou NRV readthedocs page.

NRV has been developped by contributors from the CELL research group at the Laboratory ETIS (UMR CNRS 8051), ENSEA - CY Cergy Paris University, until June 2023 and is now developped and maintained by the Bioelectronics group of laboratory IMS (UMR CNRS 5218), INP Bordeaux, U. Bordeaux.

📚 Full Documentation available here: https://nrv.readthedocs.io/en/latest/

📄 Citation

If you use NRV in your research, please cite the following paper:

Couppey, T., Regnacq, L., Giraud, R., Romain, O., Bornat, Y., & Kolbl, F. (2024). NRV: An open framework for in silico evaluation of peripheral nerve electrical stimulation strategies. PLOS Computational Biology, 20(7), e1011826.

https://doi.org/10.1371/journal.pcbi.1011826

BibTeX

@article{couppey2024nrv,
  title={NRV: An open framework for in silico evaluation of peripheral nerve electrical stimulation strategies},
  author={Couppey, Thomas and Regnacq, Louis and Giraud, Roland and Romain, Olivier and Bornat, Yannick and Kolbl, Florian},
  journal={PLOS Computational Biology},
  volume={20},
  number={7},
  pages={e1011826},
  year={2024},
  publisher={Public Library of Science San Francisco, CA USA}
}

Installation

NRV is pip installable and the whole installation process should be quite simple. However, to prevent third-party package version conflicts we recommend creating a dedicated conda environment:

conda create -n nrv-env -c anaconda python=3.12

💡 Tip: You can also use Mamba to speed up the installation. Once Mamba is installed, the installation command line is almost identical:

mamba create -n nrv-env -c anaconda python=3.12

And activate it before any installation with the command:

conda activate nrv-env

⚠️ Warning for macOS users (June 2025):
There are known compatibility issues between Xcode versions higher than 16.2 and the FEM solver used in this project.
If you encounter problems running simulations involving FEM, please downgrade Xcode to version 16.2 to ensure stability and correct functionality.

Open-source Dependencies

The pip installation takes care of most of the open source third-party dependencies, but the FEM solver (FenicsX) and the Message Passing Interface (MPICH)
are conda-installable only. We also recommend installing gmsh and ipython from conda:

conda install -c conda-forge fenics-dolfinx==0.9.0 mpich python-gmsh ipykernel

⚠️ Warning for Linux users: The default blas library used in FenicsX may not be compatible with the preconditioner used in NRV, which may result in additional CPU overhead during electric field computation. To avoid this, it is advised to force the installation as below:

conda install -c conda-forge fenics-dolfinx "libblas=*=*blis"

💡 Tip: With Mamba, the command is:

mamba install -c conda-forge fenics-dolfinx==0.9.0 mpich python-gmsh ipykernel

COMSOL Installation

NRV can perform FEM computations with COMSOL. However, the end user must provide a valid commercial installed license by themselves. COMSOL installation can be performed before or after NRV's installation.

For using COMSOL, information about the installation must be specified in the nrv/_misc code folder by filling the following fields in the NRV.ini file:

[COMSOL]
COMSOL_STATUS = True
COMSOL_SERVER = PATH_TO_COMSOL_SERVER_BINARIES
COMSOL_CPU = 1
COMSOL_PORT = 2036
TIME_COMSOL_SERVER_LAUNCH = 10

Especially, the correct path to the COMSOL server binaries has to be specified, and the port must be adapted if changed from default values.

The use of FenicsX for FEM computations has been extensively tested by NRV's contributors, and we do not recommend using COMSOL with NRV as new geometries or electrodes won't be implemented with COMSOL. Also, the use of commercial licenses limits reproducibility and open-science possibilities.

Installing NRV

Using pip NRV can simply be installed with pip (nrv-py):

pip install nrv-py

If you want the very last development version under development, please consider:

pip install git+https://github.com/fkolbl/NRV.git

If you already installed a previous version and want to upgrade to the very last development version, please use:

pip install --upgrade --force-reinstall --ignore-installed git+https://github.com/fkolbl/NRV.git

You should now be able to import nrv in your Python shell:

import nrv

Be aware that on the first import of NRV, some files related to simulation of ion channels are automatically compiled by NEURON. You may see compilation results (including warnings, but no errors) in your prompt.

Using Docker

This method should be preferred as all dependencies are already set up. Note that in this configuration, COMSOL cannot be used.

Assuming Docker is already installed, the first step is to pull the image:

docker pull nrvframework/nrv

You can then create a new container using:

docker run --rm -it nrvframework/nrv

where the --rm argument deletes the container once finished, and -it gives the interactive console.

A second image is available to use NRV in Jupyter notebooks:

docker pull nrvframework/lab

You can then create a container using:

docker run --rm -p 8888:8888 nrvframework/lab

Where the -p 8888:8888 maps the port to the localhost. This should give you a link and token to load Jupyter from your browser.

NRV on Windows

NRV is not directly installable on Windows due to some FenicsX dependencies not available on Windows. However, one can easily overcome this problem by using WSL2.

💡 Tip: A full support of FenicsX on windows is planned!

Assuming a blank installation of WSL2 (Ubuntu 22.xx), the following instructions are required to install and use NRV.

Installation of micromamba (a lighter and faster conda equivalent):

"${SHELL}" <(curl -L micro.mamba.pm/install.sh)

Creation of the environment:

micromamba create -n nrv-env -c anaconda python=3.12

Sudo update and installation of the required libraries:

sudo apt-get update -y
sudo apt-get install build-essential libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev libxrender1 libxcursor1 libxft2 libxinerama1 make libx11-dev git bison flex automake libtool libxext-dev libncurses-dev xfonts-100dpi cython3 libopenmpi-dev zlib1g-dev

Activating the environment and installing the required packages:

micromamba activate nrv-env
micromamba install -c conda-forge fenics-dolfinx==0.9.0 sysroot_linux-64=2.17 mpg mpich python-gmsh ipykernel

Finally, pip-install NRV:

pip install nrv-py

The WSL2 terminal must be rebooted before using NRV.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nrv_py-1.2.1.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

nrv_py-1.2.1-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

Details for the file nrv_py-1.2.1.tar.gz.

File metadata

  • Download URL: nrv_py-1.2.1.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nrv_py-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a19fd7e4799ae01b860f4e93980f7d7639a93b02f24711a799553222657bb2bb
MD5 2a5f9daceb74180309f15d9bc18f3582
BLAKE2b-256 131643bc719626412aed5d1c9a877221e90359ca31875ae3d2c5d2d27fdd592c

See more details on using hashes here.

File details

Details for the file nrv_py-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: nrv_py-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nrv_py-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d2b4a6c179b8dfaad30e8be1e44c344ccd44733dd5e49f8cab58ea5d0d2f3a4
MD5 51a0118da353a38bb2472c6da0a80c7f
BLAKE2b-256 11d0ec80c2c3ba4df8c9690344deb7ef0c1ebb58645e663e8874a5a005e52206

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page