bluecellulab 2.4.1__py3-none-any.whl → 2.5.3__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/__init__.py CHANGED
@@ -8,9 +8,9 @@ except ImportError:
8
8
  BLUEPY_AVAILABLE = False
9
9
 
10
10
  from .importer import * # NOQA
11
- from .tools import * # NOQA
12
11
  from .verbosity import *
13
12
  from .cell import Cell, create_ball_stick # NOQA
13
+ from .circuit import EmodelProperties
14
14
  from .connection import Connection # NOQA
15
15
  from .plotwindow import PlotWindow # NOQA
16
16
  from .dendrogram import Dendrogram # NOQA
@@ -19,3 +19,10 @@ from .psegment import PSegment # NOQA
19
19
  from .simulation import Simulation # NOQA
20
20
  from .rngsettings import RNGSettings # NOQA
21
21
  from .ssim import SSim # NOQA
22
+
23
+
24
+ from .simulation.neuron_globals import NeuronGlobals
25
+
26
+ logger.debug("Loading the hoc files.")
27
+ import_hoc(neuron)
28
+ _ = NeuronGlobals.get_instance() # initiate the singleton
bluecellulab/cell/core.py CHANGED
@@ -39,7 +39,7 @@ from bluecellulab.circuit import EmodelProperties, SynapseProperty
39
39
  from bluecellulab.circuit.node_id import CellId
40
40
  from bluecellulab.circuit.simulation_access import get_synapse_replay_spikes
41
41
  from bluecellulab.exceptions import BluecellulabError
42
- from bluecellulab.importer import load_hoc_and_mod_files
42
+ from bluecellulab.importer import load_mod_files
43
43
  from bluecellulab.neuron_interpreter import eval_neuron
44
44
  from bluecellulab.rngsettings import RNGSettings
45
45
  from bluecellulab.stimulus.circuit_stimulus_definitions import SynapseReplay
@@ -73,7 +73,7 @@ class Cell(InjectableMixin, PlottableMixin):
73
73
  emodel_properties=template_params.emodel_properties,
74
74
  )
75
75
 
