Skip to main content

Quality of life patch for the NEURON simulator.

Project description

Build Status Documentation Status Ruff codecov

Drop in replacement

*No ducks were punched during the construction of this monkey patch.

Installation

pip install nrn-patch

Minimal requirements

  • Python 3.8+
  • NEURON 9.0+

Philosophy

Pythonic reinvention of the NEURON Python interface:

  • Drop-in replacement: No breaking changes between Patch and NEURON. All your code works as is. Patch automagically fixes bugs and reduces complexity in NEURON by having an opinion, and adds new convenient methods.
  • Loud errors: silent failures and gotchas are caught and raise loud errors; so that when it runs, it runs.
  • Strong referencing: Objects connected to each other will never disappear until you disconnect them.
  • Demystified: The simplest form of each instruction does the most obvious thing. Patch frequently replaces 5 or more undocumented mystical voodoo steps by 1 clearly named function.
  • Just add water: Serial or parallel, doesn't matter, p.run() will run your simulation with no extra steps. No load_file, finitialize, fadvance, run, continuerun, tstop, set_maxstep, setup_transfer, setgid2node, gid_connect, cell, outputcell, psolve required.

Basic usage

Use it like you would use NEURON. The wrapper doesn't make any changes to the interface, it just patches up some of the more frequent and ridiculous gotchas.

Patch supplies a new interpreter p, the PythonHocInterpreter which wraps the standard HOC interpreter h provided by NEURON. Any objects returned will either be PythonHocObject's wrapping their corresponding NEURON object, or whatever NEURON returns.

When using just Patch the difference between NEURON and Patch objects is handled transparently, but if you wish to mix interpreters you can transform all Patch objects back to NEURON objects with obj.__neuron__(), or the transform function.

Example

from patch import p
import glia as g

section = p.Section()
point_process = g.insert(section, "AMPA")
point_process.stimulate(start=10, number=5, interval=10, weight=0.04)

.stimulate creates both the NetCon and NetStim, and sets their properties, and stores references to eachother so that Python doesn't garbage collect anything until we're done with it.

Even when you forget to set values, the Patch defaults have a visible effect. Here we forget to set the duration of a voltage clamp, but by default it will be active the first 100ms of the simulation, so that you can see that the voltage clamp is in fact inserted and working, but you forgot to set the duration:

section.vclamp(holding=-70, voltage=20)

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

nrn_patch-7.2.3.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nrn_patch-7.2.3-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file nrn_patch-7.2.3.tar.gz.

File metadata

  • Download URL: nrn_patch-7.2.3.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nrn_patch-7.2.3.tar.gz
Algorithm Hash digest
SHA256 a614ddec376dc1eef7606895b41f17d5e9a6bedf4ba1e4c9eaaae8fab05bab29
MD5 1150981f21c1d63b695d79fa997bca7a
BLAKE2b-256 0e2c631cd21259d9e5c652ef450e5ae753c378585e461ec727df69b6183265ed

See more details on using hashes here.

File details

Details for the file nrn_patch-7.2.3-py3-none-any.whl.

File metadata

  • Download URL: nrn_patch-7.2.3-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nrn_patch-7.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9dff616d31166e84aea512257c0697c58685222f4aec592990502c7cbef284c0
MD5 76a12180f8a53a0777873095d6482371
BLAKE2b-256 b262a16aee4303bd582479359ec1c5dfa5c92cd55d6ef8265b15d7fb5f2c70ac

See more details on using hashes here.

Supported by

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