bluecellulab 2.6.44__tar.gz → 2.6.46__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.
Potentially problematic release.
This version of bluecellulab might be problematic. Click here for more details.
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/PKG-INFO +1 -1
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/injector.py +9 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit_simulation.py +13 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/stimulus/circuit_stimulus_definitions.py +17 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/stimulus/factory.py +102 -5
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/stimulus/stimulus.py +169 -5
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab.egg-info/PKG-INFO +1 -1
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.compile_mod.sh +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.gitattributes +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.github/dependabot.yml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.github/workflows/release.yml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.github/workflows/test.yml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.gitignore +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.gitlab-ci.yml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.readthedocs.yml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/.zenodo.json +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/AUTHORS.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/CHANGELOG.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/CITATION.cff +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/CONTRIBUTING.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/LICENSE +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/MANIFEST.in +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/Makefile +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/README.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/analysis/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/analysis/analysis.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/analysis/inject_sequence.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/analysis/plotting.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/ballstick/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/ballstick/emodel.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/ballstick/morphology.asc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/cell_dict.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/core.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/plotting.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/random.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/recording.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/section_distance.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/serialized_sections.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/sonata_proxy.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/stimuli_generator.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/cell/template.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/circuit_access/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/circuit_access/bluepy_circuit_access.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/circuit_access/definition.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/circuit_access/sonata_circuit_access.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/bluepy_simulation_config.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/definition.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/sections.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/sonata_simulation_config.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/format.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/iotools.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/node_id.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/simulation_access.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/synapse_properties.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/validate.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/connection.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/dendrogram.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/exceptions.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/graph.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/hoc/Cell.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/hoc/RNGSettings.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/hoc/TDistFunc.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/hoc/TStim.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/hoc/fileUtils.hoc +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/importer.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/neuron_interpreter.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/plotwindow.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/psection.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/psegment.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/rngsettings.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/simulation/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/simulation/neuron_globals.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/simulation/parallel.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/simulation/simulation.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/stimulus/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/synapse/__init__.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/synapse/synapse_factory.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/synapse/synapse_types.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/tools.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/type_aliases.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/utils.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/verbosity.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab.egg-info/SOURCES.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab.egg-info/dependency_links.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab.egg-info/requires.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab.egg-info/top_level.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/Makefile +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/images/voltage-readme.png +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/make.bat +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/requirements_docs.txt +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/_static/.gitkeep +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/api.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/changelog.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/compiling-mechanisms.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/conf.py +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/contributing.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/index.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/list_of_stim.rst +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/docs/source/logo/BlueCelluLabBanner.jpg +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/pyproject.toml +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/setup.cfg +0 -0
- {bluecellulab-2.6.44 → bluecellulab-2.6.46}/tox.ini +0 -0
|
@@ -515,3 +515,12 @@ class InjectableMixin:
|
|
|
515
515
|
syn.e = e
|
|
516
516
|
self.persistent.append(syn) # type: ignore
|
|
517
517
|
return syn
|
|
518
|
+
|
|
519
|
+
def add_sinusoidal(self, stimulus) -> TStim:
|
|
520
|
+
"""Inject sinusoidal stimulus for replay."""
|
|
521
|
+
return self.add_sin_current(
|
|
522
|
+
stimulus.amp_start,
|
|
523
|
+
stimulus.delay,
|
|
524
|
+
stimulus.duration,
|
|
525
|
+
stimulus.frequency,
|
|
526
|
+
)
|
|
@@ -139,6 +139,7 @@ class CircuitSimulation:
|
|
|
139
139
|
pre_spike_trains: None | dict[tuple[str, int], Iterable] | dict[int, Iterable] = None,
|
|
140
140
|
add_shotnoise_stimuli: bool = False,
|
|
141
141
|
add_ornstein_uhlenbeck_stimuli: bool = False,
|
|
142
|
+
add_sinusoidal_stimuli: bool = False,
|
|
142
143
|
add_linear_stimuli: bool = False,
|
|
143
144
|
):
|
|
144
145
|
"""Instantiate a list of cells.
|
|
@@ -210,6 +211,11 @@ class CircuitSimulation:
|
|
|
210
211
|
of the simulation config,
|
|
211
212
|
Setting add_stimuli=True,
|
|
212
213
|
will automatically set this option to True.
|
|
214
|
+
add_sinusoidal_stimuli : Process the 'sinusoidal' stimuli
|
|
215
|
+
blocks of the simulation config.
|
|
216
|
+
Setting add_stimuli=True,
|
|
217
|
+
will automatically set this option to
|
|
218
|
+
True.
|
|
213
219
|
add_linear_stimuli : Process the 'linear' stimuli
|
|
214
220
|
blocks of the simulation config.
|
|
215
221
|
Setting add_stimuli=True,
|
|
@@ -271,6 +277,7 @@ class CircuitSimulation:
|
|
|
271
277
|
add_hyperpolarizing_stimuli = True
|
|
272
278
|
add_relativelinear_stimuli = True
|
|
273
279
|
add_pulse_stimuli = True
|
|
280
|
+
add_sinusoidal_stimuli = True
|
|
274
281
|
add_shotnoise_stimuli = True
|
|
275
282
|
add_ornstein_uhlenbeck_stimuli = True
|
|
276
283
|
add_linear_stimuli = True
|
|
@@ -281,6 +288,7 @@ class CircuitSimulation:
|
|
|
281
288
|
add_relativelinear_stimuli or \
|
|
282
289
|
add_shotnoise_stimuli or \
|
|
283
290
|
add_ornstein_uhlenbeck_stimuli or \
|
|
291
|
+
add_sinusoidal_stimuli or \
|
|
284
292
|
add_linear_stimuli:
|
|
285
293
|
self._add_stimuli(
|
|
286
294
|
add_noise_stimuli=add_noise_stimuli,
|
|
@@ -289,6 +297,7 @@ class CircuitSimulation:
|
|
|
289
297
|
add_pulse_stimuli=add_pulse_stimuli,
|
|
290
298
|
add_shotnoise_stimuli=add_shotnoise_stimuli,
|
|
291
299
|
add_ornstein_uhlenbeck_stimuli=add_ornstein_uhlenbeck_stimuli,
|
|
300
|
+
add_sinusoidal_stimuli=add_sinusoidal_stimuli,
|
|
292
301
|
add_linear_stimuli=add_linear_stimuli
|
|
293
302
|
)
|
|
294
303
|
|
|
@@ -298,6 +307,7 @@ class CircuitSimulation:
|
|
|
298
307
|
add_pulse_stimuli=False,
|
|
299
308
|
add_shotnoise_stimuli=False,
|
|
300
309
|
add_ornstein_uhlenbeck_stimuli=False,
|
|
310
|
+
add_sinusoidal_stimuli=False,
|
|
301
311
|
add_linear_stimuli=False
|
|
302
312
|
):
|
|
303
313
|
"""Instantiate all the stimuli."""
|
|
@@ -352,6 +362,9 @@ class CircuitSimulation:
|
|
|
352
362
|
self.cells[cell_id].add_relative_ornstein_uhlenbeck(
|
|
353
363
|
self.cells[cell_id].soma, 0.5, stimulus,
|
|
354
364
|
stim_count=ornstein_uhlenbeck_stim_count)
|
|
365
|
+
elif isinstance(stimulus, circuit_stimulus_definitions.Sinusoidal):
|
|
366
|
+
if add_sinusoidal_stimuli:
|
|
367
|
+
self.cells[cell_id].add_sinusoidal(stimulus)
|
|
355
368
|
elif isinstance(stimulus, circuit_stimulus_definitions.SynapseReplay): # sonata only
|
|
356
369
|
if self.circuit_access.target_contains_cell(
|
|
357
370
|
stimulus.target, cell_id
|
{bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/stimulus/circuit_stimulus_definitions.py
RENAMED
|
@@ -49,6 +49,7 @@ class Pattern(Enum):
|
|
|
49
49
|
RELATIVE_SHOT_NOISE = "relative_shot_noise"
|
|
50
50
|
ORNSTEIN_UHLENBECK = "ornstein_uhlenbeck"
|
|
51
51
|
RELATIVE_ORNSTEIN_UHLENBECK = "relative_ornstein_uhlenbeck"
|
|
52
|
+
SINUSOIDAL = "sinusoidal"
|
|
52
53
|
|
|
53
54
|
@classmethod
|
|
54
55
|
def from_blueconfig(cls, pattern: str) -> Pattern:
|
|
@@ -95,6 +96,8 @@ class Pattern(Enum):
|
|
|
95
96
|
return Pattern.ORNSTEIN_UHLENBECK
|
|
96
97
|
elif pattern == "relative_ornstein_uhlenbeck":
|
|
97
98
|
return Pattern.RELATIVE_ORNSTEIN_UHLENBECK
|
|
99
|
+
elif pattern == "sinusoidal":
|
|
100
|
+
return Pattern.SINUSOIDAL
|
|
98
101
|
else:
|
|
99
102
|
raise ValueError(f"Unknown pattern {pattern}")
|
|
100
103
|
|
|
@@ -313,6 +316,14 @@ class Stimulus:
|
|
|
313
316
|
mode=ClampMode(stimulus_entry.get("input_type", "current_clamp").lower()),
|
|
314
317
|
reversal=stimulus_entry.get("reversal", 0.0)
|
|
315
318
|
)
|
|
319
|
+
elif pattern == Pattern.SINUSOIDAL:
|
|
320
|
+
return Sinusoidal(
|
|
321
|
+
target=stimulus_entry["node_set"],
|
|
322
|
+
delay=stimulus_entry["delay"],
|
|
323
|
+
duration=stimulus_entry["duration"],
|
|
324
|
+
amp_start=stimulus_entry["amp_start"],
|
|
325
|
+
frequency=stimulus_entry["frequency"],
|
|
326
|
+
)
|
|
316
327
|
else:
|
|
317
328
|
raise ValueError(f"Unknown pattern {pattern}")
|
|
318
329
|
|
|
@@ -436,3 +447,9 @@ class RelativeOrnsteinUhlenbeck(Stimulus):
|
|
|
436
447
|
seed: Optional[int] = None
|
|
437
448
|
mode: ClampMode = ClampMode.CURRENT
|
|
438
449
|
reversal: float = 0.0
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
@dataclass(frozen=True, config=dict(extra="forbid"))
|
|
453
|
+
class Sinusoidal(Stimulus):
|
|
454
|
+
amp_start: float
|
|
455
|
+
frequency: float
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
from typing import Optional
|
|
18
18
|
import logging
|
|
19
|
-
from bluecellulab.stimulus.stimulus import DelayedZap, Empty, Ramp, Slope, Step, StepNoise, Stimulus, OrnsteinUhlenbeck, ShotNoise
|
|
20
|
-
from bluecellulab.stimulus.circuit_stimulus_definitions import Stimulus as CircuitStimulus
|
|
19
|
+
from bluecellulab.stimulus.stimulus import DelayedZap, Empty, Ramp, Slope, Step, StepNoise, Stimulus, OrnsteinUhlenbeck, ShotNoise, Sinusoidal, Pulse
|
|
21
20
|
|
|
22
21
|
logger = logging.getLogger(__name__)
|
|
23
22
|
|
|
@@ -376,6 +375,72 @@ class StimulusFactory:
|
|
|
376
375
|
|
|
377
376
|
raise TypeError("You have to give either threshold_current or amplitude")
|
|
378
377
|
|
|
378
|
+
def sinusoidal(
|
|
379
|
+
self,
|
|
380
|
+
pre_delay: float,
|
|
381
|
+
post_delay: float,
|
|
382
|
+
duration: float,
|
|
383
|
+
frequency: float,
|
|
384
|
+
amplitude: Optional[float] = None,
|
|
385
|
+
amplitude_percent: Optional[float] = None,
|
|
386
|
+
threshold_current: Optional[float] = None,
|
|
387
|
+
dt: float = 0.025,
|
|
388
|
+
) -> Stimulus:
|
|
389
|
+
"""Creates a Sinusoidal stimulus (factory-compatible).
|
|
390
|
+
|
|
391
|
+
Args:
|
|
392
|
+
pre_delay: Delay before the sinusoidal stimulus starts (ms).
|
|
393
|
+
post_delay: Delay after the stimulus ends (ms).
|
|
394
|
+
duration: Duration of the stimulus (ms).
|
|
395
|
+
frequency: Frequency of oscillation (Hz).
|
|
396
|
+
amplitude: Absolute amplitude (nA). Used if provided.
|
|
397
|
+
amplitude_percent: Amplitude as a percentage of threshold current.
|
|
398
|
+
threshold_current: Reference threshold current for percentage-based calculation.
|
|
399
|
+
dt: Time step of the stimulus (ms).
|
|
400
|
+
|
|
401
|
+
Returns:
|
|
402
|
+
A `Stimulus` object (Sinusoidal) that can be plotted and injected.
|
|
403
|
+
|
|
404
|
+
Notes:
|
|
405
|
+
- If `amplitude` is provided, `amplitude_percent` is ignored.
|
|
406
|
+
- If `threshold_current` is not provided, threshold-based parameters cannot be used.
|
|
407
|
+
"""
|
|
408
|
+
is_amplitude_based = amplitude is not None
|
|
409
|
+
is_threshold_based = (
|
|
410
|
+
threshold_current is not None
|
|
411
|
+
and threshold_current != 0
|
|
412
|
+
and amplitude_percent is not None
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
if is_amplitude_based:
|
|
416
|
+
if is_threshold_based:
|
|
417
|
+
logger.info(
|
|
418
|
+
"amplitude, threshold_current, and amplitude_percent are all set in Sinusoidal."
|
|
419
|
+
" Using absolute amplitude and ignoring threshold-based parameters."
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
return Sinusoidal.amplitude_based(
|
|
423
|
+
dt=dt,
|
|
424
|
+
pre_delay=pre_delay,
|
|
425
|
+
post_delay=post_delay,
|
|
426
|
+
duration=duration,
|
|
427
|
+
frequency=frequency,
|
|
428
|
+
amplitude=amplitude, # type: ignore[arg-type]
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
if is_threshold_based:
|
|
432
|
+
return Sinusoidal.threshold_based(
|
|
433
|
+
dt=dt,
|
|
434
|
+
pre_delay=pre_delay,
|
|
435
|
+
post_delay=post_delay,
|
|
436
|
+
duration=duration,
|
|
437
|
+
frequency=frequency,
|
|
438
|
+
amplitude_percent=amplitude_percent, # type: ignore[arg-type]
|
|
439
|
+
threshold_current=threshold_current, # type: ignore[arg-type]
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
raise TypeError("You have to provide either `amplitude` or `threshold_current` with `amplitude_percent`.")
|
|
443
|
+
|
|
379
444
|
def ornstein_uhlenbeck(
|
|
380
445
|
self,
|
|
381
446
|
pre_delay: float,
|
|
@@ -612,6 +677,38 @@ class StimulusFactory:
|
|
|
612
677
|
|
|
613
678
|
raise TypeError("You must provide either `mean` and `sigma`, or `threshold_current` and `mean_percent` and `sigma_percent` with percentage values.")
|
|
614
679
|
|
|
615
|
-
def
|
|
616
|
-
|
|
617
|
-
|
|
680
|
+
def pulse(
|
|
681
|
+
self,
|
|
682
|
+
pre_delay: float,
|
|
683
|
+
duration: float,
|
|
684
|
+
post_delay: float,
|
|
685
|
+
frequency: float,
|
|
686
|
+
width: float,
|
|
687
|
+
threshold_current: Optional[float] = None,
|
|
688
|
+
threshold_percentage: Optional[float] = None,
|
|
689
|
+
amplitude: Optional[float] = None,
|
|
690
|
+
) -> Stimulus:
|
|
691
|
+
"""Creates a pulse stimulus.
|
|
692
|
+
|
|
693
|
+
Args:
|
|
694
|
+
threshold_current: The threshold current of the Cell.
|
|
695
|
+
threshold_percentage: Percentage of desired threshold_current amplification.
|
|
696
|
+
amplitude: Raw amplitude of input current.
|
|
697
|
+
pre_delay: Delay before the first pulse (ms).
|
|
698
|
+
duration: Duration of the pulse train (ms).
|
|
699
|
+
post_delay: Delay after the last pulse (ms).
|
|
700
|
+
frequency: Frequency of the pulses (Hz).
|
|
701
|
+
width: Width of each pulse (ms).
|
|
702
|
+
"""
|
|
703
|
+
if amplitude is not None:
|
|
704
|
+
if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
|
|
705
|
+
logger.info(
|
|
706
|
+
"amplitude, threshold_current and threshold_percentage are all set in pulse."
|
|
707
|
+
" Will only keep amplitude value."
|
|
708
|
+
)
|
|
709
|
+
return Pulse.amplitude_based(self.dt, pre_delay, duration, post_delay, amplitude, frequency, width)
|
|
710
|
+
|
|
711
|
+
if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
|
|
712
|
+
return Pulse.threshold_based(self.dt, pre_delay, duration, post_delay, threshold_current, threshold_percentage, frequency, width)
|
|
713
|
+
|
|
714
|
+
raise TypeError("You have to give either threshold_current or amplitude")
|
|
@@ -18,6 +18,7 @@ from abc import ABC, abstractmethod
|
|
|
18
18
|
from typing import Optional
|
|
19
19
|
import logging
|
|
20
20
|
import matplotlib.pyplot as plt
|
|
21
|
+
import neuron
|
|
21
22
|
import numpy as np
|
|
22
23
|
from bluecellulab.cell.stimuli_generator import get_relative_shotnoise_params
|
|
23
24
|
from bluecellulab.exceptions import BluecellulabError
|
|
@@ -57,7 +58,6 @@ class Stimulus(ABC):
|
|
|
57
58
|
ax.plot(self.time, self.current, **kwargs)
|
|
58
59
|
ax.set_xlabel("Time (ms)")
|
|
59
60
|
ax.set_ylabel("Current (nA)")
|
|
60
|
-
ax.set_title(self.__class__.__name__)
|
|
61
61
|
return ax
|
|
62
62
|
|
|
63
63
|
def __add__(self, other: Stimulus) -> CombinedStimulus:
|
|
@@ -203,7 +203,6 @@ class OUProcess(Stimulus):
|
|
|
203
203
|
"""Generates an Ornstein-Uhlenbeck noise signal."""
|
|
204
204
|
from bluecellulab.cell.stimuli_generator import gen_ornstein_uhlenbeck
|
|
205
205
|
from bluecellulab.rngsettings import RNGSettings
|
|
206
|
-
import neuron
|
|
207
206
|
|
|
208
207
|
rng_settings = RNGSettings.get_instance()
|
|
209
208
|
rng = neuron.h.Random()
|
|
@@ -251,7 +250,6 @@ class ShotNoiseProcess(Stimulus):
|
|
|
251
250
|
"""Generates the shot noise time and current vectors."""
|
|
252
251
|
from bluecellulab.cell.stimuli_generator import gen_shotnoise_signal
|
|
253
252
|
from bluecellulab.rngsettings import RNGSettings
|
|
254
|
-
import neuron
|
|
255
253
|
|
|
256
254
|
rng_settings = RNGSettings.get_instance()
|
|
257
255
|
rng = neuron.h.Random()
|
|
@@ -310,12 +308,11 @@ class StepNoiseProcess(Stimulus):
|
|
|
310
308
|
def _generate_step_noise(self):
|
|
311
309
|
"""Generates the step noise time and current vectors using NEURON’s
|
|
312
310
|
random generator."""
|
|
313
|
-
from neuron import h
|
|
314
311
|
from bluecellulab.rngsettings import RNGSettings
|
|
315
312
|
|
|
316
313
|
# Get NEURON RNG settings
|
|
317
314
|
rng_settings = RNGSettings.get_instance()
|
|
318
|
-
rng = h.Random()
|
|
315
|
+
rng = neuron.h.Random()
|
|
319
316
|
|
|
320
317
|
if rng_settings.mode == "Random123":
|
|
321
318
|
seed1, seed2, seed3 = 2997, 19216, self.seed if self.seed else 123
|
|
@@ -341,6 +338,72 @@ class StepNoiseProcess(Stimulus):
|
|
|
341
338
|
return np.array(time_values), np.array(current_values)
|
|
342
339
|
|
|
343
340
|
|
|
341
|
+
class SinusoidalWave(Stimulus):
|
|
342
|
+
"""Generates a sinusoidal current wave."""
|
|
343
|
+
|
|
344
|
+
def __init__(self, dt: float, duration: float, amplitude: float, frequency: float):
|
|
345
|
+
super().__init__(dt)
|
|
346
|
+
self.duration = duration
|
|
347
|
+
self.amplitude = amplitude
|
|
348
|
+
self.frequency = frequency
|
|
349
|
+
|
|
350
|
+
self._time, self._current = self._generate_sinusoidal_signal()
|
|
351
|
+
|
|
352
|
+
@property
|
|
353
|
+
def time(self) -> np.ndarray:
|
|
354
|
+
return self._time
|
|
355
|
+
|
|
356
|
+
@property
|
|
357
|
+
def current(self) -> np.ndarray:
|
|
358
|
+
return self._current
|
|
359
|
+
|
|
360
|
+
def _generate_sinusoidal_signal(self):
|
|
361
|
+
"""Generate the sinusoidal waveform."""
|
|
362
|
+
tvec = neuron.h.Vector()
|
|
363
|
+
tvec.indgen(0.0, self.duration, self.dt) # Time points using NEURON
|
|
364
|
+
|
|
365
|
+
stim = neuron.h.Vector(len(tvec))
|
|
366
|
+
stim.sin(self.frequency, 0.0, self.dt) # Generate sinusoidal wave using NEURON
|
|
367
|
+
stim.mul(self.amplitude) # Scale by amplitude
|
|
368
|
+
|
|
369
|
+
return np.array(tvec.to_python()), np.array(stim.to_python())
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
class PulseTrain(Stimulus):
|
|
373
|
+
"""Generates a pulse train signal."""
|
|
374
|
+
|
|
375
|
+
def __init__(self, dt: float, duration: float, amplitude: float, frequency: float, width: float):
|
|
376
|
+
super().__init__(dt)
|
|
377
|
+
self.duration = duration
|
|
378
|
+
self.amplitude = amplitude
|
|
379
|
+
self.frequency = frequency
|
|
380
|
+
self.width = width
|
|
381
|
+
|
|
382
|
+
self._time, self._current = self._generate_pulse_train()
|
|
383
|
+
|
|
384
|
+
@property
|
|
385
|
+
def time(self) -> np.ndarray:
|
|
386
|
+
return self._time
|
|
387
|
+
|
|
388
|
+
@property
|
|
389
|
+
def current(self) -> np.ndarray:
|
|
390
|
+
return self._current
|
|
391
|
+
|
|
392
|
+
def _generate_pulse_train(self):
|
|
393
|
+
total_duration = self.duration
|
|
394
|
+
time_steps = int(total_duration / self.dt)
|
|
395
|
+
time = np.linspace(0, total_duration, time_steps)
|
|
396
|
+
current = np.zeros_like(time)
|
|
397
|
+
|
|
398
|
+
start_time = 0
|
|
399
|
+
while start_time + self.width < self.duration:
|
|
400
|
+
pulse_indices = (time >= start_time) & (time < start_time + self.width)
|
|
401
|
+
current[pulse_indices] = self.amplitude
|
|
402
|
+
start_time += 1000.0 / self.frequency
|
|
403
|
+
|
|
404
|
+
return time, current
|
|
405
|
+
|
|
406
|
+
|
|
344
407
|
class Step(Stimulus):
|
|
345
408
|
|
|
346
409
|
def __init__(self):
|
|
@@ -780,3 +843,104 @@ class StepNoise(Stimulus):
|
|
|
780
843
|
sigma=sigma,
|
|
781
844
|
seed=seed,
|
|
782
845
|
)
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
class Sinusoidal(Stimulus):
|
|
849
|
+
"""Factory-compatible Sinusoidal Stimulus."""
|
|
850
|
+
|
|
851
|
+
def __init__(self):
|
|
852
|
+
"""Prevents direct instantiation."""
|
|
853
|
+
raise NotImplementedError(
|
|
854
|
+
"This class cannot be instantiated directly. "
|
|
855
|
+
"Please use 'amplitude_based' or 'threshold_based' methods."
|
|
856
|
+
)
|
|
857
|
+
|
|
858
|
+
@classmethod
|
|
859
|
+
def amplitude_based(
|
|
860
|
+
cls,
|
|
861
|
+
dt: float,
|
|
862
|
+
pre_delay: float,
|
|
863
|
+
duration: float,
|
|
864
|
+
post_delay: float,
|
|
865
|
+
amplitude: float,
|
|
866
|
+
frequency: float,
|
|
867
|
+
) -> CombinedStimulus:
|
|
868
|
+
"""Creates a sinusoidal stimulus with a specified amplitude.
|
|
869
|
+
|
|
870
|
+
Args:
|
|
871
|
+
dt: Time step of the stimulus.
|
|
872
|
+
pre_delay: Delay before the sinusoidal wave starts.
|
|
873
|
+
duration: Duration of the sinusoidal signal.
|
|
874
|
+
post_delay: Delay after the wave ends.
|
|
875
|
+
amplitude: Amplitude of the sinusoidal wave.
|
|
876
|
+
frequency: Frequency of the wave in Hz.
|
|
877
|
+
"""
|
|
878
|
+
return (
|
|
879
|
+
Empty(dt, duration=pre_delay)
|
|
880
|
+
+ SinusoidalWave(dt, duration, amplitude, frequency)
|
|
881
|
+
+ Empty(dt, duration=post_delay)
|
|
882
|
+
)
|
|
883
|
+
|
|
884
|
+
@classmethod
|
|
885
|
+
def threshold_based(
|
|
886
|
+
cls,
|
|
887
|
+
dt: float,
|
|
888
|
+
pre_delay: float,
|
|
889
|
+
duration: float,
|
|
890
|
+
post_delay: float,
|
|
891
|
+
frequency: float,
|
|
892
|
+
threshold_current: float,
|
|
893
|
+
amplitude_percent: float,
|
|
894
|
+
) -> CombinedStimulus:
|
|
895
|
+
"""Creates a sinusoidal stimulus relative to the threshold current.
|
|
896
|
+
|
|
897
|
+
Args:
|
|
898
|
+
dt: Time step of the stimulus.
|
|
899
|
+
pre_delay: Delay before the sinusoidal wave starts.
|
|
900
|
+
duration: Duration of the sinusoidal signal.
|
|
901
|
+
post_delay: Delay after the wave ends.
|
|
902
|
+
frequency: Frequency of the wave in Hz.
|
|
903
|
+
threshold_current: Baseline threshold current.
|
|
904
|
+
amplitude_percent: Amplitude as a percentage of the threshold current.
|
|
905
|
+
"""
|
|
906
|
+
amplitude = (amplitude_percent / 100) * threshold_current
|
|
907
|
+
|
|
908
|
+
return cls.amplitude_based(
|
|
909
|
+
dt,
|
|
910
|
+
pre_delay=pre_delay,
|
|
911
|
+
duration=duration,
|
|
912
|
+
post_delay=post_delay,
|
|
913
|
+
amplitude=amplitude,
|
|
914
|
+
frequency=frequency,
|
|
915
|
+
)
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
class Pulse(Stimulus):
|
|
919
|
+
"""Factory-compatible Pulse Stimulus."""
|
|
920
|
+
|
|
921
|
+
def __init__(self):
|
|
922
|
+
"""Prevents direct instantiation of the class."""
|
|
923
|
+
raise NotImplementedError(
|
|
924
|
+
"This class cannot be instantiated directly. "
|
|
925
|
+
"Please use 'amplitude_based' or 'threshold_based' methods."
|
|
926
|
+
)
|
|
927
|
+
|
|
928
|
+
@classmethod
|
|
929
|
+
def amplitude_based(
|
|
930
|
+
cls, dt: float, pre_delay: float, duration: float, post_delay: float, amplitude: float, frequency: float, width: float
|
|
931
|
+
) -> CombinedStimulus:
|
|
932
|
+
"""Creates a Pulse stimulus from given time events and amplitude."""
|
|
933
|
+
return (
|
|
934
|
+
Empty(dt, duration=pre_delay)
|
|
935
|
+
+ PulseTrain(dt, duration, amplitude, frequency, width)
|
|
936
|
+
+ Empty(dt, duration=post_delay)
|
|
937
|
+
)
|
|
938
|
+
|
|
939
|
+
@classmethod
|
|
940
|
+
def threshold_based(
|
|
941
|
+
cls, dt: float, pre_delay: float, duration: float, post_delay: float, threshold_current: float, threshold_percentage: float,
|
|
942
|
+
frequency: float, width: float
|
|
943
|
+
) -> CombinedStimulus:
|
|
944
|
+
"""Creates a Pulse stimulus with respect to the threshold current."""
|
|
945
|
+
amplitude = threshold_current * (threshold_percentage / 100)
|
|
946
|
+
return cls.amplitude_based(dt, pre_delay, duration, post_delay, amplitude, frequency, width)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/circuit_access/definition.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/bluepy_simulation_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bluecellulab-2.6.44 → bluecellulab-2.6.46}/bluecellulab/circuit/config/sonata_simulation_config.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|