76
- @load_hoc_and_mod_files
76
+ @load_mod_files
77
77
  def __init__(self,
78
78
  template_path: str | Path,
79
79
  morphology_path: str | Path,
@@ -191,29 +191,10 @@ class Cell(InjectableMixin, PlottableMixin):
191
191
  """Connect this cell to a circuit via sonata proxy."""
192
192
  self.sonata_proxy = sonata_proxy
193
193
 
194
- def re_init_rng(self, use_random123_stochkv: bool = False) -> None:
194
+ def re_init_rng(self) -> None:
195
195
  """Reinitialize the random number generator for stochastic channels."""
196
-
197
196
  if not self.is_made_passive:
198
- if use_random123_stochkv:
199
- channel_id = 0
200
- for section in self.somatic:
201
- for seg in section:
202
- neuron.h.setdata_StochKv(seg.x, sec=section)
203
- neuron.h.setRNG_StochKv(channel_id, self.cell_id.id)
204
- channel_id += 1
205
- for section in self.basal:
206
- for seg in section:
207
- neuron.h.setdata_StochKv(seg.x, sec=section)
208
- neuron.h.setRNG_StochKv(channel_id, self.cell_id.id)
209
- channel_id += 1
210
- for section in self.apical:
211
- for seg in section:
212
- neuron.h.setdata_StochKv(seg.x, sec=section)
213
- neuron.h.setRNG_StochKv(channel_id, self.cell_id.id)
214
- channel_id += 1
215
- else:
216
- self.cell.re_init_rng()
197
+ self.cell.re_init_rng()
217
198
 
218
199
  def get_psection(self, section_id: int | str) -> PSection:
219
200
  """Return a python section with the specified section id."""
bluecellulab/importer.py CHANGED
@@ -52,8 +52,8 @@ def import_mod_lib(neuron: ModuleType) -> str:
52
52
  return res
53
53
 
54
54
 
55
- def import_neurodamus(neuron: ModuleType) -> None:
56
- """Import neurodamus."""
55
+ def import_hoc(neuron: ModuleType) -> None:
56
+ """Import hoc dependencies."""
57
57
  neuron.h.load_file("stdrun.hoc") # nrn
58
58
  hoc_files = [
59
59
  "Cell.hoc", # ND
@@ -75,17 +75,15 @@ def print_header(neuron: ModuleType, mod_lib_path: str) -> None:
75
75
 
76
76
 
77
77
  @run_once
78
- def _load_hoc_and_mod_files() -> None:
78
+ def _load_mod_files() -> None:
79
79
  """Import hoc and mod files."""
80
80
  logger.debug("Loading the mod files.")
81
81
  mod_lib_paths = import_mod_lib(neuron)
82
- logger.debug("Loading the hoc files.")
83
- import_neurodamus(neuron)
84
82
  print_header(neuron, mod_lib_paths)
85
83
 
86
84
 
87
- def load_hoc_and_mod_files(func):
85
+ def load_mod_files(func):
88
86
  def wrapper(*args, **kwargs):
89
- _load_hoc_and_mod_files()
87
+ _load_mod_files()
90
88
  return func(*args, **kwargs)
91
89
  return wrapper
@@ -20,7 +20,7 @@ from typing import Optional
20
20
  import neuron
21
21
  from bluecellulab.circuit.config.definition import SimulationConfig
22
22
  from bluecellulab.exceptions import UndefinedRNGException
23
- from bluecellulab.importer import load_hoc_and_mod_files
23
+ from bluecellulab.importer import load_mod_files
24
24
 
25
25
  logger = logging.getLogger(__name__)
26
26
 
@@ -37,7 +37,7 @@ class RNGSettings:
37
37
  cls._instance = cls()
38
38
  return cls._instance
39
39
 
40
- @load_hoc_and_mod_files
40
+ @load_mod_files
41
41
  def __init__(
42
42
  self,
43
43
  mode="Random123",
@@ -3,4 +3,3 @@
3
3
  from .simulation import Simulation
4
4
  from .neuron_globals import set_global_condition_parameters
5
5
  from .neuron_globals import set_minis_single_vesicle_values
6
- from .neuron_globals import set_tstop_value
@@ -62,6 +62,37 @@ def set_minis_single_vesicle_values(mech_conditions: MechanismConditions) -> Non
62
62
  )
63
63
 
64
64
 
65
- def set_tstop_value(tstop: float) -> None:
66
- """Set the tstop value required by Tstim noise stimuli."""
67
- neuron.h.tstop = tstop
65
+ class NeuronGlobals:
66
+ _instance = None
67
+
68
+ def __init__(self):
69
+ raise RuntimeError('Call get_instance() instead')
70
+
71
+ @classmethod
72
+ def get_instance(cls):
73
+ if cls._instance is None:
74
+ cls._instance = cls.__new__(cls)
75
+ # Initialize default values
76
+ cls._instance._temperature = 34.0 # Default temperature
77
+ cls._instance.v_init = neuron.h.v_init
78
+ # Set the default values in NEURON
79
+ neuron.h.celsius = cls._instance._temperature
80
+ return cls._instance
81
+
82
+ @property
83
+ def temperature(self):
84
+ return self._temperature
85
+
86
+ @temperature.setter
87
+ def temperature(self, value):
88
+ self._temperature = value
89
+ neuron.h.celsius = value
90
+
91
+ @property
92
+ def v_init(self):
93
+ return self._v_init
94
+
95
+ @v_init.setter
96
+ def v_init(self, value):
97
+ self._v_init = value
98
+ neuron.h.v_init = value
@@ -88,13 +88,11 @@ class Simulation:
88
88
  cvode=True,
89
89
  cvode_minstep=None,
90
90
  cvode_maxstep=None,
91
- celsius=34,
92
- v_init=-65,
93
91
  dt=0.025,
94
92
  forward_skip=None,
95
93
  forward_skip_value=False,
96
- show_progress=None,
97
- use_random123_stochkv=False):
94
+ show_progress=None
95
+ ):
98
96
  """Run the simulation."""
