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

@@ -4,11 +4,9 @@ try:
4
4
  except ImportError:
5
5
  efel = None
6
6
  from itertools import islice
7
- from itertools import repeat
8
7
  import logging
9
8
  from matplotlib.collections import LineCollection
10
9
  import matplotlib.pyplot as plt
11
- from multiprocessing import Pool
12
10
  import neuron
13
11
  import numpy as np
14
12
  import pathlib
@@ -97,20 +95,15 @@ def compute_plot_iv_curve(cell,
97
95
  for amp in list_amp
98
96
  ]
99
97
 
100
- with Pool(len(steps)) as p:
101
- recordings = p.starmap(
102
- run_stimulus,
103
- zip(
104
- repeat(cell.template_params),
105
- steps,
106
- repeat(injecting_section),
107
- repeat(injecting_segment),
108
- repeat(True), # cvode
109
- repeat(True), # add_hypamp
110
- repeat(recording_section),
111
- repeat(recording_segment),
112
- )
113
- )
98
+ recordings = []
99
+ for step in steps:
100
+ recording = run_stimulus(cell.template_params,
101
+ step,
102
+ section=injecting_section,
103
+ segment=injecting_segment,
104
+ recording_section=recording_section,
105
+ recording_segment=recording_segment)
106
+ recordings.append(recording)
114
107
 
115
108
  steady_states = []
116
109
  # compute steady state response
@@ -208,24 +201,19 @@ def compute_plot_fi_curve(cell,
208
201
  for amp in list_amp
209
202
  ]
210
203
 
211
- with Pool(len(steps)) as p:
212
- recordings = p.starmap(
213
- run_stimulus,
214
- zip(
215
- repeat(cell.template_params),
216
- steps,
217
- repeat(injecting_section),
218
- repeat(injecting_segment),
219
- repeat(True), # cvode
220
- repeat(True), # add_hypamp
221
- repeat(recording_section),
222
- repeat(recording_segment),
223
- repeat(True), # enable_spike_detection
224
- repeat(threshold_voltage), # threshold_spike_detection
225
- )
226
- )
204
+ spikes = []
205
+ for step in steps:
206
+ recording = run_stimulus(cell.template_params,
207
+ step,
208
+ section=injecting_section,
209
+ segment=injecting_segment,
210
+ recording_section=recording_section,
211
+ recording_segment=recording_segment,
212
+ enable_spike_detection=True,
213
+ threshold_spike_detection=threshold_voltage)
214
+ spikes.append(recording.spike)
227
215
 
228
- spike_count = [len(recording.spike) for recording in recordings]
216
+ spike_count = [len(spike) for spike in spikes]
229
217
 
230
218
  plot_fi_curve(list_amp,
231
219
  spike_count,
@@ -248,7 +236,7 @@ class BPAP:
248
236
  self.cell = cell
249
237
  self.dt = 0.025
250
238
  self.stim_start = 1000
251
- self.stim_duration = 3
239
+ self.stim_duration = 5
252
240
  self.basal_cmap = sns.color_palette("crest", as_cmap=True)
253
241
  self.apical_cmap = sns.color_palette("YlOrBr_r", as_cmap=True)
254
242
 
@@ -301,7 +289,11 @@ class BPAP:
301
289
  for rec in recs.values()
302
290
  ]
303
291
  features_results = efel.get_feature_values(traces, [efel_feature_name])
304
- amps = [feat_res[efel_feature_name][0] for feat_res in features_results]
292
+ amps = [
293
+ feat_res[efel_feature_name][0]
294
+ for feat_res in features_results
295
+ if feat_res[efel_feature_name] is not None
296
+ ]
305
297
 
306
298
  return amps
307
299
 
@@ -320,7 +312,7 @@ class BPAP:
320
312
 
321
313
  def get_amplitudes_and_distances(self):
322
314
  soma_rec, dend_rec, apic_rec = self.get_recordings()
323
- soma_amp = self.amplitudes({"soma": soma_rec})[0]
315
+ soma_amp = self.amplitudes({"soma": soma_rec})
324
316
  dend_amps = None
325
317
  dend_dist = None
326
318
  apic_amps = None
@@ -334,20 +326,21 @@ class BPAP:
334
326
 
335
327
  return soma_amp, dend_amps, dend_dist, apic_amps, apic_dist
336
328
 
337
- def fit(self, soma_amp, dend_amps, dend_dist, apic_amps, apic_dist):
329
+ @staticmethod
330
+ def fit(soma_amp, dend_amps, dend_dist, apic_amps, apic_dist):
338
331
  """Fit the amplitudes vs distances to an exponential decay function."""
339
332
  from scipy.optimize import curve_fit
340
333
 
341
334
  popt_dend = None
342
335
  if dend_amps and dend_dist:
343
336
  dist = [0] + dend_dist # add soma distance
344
- amps = [soma_amp] + dend_amps # add soma amplitude
337
+ amps = soma_amp + dend_amps # add soma amplitude
345
338
  popt_dend, _ = curve_fit(exp_decay, dist, amps)
346
339
 
