bmtool 0.6.4__py3-none-any.whl → 0.6.5__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.
- bmtool/connectors.py +1 -1
- bmtool/synapses.py +42 -25
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/METADATA +1 -1
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/RECORD +8 -8
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/LICENSE +0 -0
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/WHEEL +0 -0
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/entry_points.txt +0 -0
- {bmtool-0.6.4.dist-info → bmtool-0.6.5.dist-info}/top_level.txt +0 -0
bmtool/connectors.py
CHANGED
@@ -1082,7 +1082,7 @@ class ReciprocalConnector(AbstractConnector):
|
|
1082
1082
|
|
1083
1083
|
class UnidirectionConnector(AbstractConnector):
|
1084
1084
|
"""
|
1085
|
-
Object for
|
1085
|
+
Object for building unidirectional connections in bmtk network model with
|
1086
1086
|
given probability within a single population (or between two populations).
|
1087
1087
|
|
1088
1088
|
Parameters:
|
bmtool/synapses.py
CHANGED
@@ -178,6 +178,11 @@ class SynapseTuner:
|
|
178
178
|
"""
|
179
179
|
self._set_up_cell()
|
180
180
|
self._set_up_synapse()
|
181
|
+
|
182
|
+
# user slider values if the sliders are set up
|
183
|
+
if hasattr(self, 'dynamic_sliders'):
|
184
|
+
syn_props = {var: slider.value for var, slider in self.dynamic_sliders.items()}
|
185
|
+
self._set_syn_prop(**syn_props)
|
181
186
|
|
182
187
|
# Set up the stimulus
|
183
188
|
self.nstim = h.NetStim()
|
@@ -204,10 +209,17 @@ class SynapseTuner:
|
|
204
209
|
self.nstim.number = 1
|
205
210
|
self.nstim2.start = h.tstop
|
206
211
|
h.run()
|
212
|
+
|
213
|
+
current = np.array(self.rec_vectors[self.current_name])
|
214
|
+
syn_prop = self._get_syn_prop(short=True)
|
215
|
+
current = (current - syn_prop['baseline']) * 1000 # Convert to pA
|
216
|
+
current_integral = np.trapz(current, dx=h.dt) # pA·ms
|
217
|
+
|
207
218
|
self._plot_model([self.general_settings['tstart'] - 5, self.general_settings['tstart'] + self.general_settings['tdur']])
|
208
219
|
syn_props = self._get_syn_prop(rise_interval=self.general_settings['rise_interval'])
|
209
220
|
for prop in syn_props.items():
|
210
221
|
print(prop)
|
222
|
+
print(f'Current Integral in pA: {current_integral:.2f}')
|
211
223
|
|
212
224
|
|
213
225
|
def _find_first(self, x):
|
@@ -436,27 +448,25 @@ class SynapseTuner:
|
|
436
448
|
return amp
|
437
449
|
|
438
450
|
|
439
|
-
def _find_max_amp(self, amp
|
451
|
+
def _find_max_amp(self, amp):
|
440
452
|
"""
|
441
|
-
Determines the maximum amplitude from the response data
|
453
|
+
Determines the maximum amplitude from the response data and returns the max in pA
|
442
454
|
|
443
455
|
Parameters:
|
444
456
|
-----------
|
445
457
|
amp : array-like
|
446
458
|
Array containing the amplitudes of synaptic responses.
|
447
|
-
normalize_by_trial : bool, optional
|
448
|
-
If True, normalize the maximum amplitude within each trial. Default is True.
|
449
459
|
|
450
460
|
Returns:
|
451
461
|
--------
|
452
462
|
max_amp : float
|
453
463
|
The maximum or minimum amplitude based on the sign of the response.
|
454
464
|
"""
|
455
|
-
max_amp =
|
456
|
-
min_amp =
|
465
|
+
max_amp = max(amp)
|
466
|
+
min_amp = min(amp)
|
457
467
|
if(abs(min_amp) > max_amp):
|
458
|
-
return min_amp
|
459
|
-
return max_amp
|
468
|
+
return min_amp * 1000 # scale unit
|
469
|
+
return max_amp * 1000 # scale unit
|
460
470
|
|
461
471
|
|
462
472
|
def _calc_ppr_induction_recovery(self,amp, normalize_by_trial=True,print_math=True):
|
@@ -589,17 +599,19 @@ class SynapseTuner:
|
|
589
599
|
duration0 = 300
|
590
600
|
vlamp_status = self.vclamp
|
591
601
|
|
592
|
-
w_run = widgets.Button(description='Run', icon='history', button_style='primary')
|
602
|
+
w_run = widgets.Button(description='Run Train', icon='history', button_style='primary')
|
603
|
+
w_single = widgets.Button(description='Single Event', icon='check', button_style='success')
|
593
604
|
w_vclamp = widgets.ToggleButton(value=vlamp_status, description='Voltage Clamp', icon='fast-backward', button_style='warning')
|
594
605
|
w_input_mode = widgets.ToggleButton(value=False, description='Continuous input', icon='eject', button_style='info')
|
595
606
|
w_input_freq = widgets.SelectionSlider(options=freqs, value=freq0, description='Input Freq')
|
596
607
|
|
608
|
+
|
597
609
|
# Sliders for delay and duration
|
598
610
|
self.w_delay = widgets.SelectionSlider(options=delays, value=delay0, description='Delay')
|
599
611
|
self.w_duration = widgets.SelectionSlider(options=durations, value=duration0, description='Duration')
|
600
612
|
|
601
613
|
# Generate sliders dynamically based on valid numeric entries in self.slider_vars
|
602
|
-
dynamic_sliders = {}
|
614
|
+
self.dynamic_sliders = {}
|
603
615
|
print("Setting up slider! The sliders ranges are set by their init value so try changing that if you dont like the slider range!")
|
604
616
|
for key, value in self.slider_vars.items():
|
605
617
|
if isinstance(value, (int, float)): # Only create sliders for numeric values
|
@@ -609,18 +621,25 @@ class SynapseTuner:
|
|
609
621
|
slider = widgets.FloatSlider(value=value, min=0, max=1000, step=1, description=key)
|
610
622
|
else:
|
611
623
|
slider = widgets.FloatSlider(value=value, min=0, max=value*20, step=value/5, description=key)
|
612
|
-
dynamic_sliders[key] = slider
|
624
|
+
self.dynamic_sliders[key] = slider
|
613
625
|
else:
|
614
626
|
print(f"skipping slider for {key} due to not being a synaptic variable")
|
615
627
|
|
628
|
+
def run_single_event(*args):
|
629
|
+
clear_output()
|
630
|
+
display(ui)
|
631
|
+
self.vclamp = w_vclamp.value
|
632
|
+
# Update synaptic properties based on slider values
|
633
|
+
self.ispk=None
|
634
|
+
self.SingleEvent()
|
635
|
+
|
616
636
|
# Function to update UI based on input mode
|
617
637
|
def update_ui(*args):
|
618
638
|
clear_output()
|
619
639
|
display(ui)
|
620
640
|
self.vclamp = w_vclamp.value
|
621
641
|
self.input_mode = w_input_mode.value
|
622
|
-
|
623
|
-
syn_props = {var: slider.value for var, slider in dynamic_sliders.items()}
|
642
|
+
syn_props = {var: slider.value for var, slider in self.dynamic_sliders.items()}
|
624
643
|
self._set_syn_prop(**syn_props)
|
625
644
|
if self.input_mode == False:
|
626
645
|
self._simulate_model(w_input_freq.value, self.w_delay.value, w_vclamp.value)
|
@@ -629,9 +648,6 @@ class SynapseTuner:
|
|
629
648
|
amp = self._response_amplitude()
|
630
649
|
self._plot_model([self.general_settings['tstart'] - self.nstim.interval / 3, self.tstop])
|
631
650
|
_ = self._calc_ppr_induction_recovery(amp)
|
632
|
-
# print('Single trial ' + ('PSC' if self.vclamp else 'PSP'))
|
633
|
-
# print(f'Induction: {induction_single:.2f}; Recovery: {recovery:.2f}')
|
634
|
-
#print(f'Rest Amp: {amp[0]:.2f}; Maximum Amp: {maxamp:.2f}')
|
635
651
|
|
636
652
|
# Function to switch between delay and duration sliders
|
637
653
|
def switch_slider(*args):
|
@@ -648,23 +664,23 @@ class SynapseTuner:
|
|
648
664
|
# Hide the duration slider initially until the user selects it
|
649
665
|
self.w_duration.layout.display = 'none' # Hide duration slider
|
650
666
|
|
667
|
+
w_single.on_click(run_single_event)
|
651
668
|
w_run.on_click(update_ui)
|
652
669
|
|
653
670
|
# Add the dynamic sliders to the UI
|
654
|
-
slider_widgets = [slider for slider in dynamic_sliders.values()]
|
671
|
+
slider_widgets = [slider for slider in self.dynamic_sliders.values()]
|
655
672
|
|
656
|
-
|
657
|
-
|
658
|
-
col1 = VBox(slider_widgets[:half]) # First half of sliders
|
659
|
-
col2 = VBox(slider_widgets[half:]) # Second half of sliders
|
673
|
+
button_row = HBox([w_run, w_single, w_vclamp, w_input_mode])
|
674
|
+
slider_row = HBox([w_input_freq, self.w_delay, self.w_duration])
|
660
675
|
|
661
|
-
|
676
|
+
half = len(slider_widgets) // 2
|
677
|
+
col1 = VBox(slider_widgets[:half])
|
678
|
+
col2 = VBox(slider_widgets[half:])
|
662
679
|
slider_columns = HBox([col1, col2])
|
663
680
|
|
664
|
-
ui = VBox([
|
681
|
+
ui = VBox([button_row, slider_row, slider_columns])
|
665
682
|
|
666
683
|
display(ui)
|
667
|
-
# run model with default parameters
|
668
684
|
update_ui()
|
669
685
|
|
670
686
|
class GapJunctionTuner:
|
@@ -817,11 +833,12 @@ class SynapseOptimizer:
|
|
817
833
|
self.tuner._simulate_model(50, 250) # 50 Hz with 250ms Delay
|
818
834
|
amp = self.tuner._response_amplitude()
|
819
835
|
ppr, induction, recovery = self.tuner._calc_ppr_induction_recovery(amp, print_math=False)
|
836
|
+
amp = self.tuner._find_max_amp(amp)
|
820
837
|
return {
|
821
838
|
'induction': float(induction), # Ensure these are scalar values
|
822
839
|
'ppr': float(ppr),
|
823
840
|
'recovery': float(recovery),
|
824
|
-
'
|
841
|
+
'max_amplitude': float(amp)
|
825
842
|
}
|
826
843
|
|
827
844
|
def _default_cost_function(self, metrics: Dict[str, float], target_metrics: Dict[str, float]) -> float:
|
@@ -2,12 +2,12 @@ bmtool/SLURM.py,sha256=4KvtrPofaHv5iairetgrlXdhAdowJfg_aeTx9W59JDM,16618
|
|
2
2
|
bmtool/__init__.py,sha256=ZStTNkAJHJxG7Pwiy5UgCzC4KlhMS5pUNPtUJZVwL_Y,136
|
3
3
|
bmtool/__main__.py,sha256=TmFkmDxjZ6250nYD4cgGhn-tbJeEm0u-EMz2ajAN9vE,650
|
4
4
|
bmtool/bmplot.py,sha256=Im-Jrv8TK3CmTtksFzHrVogAve0l9ZwRrCW4q2MFRiA,53966
|
5
|
-
bmtool/connectors.py,sha256=
|
5
|
+
bmtool/connectors.py,sha256=hWkUUcJ4tmas8NDOFPPjQT-TgTlPcpjuZsYyAW2WkPA,72242
|
6
6
|
bmtool/graphs.py,sha256=K8BiughRUeXFVvAgo8UzrwpSClIVg7UfmIcvtEsEsk0,6020
|
7
7
|
bmtool/manage.py,sha256=_lCU0qBQZ4jSxjzAJUd09JEetb--cud7KZgxQFbLGSY,657
|
8
8
|
bmtool/plot_commands.py,sha256=Tqujyf0c0u8olhiHOMwgUSJXIIE1hgjv6otb25G9cA0,12298
|
9
9
|
bmtool/singlecell.py,sha256=MQiLucsI6OBIjtcJra3Z9PTFQOE-Zn5ST-R9SmFvrbQ,27049
|
10
|
-
bmtool/synapses.py,sha256=
|
10
|
+
bmtool/synapses.py,sha256=jQFOpi9hzzBEijDQ7dsWfcxW-DtxN9v0UWxCqDSlcTs,48466
|
11
11
|
bmtool/debug/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
bmtool/debug/commands.py,sha256=AwtcR7BUUheM0NxvU1Nu234zCdpobhJv5noX8x5K2vY,583
|
13
13
|
bmtool/debug/debug.py,sha256=xqnkzLiH3s-tS26Y5lZZL62qR2evJdi46Gud-HzxEN4,207
|
@@ -16,9 +16,9 @@ bmtool/util/commands.py,sha256=zJF-fiLk0b8LyzHDfvewUyS7iumOxVnj33IkJDzux4M,64396
|
|
16
16
|
bmtool/util/util.py,sha256=00vOAwTVIifCqouBoFoT0lBashl4fCalrk8fhg_Uq4c,56654
|
17
17
|
bmtool/util/neuron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
18
18
|
bmtool/util/neuron/celltuner.py,sha256=xSRpRN6DhPFz4q5buq_W8UmsD7BbUrkzYBEbKVloYss,87194
|
19
|
-
bmtool-0.6.
|
20
|
-
bmtool-0.6.
|
21
|
-
bmtool-0.6.
|
22
|
-
bmtool-0.6.
|
23
|
-
bmtool-0.6.
|
24
|
-
bmtool-0.6.
|
19
|
+
bmtool-0.6.5.dist-info/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
|
20
|
+
bmtool-0.6.5.dist-info/METADATA,sha256=-67VVvOyPqiGX7qoidn8SLVHuHRxSZnOIPKPxqZ8TNI,20224
|
21
|
+
bmtool-0.6.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
22
|
+
bmtool-0.6.5.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
|
23
|
+
bmtool-0.6.5.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
|
24
|
+
bmtool-0.6.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|