99
97
  # if maxtime <= neuron.h.t:
100
98
  # raise Exception("Simulation: need to provide a maxtime (=%f) "
@@ -108,7 +106,6 @@ class Simulation:
108
106
  self.progress_dt = maxtime / 100
109
107
  self.init_progress_callback()
110
108
 
111
- neuron.h.celsius = celsius
112
109
  neuron.h.tstop = maxtime
113
110
 
114
111
  cvode_old_status = neuron.h.cvode_active()
@@ -125,11 +122,9 @@ class Simulation:
125
122
  "was set")
126
123
  neuron.h.cvode_active(0)
127
124
 
128
- neuron.h.v_init = v_init
129
-
130
125
  for cell in self.cells:
131
126
  with contextlib.suppress(AttributeError):
132
- cell.re_init_rng(use_random123_stochkv=use_random123_stochkv)
127
+ cell.re_init_rng()
133
128
  neuron.h.dt = dt
134
129
  neuron.h.steps_per_ms = 1.0 / dt
135
130
 
@@ -176,6 +171,3 @@ class Simulation:
176
171
  neuron.h.cvode_active(cvode_old_status)
177
172
 
178
173
  logger.debug("Finished simulation.")
179
-
180
- def __del__(self):
181
- pass
bluecellulab/ssim.py CHANGED
@@ -39,14 +39,14 @@ from bluecellulab.circuit.config import SimulationConfig
39
39
  from bluecellulab.circuit.format import determine_circuit_format, CircuitFormat
40
40
  from bluecellulab.circuit.node_id import create_cell_id, create_cell_ids
41
41
  from bluecellulab.circuit.simulation_access import BluepySimulationAccess, SimulationAccess, SonataSimulationAccess, _sample_array
42
- from bluecellulab.importer import load_hoc_and_mod_files
42
+ from bluecellulab.importer import load_mod_files
43
43
  from bluecellulab.rngsettings import RNGSettings
44
+ from bluecellulab.simulation.neuron_globals import NeuronGlobals
44
45
  from bluecellulab.stimulus.circuit_stimulus_definitions import Noise, OrnsteinUhlenbeck, RelativeOrnsteinUhlenbeck, RelativeShotNoise, ShotNoise
45
46
  import bluecellulab.stimulus.circuit_stimulus_definitions as circuit_stimulus_definitions
46
47
  from bluecellulab.exceptions import BluecellulabError
47
48
  from bluecellulab.simulation import (
48
49
  set_global_condition_parameters,
49
- set_tstop_value
50
50
  )
51
51
  from bluecellulab.synapse.synapse_types import SynapseID
52
52
 
@@ -56,7 +56,7 @@ logger = logging.getLogger(__name__)
56
56
  class SSim:
57
57
  """Class that loads a circuit simulation to do cell simulations."""
58
58
 
