hnn-core 0.4.2.dev1__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. hnn_core-0.4.3/PKG-INFO +217 -0
  2. hnn_core-0.4.3/README.md +118 -0
  3. hnn_core-0.4.3/examples/howto/plot_replaying_spike_data_as_input.py +174 -0
  4. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/plot_simulate_beta.py +6 -6
  5. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/plot_simulate_evoked.py +1 -1
  6. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/plot_simulate_gamma.py +1 -1
  7. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/__init__.py +7 -1
  8. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/cells_default.py +4 -4
  9. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/dipole.py +2 -1
  10. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/drives.py +44 -12
  11. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/gui/gui.py +11 -7
  12. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/hnn_io.py +96 -11
  13. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/network.py +479 -83
  14. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/network_builder.py +52 -18
  15. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/network_models.py +91 -12
  16. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/optimization/optimize_evoked.py +6 -1
  17. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/parallel_backends.py +7 -7
  18. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/param/jones2009_base.json +1244 -1170
  19. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/regenerate_test_network.py +22 -3
  20. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_cell.py +2 -2
  21. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_cells_default.py +26 -3
  22. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_dipole.py +28 -0
  23. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_io.py +50 -2
  24. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_network.py +456 -13
  25. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_optimize_evoked.py +1 -1
  26. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_viz.py +13 -12
  27. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/viz.py +2 -2
  28. hnn_core-0.4.3/hnn_core.egg-info/PKG-INFO +217 -0
  29. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core.egg-info/SOURCES.txt +1 -0
  30. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core.egg-info/requires.txt +1 -1
  31. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/pyproject.toml +3 -3
  32. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/setup.py +8 -3
  33. hnn_core-0.4.2.dev1/PKG-INFO +0 -215
  34. hnn_core-0.4.2.dev1/README.md +0 -121
  35. hnn_core-0.4.2.dev1/hnn_core.egg-info/PKG-INFO +0 -215
  36. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/LICENSE +0 -0
  37. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/MANIFEST.in +0 -0
  38. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/README.txt +0 -0
  39. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/README.txt +0 -0
  40. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/optimize_evoked.py +0 -0
  41. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/optimize_rhythmic.py +0 -0
  42. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_batch_simulate.py +0 -0
  43. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_connectivity.py +0 -0
  44. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_firing_pattern.py +0 -0
  45. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_hnn_animation.py +0 -0
  46. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_record_extracellular_potentials.py +0 -0
  47. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/howto/plot_simulate_mpi_backend.py +0 -0
  48. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/README.txt +0 -0
  49. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/plot_simulate_alpha.py +0 -0
  50. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/examples/workflows/plot_simulate_somato.py +0 -0
  51. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/batch_simulate.py +0 -0
  52. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/cell.py +0 -0
  53. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/cell_response.py +0 -0
  54. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/check.py +0 -0
  55. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/docs.py +0 -0
  56. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/externals/__init__.py +0 -0
  57. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/externals/bayesopt.py +0 -0
  58. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/externals/mne.py +0 -0
  59. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/extracellular.py +0 -0
  60. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/gui/__init__.py +0 -0
  61. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/gui/_logging.py +0 -0
  62. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/gui/_viz_manager.py +0 -0
  63. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/gui/hnn_widget.ipynb +0 -0
  64. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/ar.mod +0 -0
  65. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/ca.mod +0 -0
  66. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/cad.mod +0 -0
  67. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/cat.mod +0 -0
  68. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/dipole.mod +0 -0
  69. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/dipole_pp.mod +0 -0
  70. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/hh2.mod +0 -0
  71. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/kca.mod +0 -0
  72. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/km.mod +0 -0
  73. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mod/vecevent.mod +0 -0
  74. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/mpi_child.py +0 -0
  75. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/optimization/__init__.py +0 -0
  76. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/optimization/general_optimization.py +0 -0
  77. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/optimization/objective_functions.py +0 -0
  78. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/param/N20.json +0 -0
  79. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/param/default.json +0 -0
  80. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/param/gamma_L5weak_L2weak.json +0 -0
  81. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/params.py +0 -0
  82. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/params_default.py +0 -0
  83. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/conftest.py +0 -0
  84. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_batch_simulate.py +0 -0
  85. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_cell_response.py +0 -0
  86. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_drives.py +0 -0
  87. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_extracellular.py +0 -0
  88. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_general_optimization.py +0 -0
  89. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_gui.py +0 -0
  90. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_mpi_child.py +0 -0
  91. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_parallel_backends.py +0 -0
  92. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_params.py +0 -0
  93. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/tests/test_utils.py +0 -0
  94. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core/utils.py +0 -0
  95. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core.egg-info/dependency_links.txt +0 -0
  96. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core.egg-info/entry_points.txt +0 -0
  97. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/hnn_core.egg-info/top_level.txt +0 -0
  98. {hnn_core-0.4.2.dev1 → hnn_core-0.4.3}/setup.cfg +0 -0
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: hnn-core
3
+ Version: 0.4.3
4
+ Summary: Code for biophysical simulation of a cortical column using Neuron
5
+ Home-page:
6
+ Download-URL: http://github.com/jonescompneurolab/hnn-core
7
+ Maintainer: Mainak Jas
8
+ Maintainer-email: mainakjas@gmail.com
9
+ License: BSD (3-clause)
10
+ Platform: any
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Topic :: Software Development
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX
19
+ Classifier: Operating System :: Unix
20
+ Classifier: Operating System :: MacOS
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Requires-Python: >=3.9, <3.14
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: numpy>=1.14
30
+ Requires-Dist: NEURON<=8.2.7,>=7.7; platform_system != "Windows"
31
+ Requires-Dist: matplotlib>=3.5.3
32
+ Requires-Dist: scipy
33
+ Requires-Dist: h5io
34
+ Provides-Extra: opt
35
+ Requires-Dist: scikit-learn; extra == "opt"
36
+ Provides-Extra: parallel
37
+ Requires-Dist: joblib; extra == "parallel"
38
+ Requires-Dist: psutil; extra == "parallel"
39
+ Provides-Extra: test
40
+ Requires-Dist: codespell; extra == "test"
41
+ Requires-Dist: pytest; extra == "test"
42
+ Requires-Dist: pytest-cov; extra == "test"
43
+ Requires-Dist: pytest-xdist; extra == "test"
44
+ Requires-Dist: ruff; extra == "test"
45
+ Provides-Extra: docs
46
+ Requires-Dist: mne; extra == "docs"
47
+ Requires-Dist: myst-parser; extra == "docs"
48
+ Requires-Dist: nibabel; extra == "docs"
49
+ Requires-Dist: numpydoc; extra == "docs"
50
+ Requires-Dist: pillow; extra == "docs"
51
+ Requires-Dist: pooch; extra == "docs"
52
+ Requires-Dist: pydata-sphinx-theme; extra == "docs"
53
+ Requires-Dist: sphinx; extra == "docs"
54
+ Requires-Dist: sphinx-gallery; extra == "docs"
55
+ Requires-Dist: sphinx-copybutton; extra == "docs"
56
+ Requires-Dist: tdqm; extra == "docs"
57
+ Provides-Extra: gui
58
+ Requires-Dist: ipywidgets>=8.0.0; extra == "gui"
59
+ Requires-Dist: ipykernel; extra == "gui"
60
+ Requires-Dist: ipympl; extra == "gui"
61
+ Requires-Dist: voila; extra == "gui"
62
+ Provides-Extra: dev
63
+ Requires-Dist: scikit-learn; extra == "dev"
64
+ Requires-Dist: joblib; extra == "dev"
65
+ Requires-Dist: psutil; extra == "dev"
66
+ Requires-Dist: codespell; extra == "dev"
67
+ Requires-Dist: pytest; extra == "dev"
68
+ Requires-Dist: pytest-cov; extra == "dev"
69
+ Requires-Dist: pytest-xdist; extra == "dev"
70
+ Requires-Dist: ruff; extra == "dev"
71
+ Requires-Dist: mne; extra == "dev"
72
+ Requires-Dist: myst-parser; extra == "dev"
73
+ Requires-Dist: nibabel; extra == "dev"
74
+ Requires-Dist: numpydoc; extra == "dev"
75
+ Requires-Dist: pillow; extra == "dev"
76
+ Requires-Dist: pooch; extra == "dev"
77
+ Requires-Dist: pydata-sphinx-theme; extra == "dev"
78
+ Requires-Dist: sphinx; extra == "dev"
79
+ Requires-Dist: sphinx-gallery; extra == "dev"
80
+ Requires-Dist: sphinx-copybutton; extra == "dev"
81
+ Requires-Dist: tdqm; extra == "dev"
82
+ Requires-Dist: ipywidgets>=8.0.0; extra == "dev"
83
+ Requires-Dist: ipykernel; extra == "dev"
84
+ Requires-Dist: ipympl; extra == "dev"
85
+ Requires-Dist: voila; extra == "dev"
86
+ Dynamic: classifier
87
+ Dynamic: description
88
+ Dynamic: description-content-type
89
+ Dynamic: download-url
90
+ Dynamic: license
91
+ Dynamic: license-file
92
+ Dynamic: maintainer
93
+ Dynamic: maintainer-email
94
+ Dynamic: platform
95
+ Dynamic: provides-extra
96
+ Dynamic: requires-dist
97
+ Dynamic: requires-python
98
+ Dynamic: summary
99
+
100
+
101
+ <h1 align="center">
102
+ <img src="https://raw.githubusercontent.com/jonescompneurolab/jones-website/master/images/frontpage/logos/logo-hnn-medium.png" width="300">
103
+ </h1><br>
104
+
105
+ # hnn-core
106
+
107
+ [![tests](https://github.com/jonescompneurolab/hnn-core/actions/workflows/unix_unit_tests.yml/badge.svg?branch=master)](https://github.com/jonescompneurolab/hnn-core/actions/?query=branch:master+event:push)
108
+ [![CircleCI](https://circleci.com/gh/jonescompneurolab/hnn-core.svg?style=svg)](https://circleci.com/gh/jonescompneurolab/hnn-core)
109
+ [![Codecov](https://codecov.io/gh/jonescompneurolab/hnn-core/branch/master/graph/badge.svg)](https://codecov.io/gh/jonescompneurolab/hnn-core)
110
+ [![PyPI](https://img.shields.io/pypi/dm/hnn-core.svg?label=PyPI%20downloads)](https://pypi.org/project/hnn-core/)
111
+ [![Gitter](https://badges.gitter.im/jonescompneurolab/hnn_core.svg)](https://gitter.im/jonescompneurolab/hnn-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
112
+ [![JOSS](https://joss.theoj.org/papers/10.21105/joss.05848/status.svg)](https://doi.org/10.21105/joss.05848)
113
+
114
+ ![HNN-GUI](https://raw.githubusercontent.com/jonescompneurolab/hnn-core/acbcc4a598610dc3be5d4b0b7c59f98251ea7690/.github/images/hnn_gui.png)
115
+
116
+ # About
117
+
118
+ The [Human Neocortical Neurosolver (HNN)](https://hnn.brown.edu) is an open-source
119
+ neural modeling tool designed to help researchers/clinicians interpret human brain
120
+ imaging data. This repository, called **HNN-core**, houses the source code for HNN.
121
+
122
+ With only a few lines of code, HNN provides a convenient way to run simulations of an
123
+ anatomically- and biophysically-detailed dynamical system model of human thalamocortical
124
+ brain circuits. Given its modular, object-oriented design, HNN makes it easy to generate
125
+ and evaluate hypotheses on the mechanistic origin of signals measured with
126
+ magnetoencephalography (MEG), electroencephalography (EEG), or intracranial
127
+ electrocorticography (ECoG). A unique feature of the HNN model is that it accounts for
128
+ the biophysics generating the primary electric currents underlying such data. Simulation
129
+ results are *directly* comparable to source-localized data (current dipoles in units of
130
+ nano-Ampere-meters), enabling precise tuning of model parameters to match
131
+ characteristics of recorded signals. Multimodal neurophysiology data such as local field
132
+ potential (LFP), current-source density (CSD), and spiking dynamics can also be
133
+ simulated simultaneously with current dipoles.
134
+
135
+ You can view [HNN's frontpage here](https://hnn.brown.edu) for an overview of all that
136
+ HNN can do. For how to use HNN, we provide scientific documentation, tutorials, and
137
+ examples aplenty on our [HNN Textbook website][]. There, we describe the use of HNN in
138
+ studying the circuit-level origin of some of the most commonly measured MEG/EEG and ECoG
139
+ signals: event related potentials (ERPs) and low-frequency rhythms (alpha/beta/gamma).
140
+
141
+ The HNN API, written in Python and built on top of
142
+ [NEURON](https://nrn.readthedocs.io), is designed to be flexible and serve
143
+ users with varying levels of coding expertise, while the [HNN
144
+ GUI](https://jonescompneurolab.github.io/textbook/content/04_using_hnn_gui/gui_quickstart.html)
145
+ is designed to be useful to researchers with no formal computational neural modeling or
146
+ coding experience.
147
+
148
+ The terms HNN, HNN-core, and `hnn-core` are effectively equivalent, as they are all
149
+ different names for the same codebase. Historically, HNN-core was developed based on
150
+ the [original, deprecated HNN repository](https://github.com/jonescompneurolab/hnn), however that
151
+ repository is **no longer supported or developed**. It is kept online only for the sake
152
+ of scientific reproducibility.
153
+
154
+ Please consider supporting HNN development efforts by voluntarily [providing your
155
+ demographic information
156
+ here](https://docs.google.com/forms/d/e/1FAIpQLSfN2F4IkGATs6cy1QBO78C6QJqvm9y14TqsCUsuR4Rrkmr1Mg/viewform)!
157
+ Note that any demographic information we collect is anonymized and aggregated for
158
+ reporting on the grants that fund the continued development of HNN. All questions are
159
+ voluntary.
160
+
161
+ # Installation
162
+
163
+ You can try HNN **in your browser for free, with no local installation required!** At
164
+ the top of our [Installation Guide][], you can find links that describe how to run HNN
165
+ online in the cloud, either using Google CoLab notebooks or using the [Neuroscience Gateway
166
+ Portal](https://www.nsgportal.org/).
167
+
168
+ To install HNN locally, see our [Installation Guide][] located at the [HNN Textbook
169
+ website][]. The easiest way to install `hnn-core` with the all its dependencies on Mac,
170
+ Linux, or Windows (using "Windows Subsystem for Linux"), is to first install the
171
+ [Anaconda Python Distribution](https://www.anaconda.com/download/success) and then run
172
+ the following commands:
173
+
174
+ ```
175
+ conda create -y -q -n hnn-core-env python=3.12
176
+ conda activate hnn-core-env
177
+ conda install hnn-core-all -c jonescompneurolab -c conda-forge
178
+ ```
179
+
180
+ Our Anaconda packages currently only support Python 3.12. However, installing `hnn-core`
181
+ through `pip` currently supports **Python 3.9 through 3.13**, inclusively. Please see
182
+ our [Installation Guide][] for detailed instructions on the various ways you can install
183
+ HNN.
184
+
185
+ # Usage
186
+
187
+ Once you have installed `hnn-core` and the dependencies for the features you want, you
188
+ can find tutorials, examples, and scientific documentation at our [HNN Textbook
189
+ website][].
190
+
191
+ # Problems?
192
+
193
+ You can use the [GitHub Issues
194
+ tracker](https://github.com/jonescompneurolab/hnn-core/issues) to report bugs. For user
195
+ questions, installation help, and scientific discussions, please see our [GitHub
196
+ Discussions page](https://github.com/jonescompneurolab/hnn-core/discussions).
197
+
198
+ # Interested in Contributing?
199
+
200
+ Contributors are always welcome! Please read our [Contributing Guide][] and make sure to
201
+ abide by our [Code of
202
+ Conduct](https://github.com/jonescompneurolab/hnn-core/blob/master/CODE_OF_CONDUCT.md). Our
203
+ [governance structure can be found
204
+ here](https://jonescompneurolab.github.io/hnn-core/stable/governance.html).
205
+
206
+ # Citing
207
+
208
+ If you use HNN-core in your work, please cite our [publication in
209
+ JOSS](https://doi.org/10.21105/joss.05848):
210
+
211
+ > Jas et al., (2023). HNN-core: A Python software for cellular and
212
+ > circuit-level interpretation of human MEG/EEG. *Journal of Open Source
213
+ > Software*, 8(92), 5848, <https://doi.org/10.21105/joss.05848>
214
+
215
+ [Contributing Guide]: https://jonescompneurolab.github.io/hnn-core/stable/contributing.html
216
+ [HNN Textbook website]: https://jonescompneurolab.github.io/textbook/content/preface.html
217
+ [Installation Guide]: https://jonescompneurolab.github.io/textbook/content/01_getting_started/installation.html
@@ -0,0 +1,118 @@
1
+
2
+ <h1 align="center">
3
+ <img src="https://raw.githubusercontent.com/jonescompneurolab/jones-website/master/images/frontpage/logos/logo-hnn-medium.png" width="300">
4
+ </h1><br>
5
+
6
+ # hnn-core
7
+
8
+ [![tests](https://github.com/jonescompneurolab/hnn-core/actions/workflows/unix_unit_tests.yml/badge.svg?branch=master)](https://github.com/jonescompneurolab/hnn-core/actions/?query=branch:master+event:push)
9
+ [![CircleCI](https://circleci.com/gh/jonescompneurolab/hnn-core.svg?style=svg)](https://circleci.com/gh/jonescompneurolab/hnn-core)
10
+ [![Codecov](https://codecov.io/gh/jonescompneurolab/hnn-core/branch/master/graph/badge.svg)](https://codecov.io/gh/jonescompneurolab/hnn-core)
11
+ [![PyPI](https://img.shields.io/pypi/dm/hnn-core.svg?label=PyPI%20downloads)](https://pypi.org/project/hnn-core/)
12
+ [![Gitter](https://badges.gitter.im/jonescompneurolab/hnn_core.svg)](https://gitter.im/jonescompneurolab/hnn-core?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
13
+ [![JOSS](https://joss.theoj.org/papers/10.21105/joss.05848/status.svg)](https://doi.org/10.21105/joss.05848)
14
+
15
+ ![HNN-GUI](https://raw.githubusercontent.com/jonescompneurolab/hnn-core/acbcc4a598610dc3be5d4b0b7c59f98251ea7690/.github/images/hnn_gui.png)
16
+
17
+ # About
18
+
19
+ The [Human Neocortical Neurosolver (HNN)](https://hnn.brown.edu) is an open-source
20
+ neural modeling tool designed to help researchers/clinicians interpret human brain
21
+ imaging data. This repository, called **HNN-core**, houses the source code for HNN.
22
+
23
+ With only a few lines of code, HNN provides a convenient way to run simulations of an
24
+ anatomically- and biophysically-detailed dynamical system model of human thalamocortical
25
+ brain circuits. Given its modular, object-oriented design, HNN makes it easy to generate
26
+ and evaluate hypotheses on the mechanistic origin of signals measured with
27
+ magnetoencephalography (MEG), electroencephalography (EEG), or intracranial
28
+ electrocorticography (ECoG). A unique feature of the HNN model is that it accounts for
29
+ the biophysics generating the primary electric currents underlying such data. Simulation
30
+ results are *directly* comparable to source-localized data (current dipoles in units of
31
+ nano-Ampere-meters), enabling precise tuning of model parameters to match
32
+ characteristics of recorded signals. Multimodal neurophysiology data such as local field
33
+ potential (LFP), current-source density (CSD), and spiking dynamics can also be
34
+ simulated simultaneously with current dipoles.
35
+
36
+ You can view [HNN's frontpage here](https://hnn.brown.edu) for an overview of all that
37
+ HNN can do. For how to use HNN, we provide scientific documentation, tutorials, and
38
+ examples aplenty on our [HNN Textbook website][]. There, we describe the use of HNN in
39
+ studying the circuit-level origin of some of the most commonly measured MEG/EEG and ECoG
40
+ signals: event related potentials (ERPs) and low-frequency rhythms (alpha/beta/gamma).
41
+
42
+ The HNN API, written in Python and built on top of
43
+ [NEURON](https://nrn.readthedocs.io), is designed to be flexible and serve
44
+ users with varying levels of coding expertise, while the [HNN
45
+ GUI](https://jonescompneurolab.github.io/textbook/content/04_using_hnn_gui/gui_quickstart.html)
46
+ is designed to be useful to researchers with no formal computational neural modeling or
47
+ coding experience.
48
+
49
+ The terms HNN, HNN-core, and `hnn-core` are effectively equivalent, as they are all
50
+ different names for the same codebase. Historically, HNN-core was developed based on
51
+ the [original, deprecated HNN repository](https://github.com/jonescompneurolab/hnn), however that
52
+ repository is **no longer supported or developed**. It is kept online only for the sake
53
+ of scientific reproducibility.
54
+
55
+ Please consider supporting HNN development efforts by voluntarily [providing your
56
+ demographic information
57
+ here](https://docs.google.com/forms/d/e/1FAIpQLSfN2F4IkGATs6cy1QBO78C6QJqvm9y14TqsCUsuR4Rrkmr1Mg/viewform)!
58
+ Note that any demographic information we collect is anonymized and aggregated for
59
+ reporting on the grants that fund the continued development of HNN. All questions are
60
+ voluntary.
61
+
62
+ # Installation
63
+
64
+ You can try HNN **in your browser for free, with no local installation required!** At
65
+ the top of our [Installation Guide][], you can find links that describe how to run HNN
66
+ online in the cloud, either using Google CoLab notebooks or using the [Neuroscience Gateway
67
+ Portal](https://www.nsgportal.org/).
68
+
69
+ To install HNN locally, see our [Installation Guide][] located at the [HNN Textbook
70
+ website][]. The easiest way to install `hnn-core` with the all its dependencies on Mac,
71
+ Linux, or Windows (using "Windows Subsystem for Linux"), is to first install the
72
+ [Anaconda Python Distribution](https://www.anaconda.com/download/success) and then run
73
+ the following commands:
74
+
75
+ ```
76
+ conda create -y -q -n hnn-core-env python=3.12
77
+ conda activate hnn-core-env
78
+ conda install hnn-core-all -c jonescompneurolab -c conda-forge
79
+ ```
80
+
81
+ Our Anaconda packages currently only support Python 3.12. However, installing `hnn-core`
82
+ through `pip` currently supports **Python 3.9 through 3.13**, inclusively. Please see
83
+ our [Installation Guide][] for detailed instructions on the various ways you can install
84
+ HNN.
85
+
86
+ # Usage
87
+
88
+ Once you have installed `hnn-core` and the dependencies for the features you want, you
89
+ can find tutorials, examples, and scientific documentation at our [HNN Textbook
90
+ website][].
91
+
92
+ # Problems?
93
+
94
+ You can use the [GitHub Issues
95
+ tracker](https://github.com/jonescompneurolab/hnn-core/issues) to report bugs. For user
96
+ questions, installation help, and scientific discussions, please see our [GitHub
97
+ Discussions page](https://github.com/jonescompneurolab/hnn-core/discussions).
98
+
99
+ # Interested in Contributing?
100
+
101
+ Contributors are always welcome! Please read our [Contributing Guide][] and make sure to
102
+ abide by our [Code of
103
+ Conduct](https://github.com/jonescompneurolab/hnn-core/blob/master/CODE_OF_CONDUCT.md). Our
104
+ [governance structure can be found
105
+ here](https://jonescompneurolab.github.io/hnn-core/stable/governance.html).
106
+
107
+ # Citing
108
+
109
+ If you use HNN-core in your work, please cite our [publication in
110
+ JOSS](https://doi.org/10.21105/joss.05848):
111
+
112
+ > Jas et al., (2023). HNN-core: A Python software for cellular and
113
+ > circuit-level interpretation of human MEG/EEG. *Journal of Open Source
114
+ > Software*, 8(92), 5848, <https://doi.org/10.21105/joss.05848>
115
+
116
+ [Contributing Guide]: https://jonescompneurolab.github.io/hnn-core/stable/contributing.html
117
+ [HNN Textbook website]: https://jonescompneurolab.github.io/textbook/content/preface.html
118
+ [Installation Guide]: https://jonescompneurolab.github.io/textbook/content/01_getting_started/installation.html
@@ -0,0 +1,174 @@
1
+ """
2
+ =================================
3
+ 09. Replaying Spike Data as Input
4
+ =================================
5
+
6
+ Welcome to this hands-on tutorial on simulating communication between two neocortical
7
+ networks using HNN-Core! This notebook guides you through creating a source network
8
+ (Network A), extracting its spike data, feeding it into a target network (Network B)
9
+ using the `add_spike_train_drive` method, simulating both, and visualizing the
10
+ results. Let's dive in!
11
+ """
12
+
13
+ # Authors: Maira Usman <maira.usman5703@gmail.com>
14
+
15
+ ###############################################################################
16
+ # Step 1: Setting Up the Source Network (Network A)
17
+ # -------------------------------------------------
18
+ #
19
+ # Our journey begins with Network A, the source of neural activity. We'll use the
20
+ # `jones_2009_model` to create a realistic neocortical network and simulate it with an
21
+ # evoked drive to generate spike data. This step mimics how a network might produce
22
+ # activity in a real brain region, which we'll later transmit to another network.
23
+ #
24
+ # The simulation runs for 170 ms, and we'll save the spike data to a temporary file for
25
+ # efficient handling.
26
+ import numpy as np
27
+ import matplotlib.pyplot as plt
28
+ from hnn_core import jones_2009_model, simulate_dipole, read_spikes
29
+ import os.path as op
30
+ import tempfile
31
+
32
+ # Create and simulate Network A
33
+ print("Creating and simulating Network A...")
34
+ net_A = jones_2009_model()
35
+ net_A._params.update({'tstop': 170.0})
36
+
37
+ # Add a drive to generate activity
38
+ print("Adding drive to Network A...")
39
+ drive_params = {
40
+ 'name': 'evdist1', 'mu': 63.5, 'sigma': 3.8, 'numspikes': 1,
41
+ 'location': 'distal', 'event_seed': 274
42
+ }
43
+ weights = {
44
+ 'ampa': {'L2_basket': 0.006, 'L2_pyramidal': 0.0005, 'L5_pyramidal': 0.14},
45
+ 'nmda': {'L2_basket': 0.019, 'L2_pyramidal': 0.004, 'L5_pyramidal': 0.08}
46
+ }
47
+ delays = {'L2_basket': 0.1, 'L2_pyramidal': 0.1, 'L5_pyramidal': 0.1}
48
+ net_A.add_evoked_drive(
49
+ **drive_params, weights_ampa=weights['ampa'], weights_nmda=weights['nmda'],
50
+ synaptic_delays=delays
51
+ )
52
+
53
+ # Simulate and save spike data
54
+ print("Simulating Network A and saving spikes...")
55
+ dpls_A = simulate_dipole(net_A, tstop=170.0, n_trials=1)
56
+ with tempfile.TemporaryDirectory() as tmp_dir:
57
+ spike_file = op.join(tmp_dir, 'spk_%d.txt')
58
+ net_A.cell_response.write(spike_file)
59
+ cell_response = read_spikes(op.join(tmp_dir, 'spk_*.txt'))
60
+ print(f"Extracted {sum(len(t) for t in cell_response.spike_times)} spikes from Network A")
61
+
62
+ ###############################################################################
63
+ # Step 2: Configuring the Target Network (Network B)
64
+ # --------------------------------------------------
65
+ #
66
+ # Now, let's set up Network B, the target network that will receive spike data from
67
+ # Network A. We'll extract spikes from the first trial of Network A, filter for
68
+ # pyramidal cells, and format them into a dictionary compatible with
69
+ # `add_spike_train_drive`. This process is akin to distributing computed data across
70
+ # nodes in an MPI setup, where each node (here, Network B) processes a subset of the
71
+ # input.
72
+ #
73
+ # We'll also define connection properties to map Network A's pyramidal cells to Network
74
+ # B's layers, ensuring a realistic interaction.
75
+ print("Creating and configuring Network B...")
76
+ net_B = jones_2009_model()
77
+ net_B._params.update({'tstop': 225.0})
78
+
79
+ # Extract spike data from first trial and filter for pyramidal cells
80
+ trial_idx = 0
81
+ spike_times = cell_response.spike_times[trial_idx]
82
+ spike_gids = cell_response.spike_gids[trial_idx]
83
+ spike_types = cell_response.spike_types[trial_idx]
84
+ pyramidal_mask = np.array([t in ['L2_pyramidal', 'L5_pyramidal'] for t in spike_types])
85
+ filtered_times = np.array(spike_times)[pyramidal_mask]
86
+ filtered_gids = np.array(spike_gids)[pyramidal_mask]
87
+ filtered_types = np.array(spike_types)[pyramidal_mask]
88
+ spike_data = {f"NetA_{t}_GID{g}": [] for t, g in zip(filtered_types, filtered_gids)}
89
+ for t, g, time in zip(filtered_types, filtered_gids, filtered_times):
90
+ src_id = f"NetA_{t}_GID{g}"
91
+ spike_data[src_id].append(time)
92
+
93
+ print(f"Number of valid pyramidal cells with spikes to be used for input: {len(spike_data)}")
94
+
95
+ # Define target configuration
96
+ conn_properties = {
97
+ 'L5_pyramidal': {'location': 'distal', 'weights_ampa': 0.005, 'synaptic_delays': 1.5},
98
+ 'L2_pyramidal': {'location': 'proximal', 'weights_ampa': 0.003, 'synaptic_delays': 1.0}
99
+ }
100
+ target_config = {}
101
+ source_ids = list(spike_data.keys())
102
+ for i, src_id in enumerate(source_ids):
103
+ target_type = 'L5_pyramidal' if i % 2 == 0 else 'L2_pyramidal'
104
+ props = conn_properties[target_type]
105
+ target_config[src_id] = {
106
+ 'target_cell_types': [target_type],
107
+ 'location': props['location'],
108
+ 'weights_ampa': {target_type: props['weights_ampa']},
109
+ 'synaptic_delays': {target_type: props['synaptic_delays']},
110
+ 'probability': 0.7
111
+ }
112
+ all_weights_ampa = {k: cfg['weights_ampa'][k] for cfg in target_config.values() for k in cfg['weights_ampa']}
113
+
114
+ # Add spike train drive to Network B
115
+ net_B.add_spike_train_drive(
116
+ name='drive_from_NetA',
117
+ spike_data=spike_data,
118
+ location='distal',
119
+ weights_ampa=all_weights_ampa,
120
+ weights_nmda=None,
121
+ synaptic_delays=0.1,
122
+ conn_seed=42
123
+ )
124
+
125
+ ###############################################################################
126
+ # Step 3: Simulating and Visualizing the Networks
127
+ # -----------------------------------------------
128
+ #
129
+ # With Network B configured, we'll simulate it for 225 ms to observe the effect of
130
+ # Network A's spikes. Visualization is key in neuroscience, so we'll create raster plots
131
+ # for both networks. This step lets you see how the input from Network A influences
132
+ # Network B's activity.
133
+ print("Simulating Network B...")
134
+ dpls_b = simulate_dipole(net_B, tstop=225.0, n_trials=1)
135
+
136
+ # Visualize results
137
+ fig, axes = plt.subplots(2, 1, figsize=(10, 12), sharex=True, constrained_layout=True)
138
+ # 1. Network A: Spike raster
139
+ net_A.cell_response.plot_spikes_raster(ax=axes[0], show=False)
140
+ axes[0].set_title('Network A: Spike Raster')
141
+ axes[0].set_ylabel('Cell ID')
142
+ # 2. Network B: Spike raster
143
+ net_B.cell_response.plot_spikes_raster(ax=axes[1], show=False)
144
+ axes[1].set_title('Network B: Spike Raster')
145
+ axes[1].set_ylabel('Cell ID')
146
+ axes[1].set_xlabel('Time (ms)')
147
+ plt.show()
148
+
149
+ ###############################################################################
150
+ # Now that the simulation is finished, let's verify the drive setup and ensure the
151
+ # connection was established correctly.
152
+ print("\nVerifying configuration:")
153
+ drive_name = 'drive_from_NetA'
154
+ if drive_name in net_B.external_drives:
155
+ drive = net_B.external_drives[drive_name]
156
+ print(f" Drive '{drive_name}' created with {drive['n_drive_cells']} cells")
157
+ if drive_name in net_B.gid_ranges:
158
+ print(f" GIDs assigned: {net_B.gid_ranges[drive_name]}")
159
+ drive_connections = sum(1 for conn in net_B.connectivity if conn['src_type'] == drive_name)
160
+ print(f" Number of connections from drive: {drive_connections}")
161
+ else:
162
+ print(f" ERROR: Drive '{drive_name}' not found")
163
+
164
+ ###############################################################################
165
+ # Conclusion
166
+ # -----------------------------------------------
167
+ #
168
+ # You've now successfully replayed spikes from one network into another network! The
169
+ # raster plots show how Network A's activity influences Network B, while the
170
+ # verification confirms the drive setup. This approach is scalable—similar to MPI's
171
+ # distributed computing—allowing you to experiment with multiple networks or adjust
172
+ # parameters like weights and delays to explore different dynamics. Try modifying the
173
+ # `weights_ampa` or `synaptic_delays` values in Step 2 to see how they affect the
174
+ # results!
@@ -32,18 +32,18 @@ net = law_2021_model()
32
32
  # contains information on the biophysics and geometry of each cell.
33
33
  net_jones = jones_2009_model()
34
34
 
35
- jones_rise = net_jones.cell_types['L5_pyramidal'].synapses['gabab']['tau1']
36
- law_rise = net.cell_types['L5_pyramidal'].synapses['gabab']['tau1']
35
+ jones_rise = net_jones.cell_types['L5_pyramidal']['cell_object'].synapses['gabab']['tau1']
36
+ law_rise = net.cell_types['L5_pyramidal']['cell_object'].synapses['gabab']['tau1']
37
37
  print(f'GABAb Rise (ms): {jones_rise} -> {law_rise}')
38
38
 
39
- jones_fall = net_jones.cell_types['L5_pyramidal'].synapses['gabab']['tau2']
40
- law_fall = net.cell_types['L5_pyramidal'].synapses['gabab']['tau2']
39
+ jones_fall = net_jones.cell_types['L5_pyramidal']['cell_object'].synapses['gabab']['tau2']
40
+ law_fall = net.cell_types['L5_pyramidal']['cell_object'].synapses['gabab']['tau2']
41
41
  print(f'GABAb Fall (ms): {jones_fall} -> {law_fall}\n')
42
42
 
43
43
  print('Apical Dendrite Channels:')
44
- print(net.cell_types['L5_pyramidal'].sections['apical_1'].mechs.keys())
44
+ print(net.cell_types['L5_pyramidal']['cell_object'].sections['apical_1'].mechs.keys())
45
45
  print("\nBasal Dendrite Channels ('ca' missing):")
46
- print(net.cell_types['L5_pyramidal'].sections['basal_1'].mechs.keys())
46
+ print(net.cell_types['L5_pyramidal']['cell_object'].sections['basal_1'].mechs.keys())
47
47
 
48
48
  ###############################################################################
49
49
  # A major change to the Jones 2009 model is the addition of a
@@ -38,7 +38,7 @@ from hnn_core.viz import plot_dipole
38
38
  # inside it.
39
39
  net = jones_2009_model()
40
40
  net.plot_cells()
41
- net.cell_types['L5_pyramidal'].plot_morphology()
41
+ net.cell_types['L5_pyramidal']['cell_object'].plot_morphology()
42
42
 
43
43
  ###############################################################################
44
44
  # The network of cells is now defined, to which we add external drives as
@@ -122,7 +122,7 @@ plot_psd(dpls[trial_idx], fmin=20., fmax=100., tmin=tmin)
122
122
  # we decrease `tau2` from 5 to 2 ms. This will shorten the effective
123
123
  # refactory period between L5 pyramidal cell spikes and increase the PING
124
124
  # frequency from ~50 to ~65 Hz.
125
- net.cell_types['L5_pyramidal'].synapses['gabaa']['tau2'] = 2
125
+ net.cell_types['L5_pyramidal']["cell_object"].synapses['gabaa']['tau2'] = 2
126
126
  dpls = simulate_dipole(net, tstop=250., n_trials=1)
127
127
  dpls = [dpl.scale(scaling_factor) for dpl in dpls] # scale in place
128
128
 
@@ -12,5 +12,11 @@ from .cell import Cell
12
12
  from .cell_response import CellResponse, read_spikes
13
13
  from .cells_default import pyramidal, basket
14
14
  from .parallel_backends import MPIBackend, JoblibBackend
15
+ from .hnn_io import (
16
+ dict_to_network,
17
+ network_to_dict,
18
+ read_network_configuration,
19
+ write_network_configuration,
20
+ )
15
21
 
16
- __version__ = "0.4.2.dev1"
22
+ __version__ = "0.4.3"
@@ -341,9 +341,9 @@ def basket(cell_name, pos=(0, 0, 0), gid=None):
341
341
  cell : instance of BasketSingle
342
342
  The basket cell.
343
343
  """
344
- if cell_name == "L2Basket":
344
+ if cell_name == "L2_basket":
345
345
  sect_loc = dict(proximal=["soma"], distal=["soma"])
346
- elif cell_name == "L5Basket":
346
+ elif cell_name == "L5_basket":
347
347
  sect_loc = dict(proximal=["soma"], distal=[])
348
348
  else:
349
349
  raise ValueError(f"Unknown basket cell type: {cell_name}")
@@ -382,9 +382,9 @@ def pyramidal(cell_name, pos=(0, 0, 0), override_params=None, gid=None):
382
382
  The GID is an integer from 0 to n_cells, or None if the cell is not
383
383
  yet attached to a network. Once the GID is set, it cannot be changed.
384
384
  """
385
- if cell_name == "L2Pyr":
385
+ if cell_name == "L2_pyramidal":
386
386
  return _cell_L2Pyr(override_params, pos=pos, gid=gid)
387
- elif cell_name == "L5Pyr":
387
+ elif cell_name == "L5_pyramidal":
388
388
  return _cell_L5Pyr(override_params, pos=pos, gid=gid)
389
389
  else:
390
390
  raise ValueError(f"Unknown pyramidal cell type: {cell_name}")
@@ -85,7 +85,8 @@ def simulate_dipole(
85
85
  warnings.warn("No external drives or biases loaded", UserWarning)
86
86
 
87
87
  for drive_name, drive in net.external_drives.items():
88
- if "tstop" in drive["dynamics"]:
88
+ # Check if 'dynamics' key exists before trying to access its contents
89
+ if "dynamics" in drive and "tstop" in drive["dynamics"]:
89
90
  if drive["dynamics"]["tstop"] is None:
90
91
  drive["dynamics"]["tstop"] = tstop
91
92
  for bias_name, bias in net.external_biases.items():