hnn-core 0.4.1__tar.gz → 0.4.2.dev1__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 (118) hide show
  1. {hnn_core-0.4.1/hnn_core.egg-info → hnn_core-0.4.2.dev1}/PKG-INFO +2 -2
  2. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/README.md +1 -1
  3. hnn_core-0.4.2.dev1/examples/workflows/README.txt +15 -0
  4. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/__init__.py +8 -2
  5. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/batch_simulate.py +102 -91
  6. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/cell.py +162 -134
  7. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/cell_response.py +169 -113
  8. hnn_core-0.4.2.dev1/hnn_core/cells_default.py +444 -0
  9. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/check.py +5 -5
  10. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/dipole.py +197 -122
  11. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/docs.py +6 -18
  12. hnn_core-0.4.2.dev1/hnn_core/drives.py +485 -0
  13. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/externals/bayesopt.py +15 -12
  14. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/externals/mne.py +367 -138
  15. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/extracellular.py +203 -128
  16. hnn_core-0.4.2.dev1/hnn_core/gui/__init__.py +1 -0
  17. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/gui/_viz_manager.py +472 -391
  18. hnn_core-0.4.2.dev1/hnn_core/gui/gui.py +2760 -0
  19. hnn_core-0.4.2.dev1/hnn_core/hnn_io.py +505 -0
  20. hnn_core-0.4.2.dev1/hnn_core/mod/vecevent.mod +175 -0
  21. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mpi_child.py +20 -17
  22. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/network.py +654 -406
  23. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/network_builder.py +95 -81
  24. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/network_models.py +190 -141
  25. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/optimization/general_optimization.py +107 -72
  26. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/optimization/objective_functions.py +39 -20
  27. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/optimization/optimize_evoked.py +280 -208
  28. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/parallel_backends.py +128 -115
  29. hnn_core-0.4.2.dev1/hnn_core/params.py +863 -0
  30. hnn_core-0.4.2.dev1/hnn_core/params_default.py +316 -0
  31. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/conftest.py +55 -34
  32. hnn_core-0.4.2.dev1/hnn_core/tests/regenerate_test_network.py +121 -0
  33. hnn_core-0.4.2.dev1/hnn_core/tests/test_batch_simulate.py +317 -0
  34. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_cell.py +51 -65
  35. hnn_core-0.4.2.dev1/hnn_core/tests/test_cell_response.py +206 -0
  36. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_cells_default.py +20 -14
  37. hnn_core-0.4.2.dev1/hnn_core/tests/test_dipole.py +346 -0
  38. hnn_core-0.4.2.dev1/hnn_core/tests/test_drives.py +739 -0
  39. hnn_core-0.4.2.dev1/hnn_core/tests/test_extracellular.py +346 -0
  40. hnn_core-0.4.2.dev1/hnn_core/tests/test_general_optimization.py +391 -0
  41. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_gui.py +434 -377
  42. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_io.py +141 -118
  43. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_mpi_child.py +47 -38
  44. hnn_core-0.4.2.dev1/hnn_core/tests/test_network.py +1470 -0
  45. hnn_core-0.4.2.dev1/hnn_core/tests/test_optimize_evoked.py +230 -0
  46. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_parallel_backends.py +161 -144
  47. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_params.py +71 -72
  48. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/tests/test_utils.py +12 -9
  49. hnn_core-0.4.2.dev1/hnn_core/tests/test_viz.py +703 -0
  50. hnn_core-0.4.2.dev1/hnn_core/utils.py +138 -0
  51. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/viz.py +668 -425
  52. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1/hnn_core.egg-info}/PKG-INFO +2 -2
  53. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core.egg-info/SOURCES.txt +0 -4
  54. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/setup.py +1 -1
  55. hnn_core-0.4.1/examples/howto/S1_SupraT.txt +0 -105
  56. hnn_core-0.4.1/examples/workflows/README.txt +0 -17
  57. hnn_core-0.4.1/hnn_core/cells_default.py +0 -436
  58. hnn_core-0.4.1/hnn_core/drives.py +0 -440
  59. hnn_core-0.4.1/hnn_core/gui/.ipynb_checkpoints/hnn_widget-checkpoint.ipynb +0 -71
  60. hnn_core-0.4.1/hnn_core/gui/__init__.py +0 -1
  61. hnn_core-0.4.1/hnn_core/gui/gui.py +0 -2477
  62. hnn_core-0.4.1/hnn_core/hnn_io.py +0 -494
  63. hnn_core-0.4.1/hnn_core/mod/vecevent.mod +0 -69
  64. hnn_core-0.4.1/hnn_core/param/base.json +0 -208
  65. hnn_core-0.4.1/hnn_core/param/empty.json +0 -1
  66. hnn_core-0.4.1/hnn_core/params.py +0 -785
  67. hnn_core-0.4.1/hnn_core/params_default.py +0 -364
  68. hnn_core-0.4.1/hnn_core/tests/regenerate_test_network.py +0 -81
  69. hnn_core-0.4.1/hnn_core/tests/test_batch_simulate.py +0 -318
  70. hnn_core-0.4.1/hnn_core/tests/test_cell_response.py +0 -159
  71. hnn_core-0.4.1/hnn_core/tests/test_dipole.py +0 -300
  72. hnn_core-0.4.1/hnn_core/tests/test_drives.py +0 -534
  73. hnn_core-0.4.1/hnn_core/tests/test_extracellular.py +0 -289
  74. hnn_core-0.4.1/hnn_core/tests/test_general_optimization.py +0 -305
  75. hnn_core-0.4.1/hnn_core/tests/test_network.py +0 -1160
  76. hnn_core-0.4.1/hnn_core/tests/test_optimize_evoked.py +0 -180
  77. hnn_core-0.4.1/hnn_core/tests/test_viz.py +0 -615
  78. hnn_core-0.4.1/hnn_core/utils.py +0 -97
  79. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/LICENSE +0 -0
  80. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/MANIFEST.in +0 -0
  81. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/README.txt +0 -0
  82. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/README.txt +0 -0
  83. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/optimize_evoked.py +0 -0
  84. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/optimize_rhythmic.py +0 -0
  85. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_batch_simulate.py +0 -0
  86. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_connectivity.py +0 -0
  87. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_firing_pattern.py +0 -0
  88. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_hnn_animation.py +0 -0
  89. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_record_extracellular_potentials.py +0 -0
  90. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/howto/plot_simulate_mpi_backend.py +0 -0
  91. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/workflows/plot_simulate_alpha.py +0 -0
  92. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/workflows/plot_simulate_beta.py +0 -0
  93. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/workflows/plot_simulate_evoked.py +0 -0
  94. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/workflows/plot_simulate_gamma.py +0 -0
  95. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/examples/workflows/plot_simulate_somato.py +0 -0
  96. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/externals/__init__.py +0 -0
  97. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/gui/_logging.py +0 -0
  98. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/gui/hnn_widget.ipynb +0 -0
  99. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/ar.mod +0 -0
  100. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/ca.mod +0 -0
  101. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/cad.mod +0 -0
  102. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/cat.mod +0 -0
  103. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/dipole.mod +0 -0
  104. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/dipole_pp.mod +0 -0
  105. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/hh2.mod +0 -0
  106. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/kca.mod +0 -0
  107. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/mod/km.mod +0 -0
  108. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/optimization/__init__.py +0 -0
  109. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/param/N20.json +0 -0
  110. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/param/default.json +0 -0
  111. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/param/gamma_L5weak_L2weak.json +0 -0
  112. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core/param/jones2009_base.json +0 -0
  113. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core.egg-info/dependency_links.txt +0 -0
  114. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core.egg-info/entry_points.txt +0 -0
  115. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core.egg-info/requires.txt +0 -0
  116. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/hnn_core.egg-info/top_level.txt +0 -0
  117. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/pyproject.toml +0 -0
  118. {hnn_core-0.4.1 → hnn_core-0.4.2.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hnn-core
3
- Version: 0.4.1
3
+ Version: 0.4.2.dev1
4
4
  Summary: Code for biophysical simulation of a cortical column using Neuron
5
5
  Home-page:
6
6
  Download-URL: http://github.com/jonescompneurolab/hnn-core
@@ -94,7 +94,7 @@ Dynamic: summary
94
94
 
95
95
 
96
96
  <h1 align="center">
97
- <img src="https://hnn.brown.edu/wp-content/uploads/hnn-medium.png" width="300">
97
+ <img src="https://raw.githubusercontent.com/jonescompneurolab/jones-website/master/images/frontpage/logos/logo-hnn-medium.png" width="300">
98
98
  </h1><br>
99
99
 
100
100
  # hnn-core
@@ -1,6 +1,6 @@
1
1
 
2
2
  <h1 align="center">
3
- <img src="https://hnn.brown.edu/wp-content/uploads/hnn-medium.png" width="300">
3
+ <img src="https://raw.githubusercontent.com/jonescompneurolab/jones-website/master/images/frontpage/logos/logo-hnn-medium.png" width="300">
4
4
  </h1><br>
5
5
 
6
6
  # hnn-core
@@ -0,0 +1,15 @@
1
+ Tutorials
2
+ ---------
3
+
4
+ The following tutorials contain the workflow and code to simulate and visualize commonly
5
+ studied M/EEG signals including event related potentials and low frequency rhythms in
6
+ the alpha, beta and gamma bands. These tutorial workflows are analogous to those on the
7
+ `textbook website <https://jonescompneurolab.github.io/textbook/content/preface.html>`_.
8
+
9
+ We strongly recommend that you first go through the background information provided on
10
+ the `HNN textbook website
11
+ <https://jonescompneurolab.github.io/textbook/content/preface.html>`_ and each of the
12
+ HNN GUI tutorials, after which the code and instructions in these HNN-core tutorials
13
+ will be clearer. All tutorials build from our prior publications investigating the
14
+ origin of ERPs and brain rhythms in the somatosensory system, and parameter and data
15
+ sets are provided to help users get started.
@@ -1,4 +1,10 @@
1
- from .dipole import simulate_dipole, read_dipole, average_dipoles, Dipole,_read_dipole_txt
1
+ from .dipole import (
2
+ simulate_dipole,
3
+ read_dipole,
4
+ average_dipoles,
5
+ Dipole,
6
+ _read_dipole_txt,
7
+ )
2
8
  from .params import Params, read_params, convert_to_json
3
9
  from .network import Network, pick_connection
4
10
  from .network_models import jones_2009_model, law_2021_model, calcium_model
@@ -7,4 +13,4 @@ from .cell_response import CellResponse, read_spikes
7
13
  from .cells_default import pyramidal, basket
8
14
  from .parallel_backends import MPIBackend, JoblibBackend
9
15
 
10
- __version__ = '0.4.1'
16
+ __version__ = "0.4.2.dev1"
@@ -109,7 +109,7 @@ class BatchSimulate(object):
109
109
  tstop=170,
110
110
  dt=0.025,
111
111
  n_trials=1,
112
- save_folder='./sim_results',
112
+ save_folder="./sim_results",
113
113
  batch_size=100,
114
114
  overwrite=True,
115
115
  save_outputs=False,
@@ -125,23 +125,22 @@ class BatchSimulate(object):
125
125
  clear_cache=False,
126
126
  summary_func=None,
127
127
  ):
