bluecellulab 2.6.37__py3-none-any.whl → 2.6.39__py3-none-any.whl

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.

Potentially problematic release.


This version of bluecellulab might be problematic. Click here for more details.

@@ -0,0 +1,63 @@
1
+ """Module for analyzing cell simulation results."""
2
+ try:
3
+ import efel
4
+ except ImportError:
5
+ efel = None
6
+ import numpy as np
7
+
8
+ from bluecellulab.stimulus import StimulusFactory
9
+ from bluecellulab.tools import calculate_rheobase
10
+ from bluecellulab.analysis.inject_sequence import run_stimulus
11
+ from bluecellulab.analysis.plotting import plot_iv_curve
12
+
13
+
14
+ def compute_plot_iv_curve(cell, stim_start=100.0, duration=500.0, post_delay=100.0, threshold_voltage=-30, nb_bins=11):
15
+ """Compute and plot the IV curve from a given cell by injecting a
16
+ predefined range of currents.
17
+
18
+ Args:
19
+ cell (bluecellulab.cell.Cell): The initialized cell model.
20
+ stim_start (float): Start time for current injection (in ms). Default is 100.0 ms.
21
+ duration (float): Duration of current injection (in ms). Default is 500.0 ms.
22
+ post_delay (float): Delay after the stimulation ends (in ms). Default is 100.0 ms.
23
+ nb_bins (int): Number of current injection levels. Default is 11.
24
+
25
+ Returns:
26
+ tuple: A tuple containing:
27
+ - list_amp (np.ndarray): The predefined injected step current levels (nA).
28
+ - steady_states (np.ndarray): The corresponding steady-state voltages (mV).
29
+ """
30
+ rheobase = calculate_rheobase(cell)
31
+
32
+ list_amp = np.linspace(rheobase - 2, rheobase - 0.1, nb_bins) # [nA]
33
+
34
+ steps = []
35
+ times = []
36
+ voltages = []
37
+ # inject step current and record voltage response
38
+ for amp in list_amp:
39
+ stim_factory = StimulusFactory(dt=0.1)
40
+ step_stimulus = stim_factory.step(pre_delay=stim_start, duration=duration, post_delay=post_delay, amplitude=amp)
41
+ recording = run_stimulus(cell.template_params, step_stimulus, section="soma[0]", segment=0.5)
42
+ steps.append(step_stimulus)
43
+ times.append(recording.time)
44
+ voltages.append(recording.voltage)
45
+
46
+ steady_states = []
47
+ # compute steady state response
48
+ efel.set_setting('Threshold', threshold_voltage)
49
+ for voltage, t in zip(voltages, times):
50
+ trace = {
51
+ 'T': t,
52
+ 'V': voltage,
53
+ 'stim_start': [stim_start],
54
+ 'stim_end': [stim_start + duration]
55
+ }
56
+ features_results = efel.get_feature_values([trace], ['steady_state_voltage_stimend'])
57
+ steady_state = features_results[0]['steady_state_voltage_stimend']
58
+ steady_states.append(steady_state)
59
+
60
+ # plot I-V curve
61
+ plot_iv_curve(list_amp, steady_states)
62
+
63
+ return np.array(list_amp), np.array(steady_states)
@@ -0,0 +1,25 @@
1
+ """Module for plotting analysis results of cell simulations."""
2
+
3
+ import matplotlib.pyplot as plt
4
+
5
+
6
+ def plot_iv_curve(currents, voltages):
7
+ """Plots the IV curve.
8
+
9
+ Args:
10
+ currents (iterable): The injected current levels (nA).
11
+ voltages (iterable): The corresponding steady-state voltages (mV).
12
+ Raises:
13
+ ValueError: If the lengths of currents and voltages do not match.
14
+ """
15
+ if len(currents) != len(voltages):
16
+ raise ValueError("currents and voltages must have the same length")
17
+
18
+ # Plotting
19
+ plt.figure(figsize=(10, 6))
20
+ plt.plot(voltages, currents, marker='o', linestyle='-', color='b')
21
+ plt.title("I-V Curve")
22
+ plt.ylabel("Injected current [nA]")
23
+ plt.xlabel("Steady state voltage [mV]")
24
+ plt.tight_layout()
25
+ plt.show()
bluecellulab/tools.py CHANGED
@@ -23,6 +23,7 @@ import neuron
23
23
  import numpy as np
