bluecellulab 2.6.38__py3-none-any.whl → 2.6.40__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.
- bluecellulab/analysis/analysis.py +63 -0
- bluecellulab/analysis/plotting.py +25 -0
- bluecellulab/tools.py +74 -0
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/METADATA +2 -2
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/RECORD +9 -7
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/AUTHORS.txt +0 -0
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/LICENSE +0 -0
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/WHEEL +0 -0
- {bluecellulab-2.6.38.dist-info → bluecellulab-2.6.40.dist-info}/top_level.txt +0 -0
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: bluecellulab
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.40
|
|
4
4
|
Summary: Biologically detailed neural network simulations and analysis.
|
|
5
5
|
Author: Blue Brain Project, EPFL
|
|
6
6
|
License: Apache2.0
|
|
@@ -178,7 +178,7 @@ The licenses of the morphology files used in this repository are available on: h
|
|
|
178
178
|
.. |license| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
|
|
179
179
|
:target: https://github.com/openbraininstitute/BlueCelluLab/blob/main/LICENSE
|
|
180
180
|
|
|
181
|
-
.. |tests| image:: https://github.com/openbraininstitute/BlueCelluLab/actions/workflows/test.yml/badge.svg
|
|
181
|
+
.. |tests| image:: https://github.com/openbraininstitute/BlueCelluLab/actions/workflows/test.yml/badge.svg
|
|
182
182
|
:target: https://github.com/openbraininstitute/BlueCelluLab/actions/workflows/test.yml
|
|
183
183
|
:alt: CI
|
|
184
184
|
|
|
@@ -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=
|
|
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.
|
|
66
|
-
bluecellulab-2.6.
|
|
67
|
-
bluecellulab-2.6.
|
|
68
|
-
bluecellulab-2.6.
|
|
69
|
-
bluecellulab-2.6.
|
|
70
|
-
bluecellulab-2.6.
|
|
67
|
+
bluecellulab-2.6.40.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
|
|
68
|
+
bluecellulab-2.6.40.dist-info/LICENSE,sha256=dAMAR2Sud4Nead1wGFleKiwTZfkTNZbzmuGfcTKb3kg,11335
|
|
69
|
+
bluecellulab-2.6.40.dist-info/METADATA,sha256=njZWcGPzkEh3qeWnbwZjBnnc_Fb4Dv6F41nWH5wNnL4,8213
|
|
70
|
+
bluecellulab-2.6.40.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
71
|
+
bluecellulab-2.6.40.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
|
|
72
|
+
bluecellulab-2.6.40.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|