128
-
129
- _validate_type(net, Network, 'net', 'Network')
130
- _validate_type(tstop, types='numeric', item_name='tstop')
131
- _validate_type(dt, types='numeric', item_name='dt')
132
- _validate_type(n_trials, types='int', item_name='n_trials')
133
- _validate_type(save_folder, types='path-like', item_name='save_folder')
134
- _validate_type(batch_size, types='int', item_name='batch_size')
135
- _validate_type(save_outputs, types=(bool,), item_name='save_outputs')
136
- _validate_type(save_dpl, types=(bool,), item_name='save_dpl')
137
- _validate_type(save_spiking, types=(bool,), item_name='save_spiking')
138
- _validate_type(save_lfp, types=(bool,), item_name='save_lfp')
139
- _validate_type(save_voltages, types=(bool,), item_name='save_voltages')
140
- _validate_type(save_currents, types=(bool,), item_name='save_currents')
141
- _validate_type(save_calcium, types=(bool,), item_name='save_calcium')
142
- _check_option('record_vsec', record_vsec, ['all', 'soma', False])
143
- _check_option('record_isec', record_isec, ['all', 'soma', False])
144
- _validate_type(clear_cache, types=(bool,), item_name='clear_cache')
128
+ _validate_type(net, Network, "net", "Network")
129
+ _validate_type(tstop, types="numeric", item_name="tstop")
130
+ _validate_type(dt, types="numeric", item_name="dt")
131
+ _validate_type(n_trials, types="int", item_name="n_trials")
132
+ _validate_type(save_folder, types="path-like", item_name="save_folder")
133
+ _validate_type(batch_size, types="int", item_name="batch_size")
134
+ _validate_type(save_outputs, types=(bool,), item_name="save_outputs")
135
+ _validate_type(save_dpl, types=(bool,), item_name="save_dpl")
136
+ _validate_type(save_spiking, types=(bool,), item_name="save_spiking")
137
+ _validate_type(save_lfp, types=(bool,), item_name="save_lfp")
138
+ _validate_type(save_voltages, types=(bool,), item_name="save_voltages")
139
+ _validate_type(save_currents, types=(bool,), item_name="save_currents")
140
+ _validate_type(save_calcium, types=(bool,), item_name="save_calcium")
141
+ _check_option("record_vsec", record_vsec, ["all", "soma", False])
142
+ _check_option("record_isec", record_isec, ["all", "soma", False])
143
+ _validate_type(clear_cache, types=(bool,), item_name="clear_cache")
145
144
 