24
24
 
25
25
  import bluecellulab
26
+ from bluecellulab.cell import Cell
26
27
  from bluecellulab.circuit.circuit_access import EmodelProperties
27
28
  from bluecellulab.exceptions import UnsteadyCellError
28
29
  from bluecellulab.simulation.parallel import IsolatedProcess
@@ -351,3 +352,76 @@ def check_empty_topology() -> bool:
351
352
  neuron.h.topology()
352
353
 
353
354
  return stdout == ['', '']
355
+
356
+
357
+ def calculate_max_thresh_current(cell: Cell, threshold_voltage: float = -30.0) -> float:
358
+ """Calculate the upper bound threshold current.
359
+
360
+ Args:
361
+ cell (bluecellulab.cell.Cell): The initialized cell model.
362
+ threshold_voltage (float, optional): Voltage threshold for spike detection. Default is -30.0 mV.
363
+
364
+ Returns:
365
+ float: The upper bound threshold current.
366
+ """
367
+ # Calculate resting membrane potential (rmp)
368
+ rmp = calculate_SS_voltage(
369
+ template_path=cell.template_params.template_filepath,
370
+ morphology_path=cell.template_params.morph_filepath,
371
+ template_format=cell.template_params.template_format,
372
+ emodel_properties=cell.template_params.emodel_properties,
373
+ step_level=0.0,
374
+ )
375
+
376
+ # Calculate input resistance (rin)
377
+ rin = calculate_input_resistance(
378
+ template_path=cell.template_params.template_filepath,
379
+ morphology_path=cell.template_params.morph_filepath,
380
+ template_format=cell.template_params.template_format,
381
+ emodel_properties=cell.template_params.emodel_properties,
382
+ )
383
+
384
+ # Calculate upperbound threshold current
385
+ upperbound_threshold_current = (threshold_voltage - rmp) / rin
386
+ upperbound_threshold_current = np.min([upperbound_threshold_current, 2.0])
387
+
388
+ return upperbound_threshold_current
389
+
390
+
391
+ def calculate_rheobase(cell: Cell,
392
+ threshold_voltage: float = -30.0,
393
+ threshold_search_stim_start: float = 300.0,
394
+ threshold_search_stim_stop: float = 1000.0) -> float:
395
+ """Calculate the rheobase by first computing the upper bound threshold
396
+ current.
397
+
398
+ Args:
399
+ cell (bluecellulab.cell.Cell): The initialized cell model.
400
+ threshold_voltage (float, optional): Voltage threshold for spike detection. Default is -30.0 mV.
401
+ threshold_search_stim_start (float, optional): Start time for threshold search stimulation (in ms). Default is 300.0 ms.
402
+ threshold_search_stim_stop (float, optional): Stop time for threshold search stimulation (in ms). Default is 1000.0 ms.
403
+
404
+ Returns:
405
+ float: The rheobase current.
406
+ """
407
+ if cell.template_params.emodel_properties is None:
408
+ raise ValueError("emodel_properties cannot be None")
409
+
410
+ # Calculate upper bound threshold current
411
+ upperbound_threshold_current = calculate_max_thresh_current(cell, threshold_voltage)
412
+
413
+ # Compute rheobase
414
+ rheobase = search_threshold_current(
415
+ template_name=cell.template_params.template_filepath,
416
+ morphology_path=cell.template_params.morph_filepath,
417
+ template_format=cell.template_params.template_format,
418
+ emodel_properties=cell.template_params.emodel_properties,
419
+ hyp_level=cell.template_params.emodel_properties.holding_current,
420
+ inj_start=threshold_search_stim_start,
421
+ inj_stop=threshold_search_stim_stop,
422
+ min_current=cell.template_params.emodel_properties.holding_current,
423
+ max_current=upperbound_threshold_current,
424
+ current_precision=0.005,
425
+ )
426
+
427
+ return rheobase
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bluecellulab
3
- Version: 2.6.37
3
+ Version: 2.6.39
4
4
  Summary: Biologically detailed neural network simulations and analysis.