59
- @load_hoc_and_mod_files
59
+ @load_mod_files
60
60
  def __init__(
61
61
  self,
62
62
  simulation_config: str | Path | SimulationConfig,
@@ -106,11 +106,6 @@ class SSim:
106
106
 
107
107
  self.gids_instantiated = False
108
108
 
109
- # Make sure tstop is set correctly, because it is used by the
110
- # TStim noise stimulus
111
- if self.circuit_access.config.duration is not None:
112
- set_tstop_value(self.circuit_access.config.duration)
113
-
114
109
  self.spike_threshold = self.circuit_access.config.spike_threshold
115
110
  self.spike_location = self.circuit_access.config.spike_location
116
111
 
@@ -596,8 +591,10 @@ class SSim:
596
591
  forward_skip_value = self.circuit_access.config.forward_skip
597
592
  if celsius is None:
598
593
  celsius = self.circuit_access.config.celsius
594
+ NeuronGlobals.get_instance().temperature = celsius
599
595
  if v_init is None:
600
596
  v_init = self.circuit_access.config.v_init
597
+ NeuronGlobals.get_instance().v_init = v_init
601
598
 
602
599
  sim = bluecellulab.Simulation(self.pc)
603
600
  for cell_id in self.cells:
@@ -612,8 +609,6 @@ class SSim:
612
609
  t_stop,
613
610
  cvode=cvode,
614
611
  dt=dt,
615
- celsius=celsius,
616
- v_init=v_init,
617
612
  forward_skip=forward_skip,
618
613
  forward_skip_value=forward_skip_value,
619
614
  show_progress=show_progress)
bluecellulab/tools.py CHANGED
@@ -60,6 +60,8 @@ def calculate_SS_voltage(
60
60
  template_format: str,
61
61
  emodel_properties: EmodelProperties | None,
62
62
  step_level: float,
63
+ check_for_spiking=False,
64
+ spike_threshold=-20.0,
63
65
  ) -> float:
64
66
  """Calculate the steady state voltage at a certain current step."""
65
67
  with IsolatedProcess() as runner:
@@ -71,6 +73,8 @@ def calculate_SS_voltage(
71
73
  template_format,
72
74
  emodel_properties,
73
75
  step_level,
76
+ check_for_spiking,
77
+ spike_threshold,
74
78
  ],
75
79
  )
76
80
  return SS_voltage
@@ -82,8 +86,8 @@ def calculate_SS_voltage_subprocess(
82
86
  template_format: str,
83
87
  emodel_properties: EmodelProperties | None,
84
88
  step_level: float,
85
- check_for_spiking=False,
86
- spike_threshold=-20.0,
89
+ check_for_spiking: bool,
90
+ spike_threshold: float,
87
91
  ) -> float:
88
92
  """Subprocess wrapper of calculate_SS_voltage.
89
93
 
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bluecellulab
3
- Version: 2.4.1
3
+ Version: 2.5.3
4
4
  Summary: The Pythonic Blue Brain simulator access
5
- Home-page: https://github.com/BlueBrain/BlueCelluLab
6
5
  Author: Blue Brain Project, EPFL
7
6
  License: Apache2.0
8
- Keywords: computational neuroscience,simulation,analysis,parameters,Blue Brain Project
7
+ Project-URL: Homepage, https://github.com/BlueBrain/BlueCelluLab
8
+ Project-URL: Documentation, https://bluecellulab.readthedocs.io/
9
+ Keywords: computational neuroscience,simulation,analysis,SONATA,neural networks,neuron,Blue Brain Project
9
10
  Classifier: Development Status :: 5 - Production/Stable
10
11
  Classifier: Environment :: Console
11
12
  Classifier: License :: OSI Approved :: Apache Software License
@@ -1,16 +1,16 @@
1
- bluecellulab/__init__.py,sha256=lYxUZtN_mLNUPJgBnKd4GbwDIVScDPD6ouC7OvWQxS0,645
1
+ bluecellulab/__init__.py,sha256=yC97iFnCVDtwqspxdpt4C-qq9vQF7AMJOWe1h_cB0Wc,827
2
2
  bluecellulab/connection.py,sha256=volV2YKtmqAF7MOEJar5ldF1ARAo7k2vF9MB1NXybUY,4640
3
3
  bluecellulab/dendrogram.py,sha256=w0vvv0Q169DolTX1j9dAZIvHIl4H258gAjQ1xQaNiGk,6427
4
4
  bluecellulab/exceptions.py,sha256=KIxF7s_7gPVJ07TiQ-Z1D8de7ylV74gNMhzl0339CVM,2379
5
5
  bluecellulab/graph.py,sha256=ODiQy4xjRVxtNITXeXpYnqHas0wR7gZ_aXuDAF7jMq4,3419
6
- bluecellulab/importer.py,sha256=l5nvD0y41-AheqoDNBGAX5qFTCG6_UFlLmqyFbUo77E,2998
6
+ bluecellulab/importer.py,sha256=zwVi1Nx2f8xzFfzxzYoXa7gfi7DQapqkRJII5sBbRyY,2900
7
7
  bluecellulab/neuron_interpreter.py,sha256=hXig_u3T6JmEHbkV8ZblEZtX0kY80ate4VpRtANNFrM,2185
8
8
  bluecellulab/plotwindow.py,sha256=UVHzml-BB83m5Qr-YGkjR9kB-vSW8mM0Owh2j95yIaU,2721
9
9
  bluecellulab/psection.py,sha256=EgAS8IS9DcYv2xOkNISgfg_CfRc0nDfRFjvgQhyi9eY,6328
10
10
  bluecellulab/psegment.py,sha256=rBryDYHC_uDK9itfXXrFZ0DL9F6WgRICL0j5EHN56QM,3125
11
- bluecellulab/rngsettings.py,sha256=qjwnzAEdbRt66DKd_NTD2OZnlu4hDH7UUOXxd0G9c_Q,4244
12
- bluecellulab/ssim.py,sha256=U8HFKso4lQkKowts_x2DQfG3ihR56KcN0ITeTlGu3hI,33533
13
- bluecellulab/tools.py,sha256=tS9a9VDMQOVw6zIllT3FxPIzQk4xheNlGf8lpIg01FY,10931
11
+ bluecellulab/rngsettings.py,sha256=KACk4ujPXhlHL9iAoTdAjjLuFEcUoG6aes92ZClSoQQ,4228
12
+ bluecellulab/ssim.py,sha256=radFcT2lWRfb1C0zKlqw0JQ6JY4b9LJiDP9JDPeQIqs,33399
13
+ bluecellulab/tools.py,sha256=8QMNdmh9lRDOWT4kz9cI_MYNVh4ulxgY8CtHZbaMbkA,11056
14
14
  bluecellulab/type_aliases.py,sha256=DvgjERv2Ztdw_sW63JrZTQGpJ0x5uMTFB5hcBHDb0WA,441
15
15
  bluecellulab/utils.py,sha256=fgqjgy3xzyL0zu-qjCPJdHp6PEAHADCzlr2FqyBmzHI,2012
16
16
  bluecellulab/verbosity.py,sha256=T0IgX7DrRo19faxrT4Xzb27gqxzoILQ8FzYKxvUeaPM,1342
@@ -18,7 +18,7 @@ bluecellulab/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
18
18
  bluecellulab/analysis/inject_sequence.py,sha256=jfEESRAUKAWgjceNWfx3Rwe1gDNWhxwZL4PfnJZCzrg,4930
19
19
  bluecellulab/cell/__init__.py,sha256=Sbc0QOsJ8E7tSwf3q7fsXuE_SevBN6ZmoCVyyU5zfII,208
20
20
  bluecellulab/cell/cell_dict.py,sha256=PVmZsjhZ9jp3HC-8QmdFqp-crAcVMSVeLWujcOPLlpo,1346
21
- bluecellulab/cell/core.py,sha256=r_9nq9MBm-VM-oZQc2KN3a4GxFRYgWy9AF-XpjMIDAE,32156
21
+ bluecellulab/cell/core.py,sha256=uxAWAZ6NpODJ3O77p0JWL6AVey3lOyetU3SVZxP4a9Q,31201
22
22
  bluecellulab/cell/injector.py,sha256=XC49VSHw78xCHzLJKO_-unnnVZAZXsYg5qbmZPx01AA,18091
23
23
  bluecellulab/cell/plotting.py,sha256=_hZs5oYG4vmJBVf05cJ2O_cVazi5Eap8OkL9BtIwjW8,4001
24
24
  bluecellulab/cell/random.py,sha256=FDby9BN4eJT27COwHP59bhDE2v-c6rdOKNFj3cYZTVY,1773
@@ -52,18 +52,18 @@ bluecellulab/hoc/RNGSettings.hoc,sha256=okJBdqlPXET8BrpG1Q31GdaxHfpe3CE0L5P7MAhf
52
52
  bluecellulab/hoc/TDistFunc.hoc,sha256=WKX-anvL83xGuGPH9g1oIORB17UM4Pi3-iIXzKO-pUQ,2663
53
53
  bluecellulab/hoc/TStim.hoc,sha256=noBJbM_ZqF6T6MEgBeowNzz21I9QeYZ5brGgUvCSm4k,8473
54
54
  bluecellulab/hoc/fileUtils.hoc,sha256=LSM7BgyjYVqo2DGSOKvg4W8IIusbsL45JVYK0vgwitU,2539
55
- bluecellulab/simulation/__init__.py,sha256=G1md-6mqaYQkfZT8pmzqRi3WW1fMQCgkeaela2kX3OM,258
56
- bluecellulab/simulation/neuron_globals.py,sha256=PuAxrXbr734RP-5q6YkHpnOgzTVyo_8SYZux9HABlaI,3348
57
- bluecellulab/simulation/simulation.py,sha256=tM5Psl-w25CHA4hp2fqs3GcZ2HSjIbu_6iyOcs-1jd8,6439
55
+ bluecellulab/simulation/__init__.py,sha256=P2ebt0SFw-08J3ihN-LeRn95HeF79tzA-Q0ReLm32dM,214
56
+ bluecellulab/simulation/neuron_globals.py,sha256=uxgceZ7zzbVEtITrQv8oOK900zhh7w29cScFwjLWo4I,4134
57
+ bluecellulab/simulation/simulation.py,sha256=I__cZwV_A8I7XSefn6aJDBA_jXCI3E35-pCNCLUsnvo,6206
58
58
  bluecellulab/stimulus/__init__.py,sha256=DgIgVaSyR-URf3JZzvO6j-tjCerzvktuK-ep8pjMRPQ,37
59
59
  bluecellulab/stimulus/circuit_stimulus_definitions.py,sha256=uij_s44uNdmMwMLGmTHSRgmp9K9B_vvHHshX6YPJNJU,15686
60
60
  bluecellulab/stimulus/factory.py,sha256=AOby3Sp2g8BJsRccz3afazfCyysyWIgLtcliWlyeiu0,8097
61
61
  bluecellulab/synapse/__init__.py,sha256=RW8XoAMXOvK7OG1nHl_q8jSEKLj9ZN4oWf2nY9HAwuk,192
62
62
  bluecellulab/synapse/synapse_factory.py,sha256=YkvxbdGF-u-vxYdbRNTlX-9AtSC_3t_FQRFhybwzgrk,6805
63
63
  bluecellulab/synapse/synapse_types.py,sha256=4gne-hve2vq1Lau-LAVPsfLjffVYqAYBW3kCfC7_600,16871
64
- bluecellulab-2.4.1.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
65
- bluecellulab-2.4.1.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
66
- bluecellulab-2.4.1.dist-info/METADATA,sha256=7Ug3ADUg1_1XIbqRyQ07KaSb512jch3wiaxRKsxkXPY,6907
67
- bluecellulab-2.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
68
- bluecellulab-2.4.1.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
69
- bluecellulab-2.4.1.dist-info/RECORD,,
64
+ bluecellulab-2.5.3.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
65
+ bluecellulab-2.5.3.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
66
+ bluecellulab-2.5.3.dist-info/METADATA,sha256=rYhJTsxGMFuS6MWaiwkByBjBpVxemuA3GoybjU0PgSM,7003
67
+ bluecellulab-2.5.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
68
+ bluecellulab-2.5.3.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
69
+ bluecellulab-2.5.3.dist-info/RECORD,,