146
145
  if set_params is not None and not callable(set_params):
147
146
  raise TypeError("set_params must be a callable function")
@@ -176,7 +175,7 @@ class BatchSimulate(object):
176
175
  return_output=True,
177
176
  combinations=True,
178
177
  n_jobs=1,
179
- backend='loky',
178
+ backend="loky",
180
179
  verbose=50,
181
180
  ):
182
181
  """Run batch simulations.
@@ -213,14 +212,14 @@ class BatchSimulate(object):
213
212
  Return content depends on `summary_func`, `return_output`, and
214
213
  `clear_cache` settings.
215
214
  """
216
- _validate_type(param_grid, types=(dict,), item_name='param_grid')
217
- _validate_type(n_jobs, types='int', item_name='n_jobs')
218
- _check_option('backend', backend, ['loky', 'threading',
219
- 'multiprocessing', 'dask'])
220
- _validate_type(verbose, types='int', item_name='verbose')
221
-
222
- param_combinations = self._generate_param_combinations(
223
- param_grid, combinations)
215
+ _validate_type(param_grid, types=(dict,), item_name="param_grid")
216
+ _validate_type(n_jobs, types="int", item_name="n_jobs")
217
+ _check_option(
218
+ "backend", backend, ["loky", "threading", "multiprocessing", "dask"]
219
+ )
220
+ _validate_type(verbose, types="int", item_name="verbose")
221
+
222
+ param_combinations = self._generate_param_combinations(param_grid, combinations)
224
223
  total_sims = len(param_combinations)