5
5
  Author: Blue Brain Project, EPFL
6
6
  License: Apache2.0
7
- Project-URL: Homepage, https://github.com/BlueBrain/BlueCelluLab
7
+ Project-URL: Homepage, https://github.com/openbraininstitute/BlueCelluLab
8
8
  Project-URL: Documentation, https://bluecellulab.readthedocs.io/
9
9
  Keywords: computational neuroscience,simulation,analysis,SONATA,neural networks,neuron,Blue Brain Project
10
10
  Classifier: Development Status :: 5 - Production/Stable
@@ -14,7 +14,7 @@ Classifier: Operating System :: POSIX
14
14
  Classifier: Topic :: Scientific/Engineering
15
15
  Classifier: Programming Language :: Python :: 3
16
16
  Classifier: Topic :: Utilities
17
- Requires-Python: >=3.8
17
+ Requires-Python: >=3.9
18
18
  Description-Content-Type: text/x-rst
19
19
  License-File: LICENSE
20
20
  License-File: AUTHORS.txt
@@ -91,12 +91,12 @@ If you need to cite a specific version, please use the DOI provided by `Zenodo <
91
91
  Support
92
92
  =======
93
93
 
94
- We are providing support on `Gitter <https://gitter.im/BlueBrain/BlueCelluLab>`_. We suggest you create tickets on the `Github issue tracker <https://github.com/BlueBrain/BlueCelluLab/issues>`_ in case you encounter problems while using the software or if you have some suggestions.
94
+ We are providing support on `Gitter <https://gitter.im/openbraininstitute/BlueCelluLab>`_. We suggest you create tickets on the `Github issue tracker <https://github.com/openbraininstitute/BlueCelluLab/issues>`_ in case you encounter problems while using the software or if you have some suggestions.
95
95
 
96
96
  Main dependencies
97
97
  =================
98
98
 
99
- * `Python 3.8+ <https://www.python.org/downloads/release/python-380/>`_
99
+ * `Python 3.9+ <https://www.python.org/downloads/release/python-390/>`_
100
100
  * `Neuron 8.0.2+ <https://pypi.org/project/NEURON/>`_
101
101
 
102
102
  Installation
@@ -127,13 +127,13 @@ The following example shows how to create a cell, add a stimulus and run a simul
127
127
  time, voltage = cell.get_time(), cell.get_soma_voltage()
128
128
  # plotting time and voltage ...
129
129
 
130
- .. image:: https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/main/docs/images/voltage-readme.png
130
+ .. image:: https://raw.githubusercontent.com/openbraininstitute/BlueCelluLab/main/docs/images/voltage-readme.png
131
131
  :alt: Voltage plot
132
132
 
133
133
  Tutorial
134
134
  ========
135
135
 
136
- A more detailed explanation on how to use BlueCelluLab, as well as other examples can be found on the `examples page <https://github.com/BlueBrain/BlueCelluLab/blob/main/examples/README.rst>`_.
136
+ A more detailed explanation on how to use BlueCelluLab, as well as other examples can be found on the `examples page <https://github.com/openbraininstitute/BlueCelluLab/blob/main/examples/README.rst>`_.
137
137
 
138
138
  API Documentation
139
139
  =================
@@ -155,7 +155,7 @@ Testing is set up using `tox`:
155
155
  Contributing
156
156
  ============
157
157
 
158
- We welcome contributions to BlueCelluLab! Please see the `CONTRIBUTING.rst <https://github.com/BlueBrain/BlueCelluLab/blob/main/CONTRIBUTING.rst>`_ for guidelines on how to contribute.
158
+ We welcome contributions to BlueCelluLab! Please see the `CONTRIBUTING.rst <https://github.com/openbraininstitute/BlueCelluLab/blob/main/CONTRIBUTING.rst>`_ for guidelines on how to contribute.
159
159
 