347
340
  popt_apic = None
348
341
  if apic_amps and apic_dist:
349
342
  dist = [0] + apic_dist # add soma distance
350
- amps = [soma_amp] + apic_amps # add soma amplitude
343
+ amps = soma_amp + apic_amps # add soma amplitude
351
344
  popt_apic, _ = curve_fit(exp_decay, dist, amps)
352
345
 
353
346
  return popt_dend, popt_apic
@@ -357,10 +350,18 @@ class BPAP:
357
350
  validated = True
358
351
  notes = ""
359
352
  popt_dend, popt_apic = self.fit(soma_amp, dend_amps, dend_dist, apic_amps, apic_dist)
353
+ logging.warning(popt_dend)
354
+ if dend_amps is not None:
355
+ plt.cla()
356
+ plt.plot([0], soma_amp, '.')
357
+ plt.plot(dend_dist, dend_amps, '.')
358
+ x = np.linspace(0, max(dend_dist), 100)
359
+ plt.plot(x, exp_decay(x, *popt_dend), color='darkgreen', linestyle='--', label='Basal Dendritic Fit')
360
+ plt.savefig("bad_dendritic_fit.png")
360
361
  if popt_dend is None:
361
362
  logger.debug("No dendritic recordings found.")
362
363
  notes += "No dendritic recordings found.\n"
363
- elif popt_dend[1] <= 0:
364
+ elif popt_dend[1] <= 0 or popt_dend[0] <= 0:
364
365
  logger.debug("Dendritic fit is not decaying.")
365
366
  validated = False
366
367
  notes += "Dendritic fit is not decaying.\n"
@@ -369,7 +370,7 @@ class BPAP:
369
370
  if popt_apic is None:
370
371
  logger.debug("No apical recordings found.")
371
372
  notes += "No apical recordings found.\n"
372
- elif popt_apic[1] <= 0:
373
+ elif popt_apic[1] <= 0 or popt_apic[0] <= 0:
373
374
  logger.debug("Apical fit is not decaying.")
374
375
  validated = False
375
376
  notes += "Apical fit is not decaying.\n"
@@ -395,7 +396,7 @@ class BPAP:
395
396
 
396
397
  outpath = pathlib.Path(output_dir) / output_fname
397
398
  fig, ax1 = plt.subplots(figsize=(10, 6))
398
- ax1.scatter([0], [soma_amp], marker="^", color='black', label='Soma')
399
+ ax1.scatter([0], soma_amp, marker="^", color='black', label='Soma')
399
400
  if dend_amps and dend_dist:
400
401
  ax1.scatter(
401
402
  dend_dist,
@@ -438,68 +438,38 @@ def run_validations(
438
438
  )
439
439
 
440
440
  logger.debug("Running validations...")
441
- from bluecellulab.utils import NestedPool
442
- with NestedPool(processes=8) as pool:
443
- # Validation 1: Spiking Test
444
- spiking_test_result_future = pool.apply_async(
445
- spiking_test,
446
- (cell.template_params, rheobase, out_dir, spike_threshold_voltage)
447
- )
448
-
449
- # Validation 2: Depolarization Block Test
450
- depolarization_block_result_future = pool.apply_async(
451
- depolarization_block_test,
452
- (cell.template_params, rheobase, out_dir)
453
- )
441
+ # Validation 1: Spiking Test
442
+ spiking_test_result = spiking_test(
443
+ cell.template_params, rheobase, out_dir, spike_threshold_voltage
444
+ )
454
445
 
455
- # Validation 3: Backpropagating AP Test
456
- bpap_result_future = pool.apply_async(
457
- bpap_test,
458
- (cell.template_params, rheobase, out_dir)
459
- )
446
+ # Validation 2: Depolarization Block Test
447
+ depolarization_block_result = depolarization_block_test(
448
+ cell.template_params, rheobase, out_dir
449
+ )
460
450
 
461
- # Validation 4: Postsynaptic Potential Test
462
- # We have to wait for ProbAMPANMDA_EMS to be present in entitycore to implement this test
451
+ # Validation 3: Backpropagating AP Test
452
+ bpap_result = bpap_test(cell.template_params, rheobase, out_dir)
463
453
 
464
- # Validation 5: AIS Spiking Test
465
- ais_spiking_test_result_future = pool.apply_async(
466
- ais_spiking_test,
467
- (cell.template_params, rheobase, out_dir, spike_threshold_voltage)
468
- )
454
+ # Validation 4: Postsynaptic Potential Test
455
+ # We have to wait for ProbAMPANMDA_EMS to be present in entitycore to implement this test
469
456
 
470
- # Validation 6: Hyperpolarization Test
471
- hyperpolarization_result_future = pool.apply_async(
472
- hyperpolarization_test,
473
- (cell.template_params, rheobase, out_dir)
474
- )
457
+ # Validation 5: AIS Spiking Test
458
+ ais_spiking_test_result = ais_spiking_test(
459
+ cell.template_params, rheobase, out_dir, spike_threshold_voltage
460
+ )
475
461
 
476
- # Validation 7: Rin Test
477
- rin_result_future = pool.apply_async(
478
- rin_test,
479
- (rin,)
480
- )
462
+ # Validation 6: Hyperpolarization Test
463
+ hyperpolarization_result = hyperpolarization_test(cell.template_params, rheobase, out_dir)
481
464
 
482
- # # Validation 8: IV Test
483
- iv_test_result_future = pool.apply_async(
484
- iv_test,
485
- (cell.template_params, rheobase, out_dir, spike_threshold_voltage)
486
- )
465
+ # Validation 7: Rin Test
466
+ rin_result = rin_test(rin)
487
467
 
488
- # # Validation 9: FI Test
489
- fi_test_result_future = pool.apply_async(
490
- fi_test,
491
- (cell.template_params, rheobase, out_dir, spike_threshold_voltage)
492
- )
468
+ # Validation 8: IV Test
469
+ iv_test_result = iv_test(cell.template_params, rheobase, out_dir, spike_threshold_voltage)
493
470
 
494
- # Wait for all validations to complete
495
- spiking_test_result = spiking_test_result_future.get()
496
- depolarization_block_result = depolarization_block_result_future.get()
497
- bpap_result = bpap_result_future.get()
498
- ais_spiking_test_result = ais_spiking_test_result_future.get()
499
- hyperpolarization_result = hyperpolarization_result_future.get()
500
- rin_result = rin_result_future.get()
501
- iv_test_result = iv_test_result_future.get()
502
- fi_test_result = fi_test_result_future.get()
471
+ # Validation 9: FI Test
472
+ fi_test_result = fi_test(cell.template_params, rheobase, out_dir, spike_threshold_voltage)
503
473
 
504
474
  return {
505
475
  "memodel_properties": {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluecellulab
3
- Version: 2.6.52
3
+ Version: 2.6.54
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=0NhwlzyLnSi8kziSfDsQf7pokO4qDkMJVAO33kSX4O0,2227
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=53g6SW_9ZbG3fbhuXJqurAPRR4VG1jsZYK6efq-EwfA,21229
18
+ bluecellulab/analysis/analysis.py,sha256=rZdM7AjjCLFoW7x0d_R6oQPLAasz_R6UxSVgcKTUJW0,21646
19
19
  bluecellulab/analysis/inject_sequence.py,sha256=uU6Q6y0ErMDDEgdsTZBXCJ4LgwkATY7G8Fa6mmjpL98,12523
20
20
  bluecellulab/analysis/plotting.py,sha256=PqRoaZz33ULMw8A9YnZXXrxcUd84M_dwlYMTFhG7YT4,3999
21
21
  bluecellulab/analysis/utils.py,sha256=eMirP557D11BuedgSqjripDxOq1haIldNbnYNetV1bg,121
@@ -67,10 +67,10 @@ bluecellulab/stimulus/stimulus.py,sha256=a_hKJUtZmIgjiFjbJf6RzUPokELqn0IHCgIWGw5
67
67
  bluecellulab/synapse/__init__.py,sha256=RW8XoAMXOvK7OG1nHl_q8jSEKLj9ZN4oWf2nY9HAwuk,192
68
68
  bluecellulab/synapse/synapse_factory.py,sha256=NHwRMYMrnRVm_sHmyKTJ1bdoNmWZNU4UPOGu7FCi-PE,6987
69
69
  bluecellulab/synapse/synapse_types.py,sha256=zs_yBvGTH4QrbQF3nEViidyq1WM_ZcTSFdjUxB3khW0,16871
70
- bluecellulab/validation/validation.py,sha256=EN9HMty70VPwnEPhWUmN5F-MGWbMN3uU0DmNnjL0ucw,18209
71
- bluecellulab-2.6.52.dist-info/licenses/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
72
- bluecellulab-2.6.52.dist-info/licenses/LICENSE,sha256=dAMAR2Sud4Nead1wGFleKiwTZfkTNZbzmuGfcTKb3kg,11335
73
- bluecellulab-2.6.52.dist-info/METADATA,sha256=dpyLb82oMOxH5zViSJr5Q9HbpmYDuGv8f_GgNJdOc8g,8259
74
- bluecellulab-2.6.52.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
- bluecellulab-2.6.52.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
76
- bluecellulab-2.6.52.dist-info/RECORD,,
70
+ bluecellulab/validation/validation.py,sha256=-wNn76QndoYPrC0C2cKEG3gw3ytPv7uTQ8UFj6xtT_0,17066
71
+ bluecellulab-2.6.54.dist-info/licenses/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
72
+ bluecellulab-2.6.54.dist-info/licenses/LICENSE,sha256=dAMAR2Sud4Nead1wGFleKiwTZfkTNZbzmuGfcTKb3kg,11335
73
+ bluecellulab-2.6.54.dist-info/METADATA,sha256=4sgl5RPxGJsw20GxT8VvsWlisoqoT6G1L4CRxKJX8UU,8259
74
+ bluecellulab-2.6.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
75
+ bluecellulab-2.6.54.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
76
+ bluecellulab-2.6.54.dist-info/RECORD,,