bmtool 0.6.5.1__py3-none-any.whl → 0.6.6.1__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/synapses.py +126 -10
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/METADATA +1 -1
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/RECORD +7 -7
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/LICENSE +0 -0
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/WHEEL +0 -0
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/entry_points.txt +0 -0
- {bmtool-0.6.5.1.dist-info → bmtool-0.6.6.1.dist-info}/top_level.txt +0 -0
bmtool/synapses.py
CHANGED
@@ -405,6 +405,10 @@ class SynapseTuner:
|
|
405
405
|
------
|
406
406
|
- This function is based on experiments from the Allen Database.
|
407
407
|
"""
|
408
|
+
# lets also set the train drive and delay here
|
409
|
+
self.train_freq = freq
|
410
|
+
self.train_delay = delay
|
411
|
+
|
408
412
|
n_init_pulse = 8
|
409
413
|
n_ending_pulse = 4
|
410
414
|
self.nstim.start = self.general_settings['tstart']
|
@@ -500,7 +504,7 @@ class SynapseTuner:
|
|
500
504
|
|
501
505
|
if print_math:
|
502
506
|
print("\n" + "="*40)
|
503
|
-
print("Short Term Plasticity Results")
|
507
|
+
print(f"Short Term Plasticity Results for {self.train_freq}Hz with {self.train_delay} Delay")
|
504
508
|
print("="*40)
|
505
509
|
print("PPR: Above 1 is facilitating, below 1 is depressing.")
|
506
510
|
print("Induction: Above 0 is facilitating, below 0 is depressing.")
|
@@ -682,6 +686,93 @@ class SynapseTuner:
|
|
682
686
|
|
683
687
|
display(ui)
|
684
688
|
update_ui()
|
689
|
+
|
690
|
+
def analyze_frequency_response(self, freqs=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 35, 50, 100, 200],
|
691
|
+
delay=250, plot=True):
|
692
|
+
"""
|
693
|
+
Analyze synaptic response across different stimulation frequencies.
|
694
|
+
|
695
|
+
Parameters:
|
696
|
+
-----------
|
697
|
+
freqs : list, optional
|
698
|
+
List of frequencies to analyze (in Hz)
|
699
|
+
delay : float, optional
|
700
|
+
Delay between pulse trains in ms
|
701
|
+
plot : bool, optional
|
702
|
+
Whether to plot the results
|
703
|
+
|
704
|
+
Returns:
|
705
|
+
--------
|
706
|
+
dict
|
707
|
+
Dictionary containing frequency-dependent metrics
|
708
|
+
"""
|
709
|
+
results = {
|
710
|
+
'frequencies': freqs,
|
711
|
+
'ppr': [],
|
712
|
+
'induction': [],
|
713
|
+
'recovery': []
|
714
|
+
}
|
715
|
+
|
716
|
+
# Store original state
|
717
|
+
original_ispk = self.ispk
|
718
|
+
|
719
|
+
for freq in tqdm(freqs, desc="Analyzing frequencies"):
|
720
|
+
self._simulate_model(freq, delay)
|
721
|
+
amp = self._response_amplitude()
|
722
|
+
ppr, induction, recovery = self._calc_ppr_induction_recovery(amp, print_math=False)
|
723
|
+
|
724
|
+
results['ppr'].append(float(ppr))
|
725
|
+
results['induction'].append(float(induction))
|
726
|
+
results['recovery'].append(float(recovery))
|
727
|
+
|
728
|
+
# Restore original state
|
729
|
+
self.ispk = original_ispk
|
730
|
+
|
731
|
+
if plot:
|
732
|
+
self._plot_frequency_analysis(results)
|
733
|
+
|
734
|
+
return results
|
735
|
+
|
736
|
+
def _plot_frequency_analysis(self, results):
|
737
|
+
"""
|
738
|
+
Plot the frequency-dependent synaptic properties.
|
739
|
+
|
740
|
+
Parameters:
|
741
|
+
-----------
|
742
|
+
results : dict
|
743
|
+
Dictionary containing frequency analysis results
|
744
|
+
"""
|
745
|
+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5))
|
746
|
+
|
747
|
+
# Convert frequencies to log scale for better visualization
|
748
|
+
frequencies = np.array(results['frequencies'])
|
749
|
+
|
750
|
+
# Plot PPR
|
751
|
+
ax1.semilogx(frequencies, results['ppr'], 'o-')
|
752
|
+
ax1.axhline(y=1, color='gray', linestyle='--', alpha=0.5)
|
753
|
+
ax1.set_xlabel('Frequency (Hz)')
|
754
|
+
ax1.set_ylabel('Paired Pulse Ratio')
|
755
|
+
ax1.set_title('PPR vs Frequency')
|
756
|
+
ax1.grid(True)
|
757
|
+
|
758
|
+
# Plot Induction
|
759
|
+
ax2.semilogx(frequencies, results['induction'], 'o-')
|
760
|
+
ax2.axhline(y=0, color='gray', linestyle='--', alpha=0.5)
|
761
|
+
ax2.set_xlabel('Frequency (Hz)')
|
762
|
+
ax2.set_ylabel('Induction')
|
763
|
+
ax2.set_title('Induction vs Frequency')
|
764
|
+
ax2.grid(True)
|
765
|
+
|
766
|
+
# Plot Recovery
|
767
|
+
ax3.semilogx(frequencies, results['recovery'], 'o-')
|
768
|
+
ax3.axhline(y=0, color='gray', linestyle='--', alpha=0.5)
|
769
|
+
ax3.set_xlabel('Frequency (Hz)')
|
770
|
+
ax3.set_ylabel('Recovery')
|
771
|
+
ax3.set_title('Recovery vs Frequency')
|
772
|
+
ax3.grid(True)
|
773
|
+
|
774
|
+
plt.tight_layout()
|
775
|
+
plt.show()
|
685
776
|
|
686
777
|
class GapJunctionTuner:
|
687
778
|
def __init__(self, mechanisms_dir: str, templates_dir: str, general_settings: dict, conn_type_settings: dict):
|
@@ -829,13 +920,13 @@ class SynapseOptimizer:
|
|
829
920
|
return np.array([normalized_params[i] * self.param_scales[name] for i, name in enumerate(param_names)])
|
830
921
|
|
831
922
|
def _calculate_metrics(self) -> Dict[str, float]:
|
832
|
-
"""Calculate standard metrics from the current simulation"""
|
833
|
-
self.tuner._simulate_model(
|
923
|
+
"""Calculate standard metrics from the current simulation using specified frequency"""
|
924
|
+
self.tuner._simulate_model(self.train_frequency, self.train_delay)
|
834
925
|
amp = self.tuner._response_amplitude()
|
835
926
|
ppr, induction, recovery = self.tuner._calc_ppr_induction_recovery(amp, print_math=False)
|
836
927
|
amp = self.tuner._find_max_amp(amp)
|
837
928
|
return {
|
838
|
-
'induction': float(induction),
|
929
|
+
'induction': float(induction),
|
839
930
|
'ppr': float(ppr),
|
840
931
|
'recovery': float(recovery),
|
841
932
|
'max_amplitude': float(amp)
|
@@ -874,15 +965,40 @@ class SynapseOptimizer:
|
|
874
965
|
|
875
966
|
return error
|
876
967
|
|
877
|
-
def optimize_parameters(self,
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
968
|
+
def optimize_parameters(self, target_metrics: Dict[str, float],
|
969
|
+
param_bounds: Dict[str, Tuple[float, float]],
|
970
|
+
train_frequency: float = 50,train_delay: float = 250,
|
971
|
+
cost_function: Optional[Callable] = None,
|
972
|
+
method: str = 'SLSQP',init_guess='random') -> SynapseOptimizationResult:
|
882
973
|
"""
|
883
974
|
Optimize synaptic parameters using custom cost function
|
884
|
-
|
975
|
+
|
976
|
+
Parameters:
|
977
|
+
-----------
|
978
|
+
target_metrics : Dict[str, float]
|
979
|
+
Target values for synaptic metrics
|
980
|
+
param_bounds : Dict[str, Tuple[float, float]]
|
981
|
+
Bounds for each parameter to optimize
|
982
|
+
train_frequency : float, optional
|
983
|
+
Frequency of the stimulus train in Hz (default: 50)
|
984
|
+
train_delay : float, optional
|
985
|
+
Delay between pulse trains in ms (default: 250)
|
986
|
+
cost_function : Optional[Callable]
|
987
|
+
Custom cost function for optimization
|
988
|
+
method : str, optional
|
989
|
+
Optimization method to use (default: 'SLSQP')
|
990
|
+
init_guess : str, optional
|
991
|
+
Method for initial parameter guess ('random' or 'middle_guess')
|
992
|
+
|
993
|
+
Returns:
|
994
|
+
--------
|
995
|
+
SynapseOptimizationResult
|
996
|
+
Results of the optimization
|
997
|
+
"""
|
885
998
|
self.optimization_history = []
|
999
|
+
self.train_frequency = train_frequency
|
1000
|
+
self.train_delay = train_delay
|
1001
|
+
|
886
1002
|
param_names = list(param_bounds.keys())
|
887
1003
|
bounds = [param_bounds[name] for name in param_names]
|
888
1004
|
|
@@ -7,7 +7,7 @@ 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=HlAKDlXTDkth6sb8pvgX2k8kOOm9wNXiaCC80RCyOdE,52600
|
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.6.1.dist-info/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
|
20
|
+
bmtool-0.6.6.1.dist-info/METADATA,sha256=f0-Qyi2oYMIthCUzvo0b2uiMsF9kUISI10p84dthBa0,20226
|
21
|
+
bmtool-0.6.6.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
22
|
+
bmtool-0.6.6.1.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
|
23
|
+
bmtool-0.6.6.1.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
|
24
|
+
bmtool-0.6.6.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|