bmtool 0.6.5__tar.gz → 0.6.6.1__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.
Files changed (29) hide show
  1. {bmtool-0.6.5 → bmtool-0.6.6.1}/PKG-INFO +1 -1
  2. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/SLURM.py +2 -2
  3. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/synapses.py +126 -10
  4. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/PKG-INFO +1 -1
  5. {bmtool-0.6.5 → bmtool-0.6.6.1}/setup.py +1 -1
  6. {bmtool-0.6.5 → bmtool-0.6.6.1}/LICENSE +0 -0
  7. {bmtool-0.6.5 → bmtool-0.6.6.1}/README.md +0 -0
  8. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/__init__.py +0 -0
  9. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/__main__.py +0 -0
  10. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/bmplot.py +0 -0
  11. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/connectors.py +0 -0
  12. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/debug/__init__.py +0 -0
  13. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/debug/commands.py +0 -0
  14. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/debug/debug.py +0 -0
  15. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/graphs.py +0 -0
  16. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/manage.py +0 -0
  17. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/plot_commands.py +0 -0
  18. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/singlecell.py +0 -0
  19. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/util/__init__.py +0 -0
  20. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/util/commands.py +0 -0
  21. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/util/neuron/__init__.py +0 -0
  22. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/util/neuron/celltuner.py +0 -0
  23. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool/util/util.py +0 -0
  24. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/SOURCES.txt +0 -0
  25. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/dependency_links.txt +0 -0
  26. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/entry_points.txt +0 -0
  27. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/requires.txt +0 -0
  28. {bmtool-0.6.5 → bmtool-0.6.6.1}/bmtool.egg-info/top_level.txt +0 -0
  29. {bmtool-0.6.5 → bmtool-0.6.6.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bmtool
3
- Version: 0.6.5
3
+ Version: 0.6.6.1
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -208,7 +208,7 @@ class SimulationBlock:
208
208
  # Conditional account linegit
209
209
  account_line = f"#SBATCH --account={self.account}\n" if self.account else ""
210
210
  env_var_component_path = f"export COMPONENT_PATH={self.component_path}" if self.component_path else ""
211
-
211
+ mem_per_cpu = int(int(self.mem)/int(self.ntasks))
212
212
 
213
213
  # Write the batch script to the file
214
214
  with open(batch_script_path, 'w') as script_file:
@@ -220,7 +220,7 @@ class SimulationBlock:
220
220
  #SBATCH --partition={self.partition}
221
221
  #SBATCH --nodes={self.nodes}
222
222
  #SBATCH --ntasks={self.ntasks}
223
- #SBATCH --mem={self.mem}
223
+ #SBATCH --mem-per-cpu={mem_per_cpu}G
224
224
  {account_line}
225
225
 
226
226
  # Additional user-defined commands
@@ -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(50, 250) # 50 Hz with 250ms Delay
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), # Ensure these are scalar values
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
- target_metrics: Dict[str, float],
879
- param_bounds: Dict[str, Tuple[float, float]],
880
- cost_function: Optional[Callable] = None,
881
- method: str = 'SLSQP',init_guess='random') -> SynapseOptimizationResult:
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bmtool
3
- Version: 0.6.5
3
+ Version: 0.6.6.1
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
6
6
 
7
7
  setup(
8
8
  name="bmtool",
9
- version='0.6.5',
9
+ version='0.6.6.1',
10
10
  author="Neural Engineering Laboratory at the University of Missouri",
11
11
  author_email="gregglickert@mail.missouri.edu",
12
12
  description="BMTool",
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