bluecellulab 2.6.13__py3-none-any.whl → 2.6.14__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.

@@ -74,6 +74,7 @@ def apply_multiple_stimuli(
74
74
  cell: Cell,
75
75
  stimulus_name: StimulusName,
76
76
  amplitudes: Sequence[float],
77
+ threshold_based: bool = True,
77
78
  section_name: str | None = None,
78
79
  segment: float = 0.5,
79
80
  n_processes: int | None = None,
@@ -84,6 +85,8 @@ def apply_multiple_stimuli(
84
85
  cell: The cell to which the stimuli are applied.
85
86
  stimulus_name: The name of the stimulus to apply.
86
87
  amplitudes: The amplitudes of the stimuli to apply.
88
+ threshold_based: Whether to consider amplitudes to be
89
+ threshold percentages or to be raw amplitudes.
87
90
  section_name: Section name of the cell where the stimuli are applied.
88
91
  If None, the stimuli are applied at the soma[0] of the cell.
89
92
  segment: The segment of the section where the stimuli are applied.
@@ -103,18 +106,37 @@ def apply_multiple_stimuli(
103
106
 
104
107
  # Prepare arguments for each stimulus
105
108
  for amplitude in amplitudes:
109
+ if threshold_based:
110
+ thres_perc = amplitude
111
+ amp = None
112
+ else:
113
+ thres_perc = None
114
+ amp = amplitude
115
+
106
116
  if stimulus_name == StimulusName.AP_WAVEFORM:
107
- stimulus = stim_factory.ap_waveform(threshold_current=cell.threshold, threshold_percentage=amplitude)
117
+ stimulus = stim_factory.ap_waveform(
118
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
119
+ )
108
120
  elif stimulus_name == StimulusName.IDREST:
109
- stimulus = stim_factory.idrest(threshold_current=cell.threshold, threshold_percentage=amplitude)
121
+ stimulus = stim_factory.idrest(
122
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
123
+ )
110
124
  elif stimulus_name == StimulusName.IV:
111
- stimulus = stim_factory.iv(threshold_current=cell.threshold, threshold_percentage=amplitude)
125
+ stimulus = stim_factory.iv(
126
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
127
+ )
112
128
  elif stimulus_name == StimulusName.FIRE_PATTERN:
113
- stimulus = stim_factory.fire_pattern(threshold_current=cell.threshold, threshold_percentage=amplitude)
129
+ stimulus = stim_factory.fire_pattern(
130
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
131
+ )
114
132
  elif stimulus_name == StimulusName.POS_CHEOPS:
115
- stimulus = stim_factory.pos_cheops(threshold_current=cell.threshold, threshold_percentage=amplitude)
133
+ stimulus = stim_factory.pos_cheops(
134
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
135
+ )
116
136
  elif stimulus_name == StimulusName.NEG_CHEOPS:
117
- stimulus = stim_factory.neg_cheops(threshold_current=cell.threshold, threshold_percentage=amplitude)
137
+ stimulus = stim_factory.neg_cheops(
138
+ threshold_current=cell.threshold, threshold_percentage=thres_perc, amplitude=amp
139
+ )
118
140
  else:
119
141
  raise ValueError("Unknown stimulus name.")
120
142
 
@@ -1,8 +1,12 @@
1
1
  from __future__ import annotations
2
2
  from abc import ABC, abstractmethod
3
+ from typing import Optional
4
+ import logging
3
5
  import matplotlib.pyplot as plt
4
6
  import numpy as np
5
7
 
8
+ logger = logging.getLogger(__name__)
9
+
6
10
 
7
11
  class Stimulus(ABC):
8
12
  def __init__(self, dt: float) -> None:
@@ -299,99 +303,182 @@ class StimulusFactory:
299
303
  )
300
304
 
301
305
  def ap_waveform(
302
- self, threshold_current: float, threshold_percentage: float = 220.0
306
+ self,
307
+ threshold_current: Optional[float] = None,
308
+ threshold_percentage: Optional[float] = 220.0,
309
+ amplitude: Optional[float] = None,
303
310
  ) -> Stimulus:
304
311
  """Returns the APWaveform Stimulus object, a type of Step stimulus.
305
312
 
306
313
  Args:
307
314
  threshold_current: The threshold current of the Cell.
308
315
  threshold_percentage: Percentage of desired threshold_current amplification.
316
+ amplitude: Raw amplitude of input current.
309
317
  """
310
318
  pre_delay = 250.0
311
319
  duration = 50.0
312
320
  post_delay = 250.0
313
- return Step.threshold_based(
314
- self.dt,
315
- pre_delay=pre_delay,
316
- duration=duration,
317
- post_delay=post_delay,
318
- threshold_current=threshold_current,
319
- threshold_percentage=threshold_percentage,
320
- )
321
+
322
+ if amplitude is not None:
323
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
324
+ logger.info(
325
+ "amplitude, threshold_current and threshold_percentage are all set in ap_waveform."
326
+ " Will only keep amplitude value."
327
+ )
328
+ return Step.amplitude_based(
329
+ self.dt,
330
+ pre_delay=pre_delay,
331
+ duration=duration,
332
+ post_delay=post_delay,
333
+ amplitude=amplitude,
334
+ )
335
+
336
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
337
+ return Step.threshold_based(
338
+ self.dt,
339
+ pre_delay=pre_delay,
340
+ duration=duration,
341
+ post_delay=post_delay,
342
+ threshold_current=threshold_current,
343
+ threshold_percentage=threshold_percentage,
344
+ )
345
+
346
+ raise TypeError("You have to give either threshold_current or amplitude")
321
347
 
322
348
  def idrest(
323
349
  self,
324
- threshold_current: float,
325
- threshold_percentage: float = 200.0,
350
+ threshold_current: Optional[float] = None,
351
+ threshold_percentage: Optional[float] = 200.0,
352
+ amplitude: Optional[float] = None,
326
353
  ) -> Stimulus:
327
354
  """Returns the IDRest Stimulus object, a type of Step stimulus.
328
355
 
329
356
  Args:
330
357
  threshold_current: The threshold current of the Cell.
331
358
  threshold_percentage: Percentage of desired threshold_current amplification.
359
+ amplitude: Raw amplitude of input current.
332
360
  """
333
361
  pre_delay = 250.0
334
362
  duration = 1350.0
335
363
  post_delay = 250.0
336
- return Step.threshold_based(
337
- self.dt,
338
- pre_delay=pre_delay,
339
- duration=duration,
340
- post_delay=post_delay,
341
- threshold_current=threshold_current,
342
- threshold_percentage=threshold_percentage,
343
- )
364
+
365
+ if amplitude is not None:
366
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
367
+ logger.info(
368
+ "amplitude, threshold_current and threshold_percentage are all set in idrest."
369
+ " Will only keep amplitude value."
370
+ )
371
+ return Step.amplitude_based(
372
+ self.dt,
373
+ pre_delay=pre_delay,
374
+ duration=duration,
375
+ post_delay=post_delay,
376
+ amplitude=amplitude,
377
+ )
378
+
379
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
380
+ return Step.threshold_based(
381
+ self.dt,
382
+ pre_delay=pre_delay,
383
+ duration=duration,
384
+ post_delay=post_delay,
385
+ threshold_current=threshold_current,
386
+ threshold_percentage=threshold_percentage,
387
+ )
388
+
389
+ raise TypeError("You have to give either threshold_current or amplitude")
344
390
 
345
391
  def iv(
346
392
  self,
347
- threshold_current: float,
348
- threshold_percentage: float = -40.0,
393
+ threshold_current: Optional[float] = None,
394
+ threshold_percentage: Optional[float] = -40.0,
395
+ amplitude: Optional[float] = None,
349
396
  ) -> Stimulus:
350
397
  """Returns the IV Stimulus object, a type of Step stimulus.
351
398
 
352
399
  Args:
353
400
  threshold_current: The threshold current of the Cell.
354
401
  threshold_percentage: Percentage of desired threshold_current amplification.
402
+ amplitude: Raw amplitude of input current.
355
403
  """
356
404
  pre_delay = 250.0
357
405
  duration = 3000.0
358
406
  post_delay = 250.0
359
- return Step.threshold_based(
360
- self.dt,
361
- pre_delay=pre_delay,
362
- duration=duration,
363
- post_delay=post_delay,
364
- threshold_current=threshold_current,
365
- threshold_percentage=threshold_percentage,
366
- )
407
+
408
+ if amplitude is not None:
409
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
410
+ logger.info(
411
+ "amplitude, threshold_current and threshold_percentage are all set in iv."
412
+ " Will only keep amplitude value."
413
+ )
414
+ return Step.amplitude_based(
415
+ self.dt,
416
+ pre_delay=pre_delay,
417
+ duration=duration,
418
+ post_delay=post_delay,
419
+ amplitude=amplitude,
420
+ )
421
+
422
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
423
+ return Step.threshold_based(
424
+ self.dt,
425
+ pre_delay=pre_delay,
426
+ duration=duration,
427
+ post_delay=post_delay,
428
+ threshold_current=threshold_current,
429
+ threshold_percentage=threshold_percentage,
430
+ )
431
+
432
+ raise TypeError("You have to give either threshold_current or amplitude")
367
433
 
368
434
  def fire_pattern(
369
435
  self,
370
- threshold_current: float,
371
- threshold_percentage: float = 200.0,
436
+ threshold_current: Optional[float] = None,
437
+ threshold_percentage: Optional[float] = 200.0,
438
+ amplitude: Optional[float] = None,
372
439
  ) -> Stimulus:
373
440
  """Returns the FirePattern Stimulus object, a type of Step stimulus.
374
441
 
375
442
  Args:
376
443
  threshold_current: The threshold current of the Cell.
377
444
  threshold_percentage: Percentage of desired threshold_current amplification.
445
+ amplitude: Raw amplitude of input current.
378
446
  """
379
447
  pre_delay = 250.0
380
448
  duration = 3600.0
381
449
  post_delay = 250.0
382
- return Step.threshold_based(
383
- self.dt,
384
- pre_delay=pre_delay,
385
- duration=duration,
386
- post_delay=post_delay,
387
- threshold_current=threshold_current,
388
- threshold_percentage=threshold_percentage,
389
- )
450
+
451
+ if amplitude is not None:
452
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
453
+ logger.info(
454
+ "amplitude, threshold_current and threshold_percentage are all set in fire_pattern."
455
+ " Will only keep amplitude value."
456
+ )
457
+ return Step.amplitude_based(
458
+ self.dt,
459
+ pre_delay=pre_delay,
460
+ duration=duration,
461
+ post_delay=post_delay,
462
+ amplitude=amplitude,
463
+ )
464
+
465
+ if threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
466
+ return Step.threshold_based(
467
+ self.dt,
468
+ pre_delay=pre_delay,
469
+ duration=duration,
470
+ post_delay=post_delay,
471
+ threshold_current=threshold_current,
472
+ threshold_percentage=threshold_percentage,
473
+ )
474
+
475
+ raise TypeError("You have to give either threshold_current or amplitude")
390
476
 
391
477
  def pos_cheops(
392
478
  self,
393
- threshold_current: float,
394
- threshold_percentage: float = 300.0,
479
+ threshold_current: Optional[float] = None,
480
+ threshold_percentage: Optional[float] = 300.0,
481
+ amplitude: Optional[float] = None,
395
482
  ) -> Stimulus:
396
483
  """A combination of pyramid shaped Ramp stimuli with a positive
397
484
  amplitude.
@@ -399,6 +486,7 @@ class StimulusFactory:
399
486
  Args:
400
487
  threshold_current: The threshold current of the Cell.
401
488
  threshold_percentage: Percentage of desired threshold_current amplification.
489
+ amplitude: Raw amplitude of input current.
402
490
  """
403
491
  delay = 250.0
404
492
  ramp1_duration = 4000.0
@@ -407,7 +495,15 @@ class StimulusFactory:
407
495
  inter_delay = 2000.0
408
496
  post_delay = 250.0
409
497
 
410
- amplitude = threshold_current * threshold_percentage / 100
498
+ if amplitude is None:
499
+ if threshold_current is None or threshold_current == 0 or threshold_percentage is None:
500
+ raise TypeError("You have to give either threshold_current or amplitude")
501
+ amplitude = threshold_current * threshold_percentage / 100
502
+ elif threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
503
+ logger.info(
504
+ "amplitude, threshold_current and threshold_percentage are all set in pos_cheops."
505
+ " Will only keep amplitude value."
506
+ )
411
507
  result = (
412
508
  Empty(self.dt, duration=delay)
413
509
  + Slope(self.dt, duration=ramp1_duration, amplitude_start=0.0, amplitude_end=amplitude)
@@ -424,8 +520,9 @@ class StimulusFactory:
424
520
 
425
521
  def neg_cheops(
426
522
  self,
427
- threshold_current: float,
428
- threshold_percentage: float = 300.0,
523
+ threshold_current: Optional[float] = None,
524
+ threshold_percentage: Optional[float] = 300.0,
525
+ amplitude: Optional[float] = None,
429
526
  ) -> Stimulus:
430
527
  """A combination of pyramid shaped Ramp stimuli with a negative
431
528
  amplitude.
@@ -433,6 +530,7 @@ class StimulusFactory:
433
530
  Args:
434
531
  threshold_current: The threshold current of the Cell.
435
532
  threshold_percentage: Percentage of desired threshold_current amplification.
533
+ amplitude: Raw amplitude of input current.
436
534
  """
437
535
  delay = 1750.0
438
536
  ramp1_duration = 3333.0
@@ -441,7 +539,15 @@ class StimulusFactory:
441
539
  inter_delay = 2000.0
442
540
  post_delay = 250.0
443
541
 
444
- amplitude = - threshold_current * threshold_percentage / 100
542
+ if amplitude is None:
543
+ if threshold_current is None or threshold_current == 0 or threshold_percentage is None:
544
+ raise TypeError("You have to give either threshold_current or amplitude")
545
+ amplitude = - threshold_current * threshold_percentage / 100
546
+ elif threshold_current is not None and threshold_current != 0 and threshold_percentage is not None:
547
+ logger.info(
548
+ "amplitude, threshold_current and threshold_percentage are all set in neg_cheops."
549
+ " Will only keep amplitude value."
550
+ )
445
551
  result = (
446
552
  Empty(self.dt, duration=delay)
447
553
  + Slope(self.dt, duration=ramp1_duration, amplitude_start=0.0, amplitude_end=amplitude)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bluecellulab
3
- Version: 2.6.13
3
+ Version: 2.6.14
4
4
  Summary: Biologically detailed neural network simulations and analysis.
5
5
  Author: Blue Brain Project, EPFL
6
6
  License: Apache2.0
@@ -15,7 +15,7 @@ bluecellulab/type_aliases.py,sha256=DvgjERv2Ztdw_sW63JrZTQGpJ0x5uMTFB5hcBHDb0WA,
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/inject_sequence.py,sha256=Kgs-Be6CtRc9LI1qsM7mC4oGfpW6VrqGPHSuoa7XFYs,5148
18
+ bluecellulab/analysis/inject_sequence.py,sha256=K3166jDTikEMMfRPJvuqfC6VPdUfyK7Ua7_M9Tr6uZg,5738
19
19
  bluecellulab/cell/__init__.py,sha256=Sbc0QOsJ8E7tSwf3q7fsXuE_SevBN6ZmoCVyyU5zfII,208
20
20
  bluecellulab/cell/cell_dict.py,sha256=PVmZsjhZ9jp3HC-8QmdFqp-crAcVMSVeLWujcOPLlpo,1346
21
21
  bluecellulab/cell/core.py,sha256=ZVzy3tsA5X7OyCmnHQn0d6AlNg9rOG2ojKuojvKdsFw,31487
@@ -58,13 +58,13 @@ bluecellulab/simulation/parallel.py,sha256=oQ_oV2EKr8gP4yF2Dq8q9MiblDyi89_wBgLzQ
58
58
  bluecellulab/simulation/simulation.py,sha256=I__cZwV_A8I7XSefn6aJDBA_jXCI3E35-pCNCLUsnvo,6206
59
59
  bluecellulab/stimulus/__init__.py,sha256=DgIgVaSyR-URf3JZzvO6j-tjCerzvktuK-ep8pjMRPQ,37
60
60
  bluecellulab/stimulus/circuit_stimulus_definitions.py,sha256=uij_s44uNdmMwMLGmTHSRgmp9K9B_vvHHshX6YPJNJU,15686
61
- bluecellulab/stimulus/factory.py,sha256=hoq5JA69eX4bAdtOJNErhBn_p0uQh8QPoFvCqqeGBN4,14874
61
+ bluecellulab/stimulus/factory.py,sha256=XDbnqCuMCh1RdZLKvlRucMj3wkXDqy6mEda_Oh6Yqo4,19955
62
62
  bluecellulab/synapse/__init__.py,sha256=RW8XoAMXOvK7OG1nHl_q8jSEKLj9ZN4oWf2nY9HAwuk,192
63
63
  bluecellulab/synapse/synapse_factory.py,sha256=MjUorWoMl4lFSBgQw4QS09Dzh0-LYWlCHJKYy8N-d3w,6847
64
64
  bluecellulab/synapse/synapse_types.py,sha256=4gne-hve2vq1Lau-LAVPsfLjffVYqAYBW3kCfC7_600,16871
65
- bluecellulab-2.6.13.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
66
- bluecellulab-2.6.13.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
67
- bluecellulab-2.6.13.dist-info/METADATA,sha256=pMdxyVSGeRMoo0di8GdJVhrkW_1kd6OTxNOJCbSa8cI,7054
68
- bluecellulab-2.6.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
69
- bluecellulab-2.6.13.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
70
- bluecellulab-2.6.13.dist-info/RECORD,,
65
+ bluecellulab-2.6.14.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
66
+ bluecellulab-2.6.14.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
67
+ bluecellulab-2.6.14.dist-info/METADATA,sha256=aAFV1ZITbhfPMneiZzSo0Vj4wdBu2dzcGd9sggs1R8I,7054
68
+ bluecellulab-2.6.14.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
69
+ bluecellulab-2.6.14.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
70
+ bluecellulab-2.6.14.dist-info/RECORD,,