225
224
  batch_size = min(self.batch_size, total_sims)
226
225
 
@@ -233,7 +232,8 @@ class BatchSimulate(object):
233
232
  param_combinations[start_idx:end_idx],
234
233
  n_jobs=n_jobs,
235
234
  backend=backend,
236
- verbose=verbose)
235
+ verbose=verbose,
236
+ )
237
237
 
238
238
  if self.save_outputs:
239
239
  self._save(batch_results, start_idx, end_idx)
@@ -254,15 +254,14 @@ class BatchSimulate(object):
254
254
  if self.clear_cache:
255
255
  return {"summary_statistics": results}
256
256
  else:
257
- return {"summary_statistics": results,
258
- "simulated_data": simulated_data}
257
+ return {"summary_statistics": results, "simulated_data": simulated_data}
259
258
 
260
259
  def simulate_batch(
261
- self,
262
- param_combinations,
263
- n_jobs=1,
264
- backend='loky',
265
- verbose=50,
260
+ self,
261
+ param_combinations,
262
+ n_jobs=1,
263
+ backend="loky",
264
+ verbose=50,
266
265
  ):
267
266
  """Simulate a batch of parameter sets in parallel.
268
267
 
@@ -291,17 +290,19 @@ class BatchSimulate(object):
291
290
  - `dpl`: The simulated dipole.
292
291
  - `param_values`: The parameter values used for the simulation.
293
292
  """