160
160
  Funding & Acknowledgements
161
161
  ==========================
@@ -166,6 +166,7 @@ Copyright
166
166
  =========
167
167
 
168
168
  Copyright (c) 2023-2024 Blue Brain Project/EPFL
169
+ Copyright (c) 2025 Open Brain Institute
169
170
 
170
171
  This work is licensed under `Apache 2.0 <https://www.apache.org/licenses/LICENSE-2.0.html>`_
171
172
 
@@ -175,10 +176,10 @@ The licenses of the morphology files used in this repository are available on: h
175
176
 
176
177
 
177
178
  .. |license| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
178
- :target: https://github.com/BlueBrain/BlueCelluLab/blob/main/LICENSE
179
+ :target: https://github.com/openbraininstitute/BlueCelluLab/blob/main/LICENSE
179
180
 
180
- .. |tests| image:: https://github.com/BlueBrain/BlueCelluLab/actions/workflows/test.yml/badge.svg?branch=main
181
- :target: https://github.com/BlueBrain/BlueCelluLab/actions/workflows/test.yml
181
+ .. |tests| image:: https://github.com/openbraininstitute/BlueCelluLab/actions/workflows/test.yml/badge.svg?branch=main
182
+ :target: https://github.com/openbraininstitute/BlueCelluLab/actions/workflows/test.yml
182
183
  :alt: CI
183
184
 
184
185
  .. |pypi| image:: https://img.shields.io/pypi/v/bluecellulab.svg
@@ -189,13 +190,13 @@ The licenses of the morphology files used in this repository are available on: h
189
190
  :target: https://bluecellulab.readthedocs.io/
190
191
  :alt: latest documentation
191
192
 
192
- .. |coverage| image:: https://codecov.io/github/BlueBrain/BlueCelluLab/coverage.svg?branch=main
193
- :target: https://codecov.io/gh/BlueBrain/bluecellulab
193
+ .. |coverage| image:: https://codecov.io/github/openbraininstitute/BlueCelluLab/coverage.svg?branch=main
194
+ :target: https://codecov.io/gh/openbraininstitute/bluecellulab
194
195
  :alt: coverage
195
196
 
196
197
  .. |gitter| image:: https://badges.gitter.im/Join%20Chat.svg
197
- :target: https://gitter.im/BlueBrain/BlueCelluLab
198
- :alt: Join the chat at https://gitter.im/BlueBrain/BlueCelluLab
198
+ :target: https://gitter.im/openbraininstitute/BlueCelluLab
199
+ :alt: Join the chat at https://gitter.im/openbraininstitute/BlueCelluLab
199
200
 
200
201
  .. |joss| image:: https://joss.theoj.org/papers/effd553ca48734a2966d9d7ace3b05ff/status.svg
201
202
  :target: https://joss.theoj.org/papers/effd553ca48734a2966d9d7ace3b05ff
@@ -212,4 +213,4 @@ The licenses of the morphology files used in this repository are available on: h
212
213
  to skip content after the marker 'substitutions'.
213
214
 
214
215
  .. substitutions
215
- .. |banner| image:: https://raw.githubusercontent.com/BlueBrain/BlueCelluLab/main/docs/source/logo/BlueCelluLabBanner.jpg
216
+ .. |banner| image:: https://raw.githubusercontent.com/openbraininstitute/BlueCelluLab/main/docs/source/logo/BlueCelluLabBanner.jpg
@@ -10,12 +10,14 @@ bluecellulab/plotwindow.py,sha256=ePU-EegZ1Sqk0SoYYiQ6k24ZO4s3Hgfpx10uePiJ5xM,27
10
10
  bluecellulab/psection.py,sha256=FSOwRNuOTyB469BM-jPEf9l1J59FamXmzrQgBI6cnP4,6174
11
11
  bluecellulab/psegment.py,sha256=PTgoGLqM4oFIdF_8QHFQCU59j-8TQmtq6PakiGUQhIo,3138
12
12
  bluecellulab/rngsettings.py,sha256=2Ykb4Ylk3XTs58x1UIxjg8XJqjSpnCgKRZ8avXCDpxk,4237
13
- bluecellulab/tools.py,sha256=ytziurCwhp2iuiwhYrr4yk7PywikDL8Hk-Knx5CYFK8,11213
13
+ bluecellulab/tools.py,sha256=LgfP2NNm7dVbig2NFx3FFJXCbVpvK8BkighUoyKVPp8,14321
14
14
  bluecellulab/type_aliases.py,sha256=DvgjERv2Ztdw_sW63JrZTQGpJ0x5uMTFB5hcBHDb0WA,441
15
15
  bluecellulab/utils.py,sha256=SbOOkzw1YGjCKV3qOw0zpabNEy7V9BRtgMLsQJiFRq4,1526
16
16
  bluecellulab/verbosity.py,sha256=T0IgX7DrRo19faxrT4Xzb27gqxzoILQ8FzYKxvUeaPM,1342
17
17
  bluecellulab/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ bluecellulab/analysis/analysis.py,sha256=i64iVNF7-0cCneKP4OjdyNHdhxtixjTFiJiSXK4FHLs,2508
18
19
  bluecellulab/analysis/inject_sequence.py,sha256=Ih3wdNRn0-lM-NW8agrMUGS862CEgzn_hl54DFDXyjM,6325
20
+ bluecellulab/analysis/plotting.py,sha256=X2llERRPB9aDMbtw96RzMFfUQFXTKVMwmQ5lEkGWLlQ,791
19
21
  bluecellulab/cell/__init__.py,sha256=Sbc0QOsJ8E7tSwf3q7fsXuE_SevBN6ZmoCVyyU5zfII,208
20
22
  bluecellulab/cell/cell_dict.py,sha256=VE7pi-NsMVRSmo-PSdbiLYmolDOu0Gc6JxFBkuQpFdk,1346
21
23
  bluecellulab/cell/core.py,sha256=QzCC2uVj1yOSLi3-dGN3Iib9POTNRGNJSnjvJue1T5g,31315
@@ -62,9 +64,9 @@ bluecellulab/stimulus/factory.py,sha256=L85RN-lImkyCEM87Pp1X5rpGNIHLNSMwx1b9dZxO
62
64
  bluecellulab/synapse/__init__.py,sha256=RW8XoAMXOvK7OG1nHl_q8jSEKLj9ZN4oWf2nY9HAwuk,192
63
65
  bluecellulab/synapse/synapse_factory.py,sha256=NHwRMYMrnRVm_sHmyKTJ1bdoNmWZNU4UPOGu7FCi-PE,6987
64
66
  bluecellulab/synapse/synapse_types.py,sha256=zs_yBvGTH4QrbQF3nEViidyq1WM_ZcTSFdjUxB3khW0,16871
65
- bluecellulab-2.6.37.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
66
- bluecellulab-2.6.37.dist-info/LICENSE,sha256=dAMAR2Sud4Nead1wGFleKiwTZfkTNZbzmuGfcTKb3kg,11335
67
- bluecellulab-2.6.37.dist-info/METADATA,sha256=WjdGXa3ealMZkID135lo2fl2gcDNyHz5TBpUJlAoQ3I,8059
68
- bluecellulab-2.6.37.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
69
- bluecellulab-2.6.37.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
70
- bluecellulab-2.6.37.dist-info/RECORD,,
67
+ bluecellulab-2.6.39.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
68
+ bluecellulab-2.6.39.dist-info/LICENSE,sha256=dAMAR2Sud4Nead1wGFleKiwTZfkTNZbzmuGfcTKb3kg,11335
69
+ bluecellulab-2.6.39.dist-info/METADATA,sha256=hkRo4sSq0ypIDM0HXvM8gn8MlomPoCqhy66-Se40IWM,8225
70
+ bluecellulab-2.6.39.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
71
+ bluecellulab-2.6.39.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
72
+ bluecellulab-2.6.39.dist-info/RECORD,,