294
- _validate_type(param_combinations, types=(list,),
295
- item_name='param_combinations')
296
- _validate_type(n_jobs, types='int', item_name='n_jobs')
297
- _check_option('backend', backend, ['loky', 'threading',
298
- 'multiprocessing', 'dask'])
299
- _validate_type(verbose, types='int', item_name='verbose')
293
+ _validate_type(
294
+ param_combinations, types=(list,), item_name="param_combinations"
295
+ )
296
+ _validate_type(n_jobs, types="int", item_name="n_jobs")
297
+ _check_option(
298
+ "backend", backend, ["loky", "threading", "multiprocessing", "dask"]
299
+ )
300
+ _validate_type(verbose, types="int", item_name="verbose")
300
301
 
301
302
  with parallel_config(backend=backend):
302
303
  res = Parallel(n_jobs=n_jobs, verbose=verbose)(
303
- delayed(self._run_single_sim)(
304
- params) for params in param_combinations)
304
+ delayed(self._run_single_sim)(params) for params in param_combinations
305
+ )
305
306
  return res
306
307
 
307
308
  def _run_single_sim(self, param_values):
@@ -325,36 +326,38 @@ class BatchSimulate(object):
325
326
  net = self.net.copy()
326
327
  self.set_params(param_values, net)
327
328
 
328
- results = {'net': net, 'param_values': param_values}
329
+ results = {"net": net, "param_values": param_values}
329
330
 
330
331
  if self.save_dpl:
331
- dpl = simulate_dipole(net,
332
- tstop=self.tstop,
333
- dt=self.dt,
334
- n_trials=self.n_trials,
335
- record_vsec=self.record_vsec,
336
- record_isec=self.record_isec,
337
- postproc=self.postproc)
338
- results['dpl'] = dpl
332
+ dpl = simulate_dipole(
333
+ net,
334
+ tstop=self.tstop,
335
+ dt=self.dt,
336
+ n_trials=self.n_trials,
337
+ record_vsec=self.record_vsec,
338
+ record_isec=self.record_isec,
339
+ postproc=self.postproc,
340
+ )
341
+ results["dpl"] = dpl
339
342
 
340
343
  if self.save_spiking:
341
- results['spiking'] = {
342
- 'spike_times': net.cell_response.spike_times,
343
- 'spike_types': net.cell_response.spike_types,
344
- 'spike_gids': net.cell_response.spike_gids
344
+ results["spiking"] = {
345
+ "spike_times": net.cell_response.spike_times,
346
+ "spike_types": net.cell_response.spike_types,
347
+ "spike_gids": net.cell_response.spike_gids,
345
348
  }
346
349
 
347
350
  if self.save_lfp:
348
- results['lfp'] = net.rec_arrays
351
+ results["lfp"] = net.rec_arrays
349
352
 
350
353
  if self.save_voltages:
351
- results['voltages'] = net.cell_response.vsec
354
+ results["voltages"] = net.cell_response.vsec
352
355
 
353
356
  if self.save_currents:
354
- results['currents'] = net.cell_response.isec
357
+ results["currents"] = net.cell_response.isec
355
358
 
356
359
  if self.save_calcium:
357
- results['calcium'] = net.cell_response.ca
360
+ results["calcium"] = net.cell_response.ca
358
361
 
359
362
  return results
360
363
 
@@ -379,11 +382,13 @@ class BatchSimulate(object):
379
382
 
380
383
  keys, values = zip(*param_grid.items())
381
384
  if combinations:
382
- param_combinations = [dict(zip(keys, combination))
383
- for combination in product(*values)]
385
+ param_combinations = [
386
+ dict(zip(keys, combination)) for combination in product(*values)
387
+ ]
384
388
  else:
385
- param_combinations = [dict(zip(keys, combination))
386
- for combination in zip(*values)]
389
+ param_combinations = [
390
+ dict(zip(keys, combination)) for combination in zip(*values)
391
+ ]
387
392
  return param_combinations
388
393
 
389
394
  def _save(self, results, start_idx, end_idx):
@@ -398,37 +403,40 @@ class BatchSimulate(object):
398
403
  end_idx : int
399
404
  The index of the last simulation in this batch.
400
405
  """
401
- _validate_type(results, types=(list,), item_name='results')
402
- _validate_type(start_idx, types='int', item_name='start_idx')
403
- _validate_type(end_idx, types='int', item_name='end_idx')
406
+ _validate_type(results, types=(list,), item_name="results")
407
+ _validate_type(start_idx, types="int", item_name="start_idx")
408
+ _validate_type(end_idx, types="int", item_name="end_idx")
404
409
 
405
410
  if not os.path.exists(self.save_folder):
406
411
  os.makedirs(self.save_folder)
407
412
 
408
- save_data = {
409
- 'param_values': [result['param_values'] for result in results]
410
- }
413
+ save_data = {"param_values": [result["param_values"] for result in results]}
411
414
 
412
- attributes_to_save = ['dpl', 'spiking', 'lfp',
413
- 'voltages', 'currents', 'calcium']
415
+ attributes_to_save = [
416
+ "dpl",
417
+ "spiking",
418
+ "lfp",
419
+ "voltages",
420
+ "currents",
421
+ "calcium",
422
+ ]
414
423
  for attr in attributes_to_save:
415
- if getattr(self, f'save_{attr}') and attr in results[0]:
424
+ if getattr(self, f"save_{attr}") and attr in results[0]:
416
425
  save_data[attr] = [result[attr] for result in results]
417
426
 
418
427
  metadata = {
419
- 'batch_size': self.batch_size,
420
- 'n_trials': self.n_trials,
421
- 'tstop': self.tstop,
422
- 'dt': self.dt
428
+ "batch_size": self.batch_size,
429
+ "n_trials": self.n_trials,
430
+ "tstop": self.tstop,
431
+ "dt": self.dt,
423
432
  }
424
- save_data['metadata'] = metadata
433
+ save_data["metadata"] = metadata
425
434
 
426
- file_name = os.path.join(self.save_folder,
427
- f'sim_run_{start_idx}-{end_idx}.npz')
435
+ file_name = os.path.join(self.save_folder, f"sim_run_{start_idx}-{end_idx}.npz")
428
436
  if os.path.exists(file_name) and not self.overwrite:
429
437
  raise FileExistsError(
430
- f"File {file_name} already exists and "
431
- "overwrite is set to False.")
438
+ f"File {file_name} already exists and overwrite is set to False."
439
+ )
432
440
 
433
441
  np.savez(file_name, **save_data)
434
442
 
@@ -451,21 +459,24 @@ class BatchSimulate(object):
451
459
  if return_data is None:
452
460
  return_data = []
453
461
  if self.save_dpl:
454
- return_data.append('dpl')
462
+ return_data.append("dpl")
455
463
  if self.save_spiking:
456
- return_data.append('spiking')
464
+ return_data.append("spiking")
457
465
  if self.save_lfp:
458
- return_data.append('lfp')
466
+ return_data.append("lfp")
459
467
  if self.save_voltages:
460
- return_data.append('voltages')
468
+ return_data.append("voltages")
461
469
  if self.save_currents:
462
- return_data.append('currents')
470
+ return_data.append("currents")
463
471
  if self.save_calcium:
464
- return_data.append('calcium')
472
+ return_data.append("calcium")
465
473
 
466
474
  data = np.load(file_path, allow_pickle=True)
467
- results = {key: data[key].tolist() for key in data.files
468
- if key in return_data or key == 'param_values'}
475
+ results = {
476
+ key: data[key].tolist()
477
+ for key in data.files
478
+ if key in return_data or key == "param_values"
479
+ }
469
480
  return results
470
481
 
471
482
  def load_all_results(self):
@@ -478,7 +489,7 @@ class BatchSimulate(object):
478
489
  """
479
490
  all_results = []
480
491
  for file_name in os.listdir(self.save_folder):
481
- if file_name.startswith('sim_run_') and file_name.endswith('.npz'):
492
+ if file_name.startswith("sim_run_") and file_name.endswith(".npz"):
482
493
  file_path = os.path.join(self.save_folder, file_name)
483
494
  results = self.load_results(file_path)
484
495
  all_results.append(results)