bmtool 0.5.9.6__tar.gz → 0.5.9.7__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.5.9.6 → bmtool-0.5.9.7}/PKG-INFO +8 -1
  2. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/README.md +7 -0
  3. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/bmplot.py +81 -68
  4. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/synapses.py +1 -1
  5. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/PKG-INFO +8 -1
  6. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/setup.py +1 -1
  7. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/LICENSE +0 -0
  8. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/SLURM.py +0 -0
  9. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/__init__.py +0 -0
  10. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/__main__.py +0 -0
  11. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/connectors.py +0 -0
  12. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/debug/__init__.py +0 -0
  13. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/debug/commands.py +0 -0
  14. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/debug/debug.py +0 -0
  15. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/graphs.py +0 -0
  16. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/manage.py +0 -0
  17. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/plot_commands.py +0 -0
  18. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/singlecell.py +0 -0
  19. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/util/__init__.py +0 -0
  20. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/util/commands.py +0 -0
  21. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/util/neuron/__init__.py +0 -0
  22. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/util/neuron/celltuner.py +0 -0
  23. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool/util/util.py +0 -0
  24. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/SOURCES.txt +0 -0
  25. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/dependency_links.txt +0 -0
  26. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/entry_points.txt +0 -0
  27. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/requires.txt +0 -0
  28. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/bmtool.egg-info/top_level.txt +0 -0
  29. {bmtool-0.5.9.6 → bmtool-0.5.9.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bmtool
3
- Version: 0.5.9.6
3
+ Version: 0.5.9.7
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -41,6 +41,7 @@ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/
41
41
  - [Getting Started](#Getting-Started)
42
42
  - [CLI](#CLI)
43
43
  - [Single Cell](#Single-Cell-Module)
44
+ - [Synapses](#synapses-module)
44
45
  - [Connectors](#Connectors-Module)
45
46
  - [Bmplot](#bmplot-Module)
46
47
  - [Graphs](#graphs-module)
@@ -335,6 +336,12 @@ bmtool util cell --hoc segmented_template.hoc vhsegbuild
335
336
  ```
336
337
  ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)
337
338
 
339
+ ### Synapses Module
340
+ -[SynapticTuner](#synaptictuner)
341
+
342
+ #### SynapticTuner - Aids in the tuning of synapses by printing out synaptic properties and giving the user sliders in a Jupyter notebook to tune the synapse. For more info view the example [here](examples/synapses/synaptic_tuner.ipynb)
343
+
344
+
338
345
  ### Connectors Module
339
346
  - [UnidirectionConnector](#unidirectional-connector---unidirectional-connections-in-bmtk-network-model-with-given-probability-within-a-single-population-or-between-two-populations)
340
347
  - [ReciprocalConnector](#recipical-connector---buiilding-connections-in-bmtk-network-model-with-reciprocal-probability-within-a-single-population-or-between-two-populations)
@@ -7,6 +7,7 @@ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/
7
7
  - [Getting Started](#Getting-Started)
8
8
  - [CLI](#CLI)
9
9
  - [Single Cell](#Single-Cell-Module)
10
+ - [Synapses](#synapses-module)
10
11
  - [Connectors](#Connectors-Module)
11
12
  - [Bmplot](#bmplot-Module)
12
13
  - [Graphs](#graphs-module)
@@ -301,6 +302,12 @@ bmtool util cell --hoc segmented_template.hoc vhsegbuild
301
302
  ```
302
303
  ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)
303
304
 
305
+ ### Synapses Module
306
+ -[SynapticTuner](#synaptictuner)
307
+
308
+ #### SynapticTuner - Aids in the tuning of synapses by printing out synaptic properties and giving the user sliders in a Jupyter notebook to tune the synapse. For more info view the example [here](examples/synapses/synaptic_tuner.ipynb)
309
+
310
+
304
311
  ### Connectors Module
305
312
  - [UnidirectionConnector](#unidirectional-connector---unidirectional-connections-in-bmtk-network-model-with-given-probability-within-a-single-population-or-between-two-populations)
306
313
  - [ReciprocalConnector](#recipical-connector---buiilding-connections-in-bmtk-network-model-with-reciprocal-probability-within-a-single-population-or-between-two-populations)
@@ -12,6 +12,7 @@ import matplotlib.cm as cmx
12
12
  import matplotlib.colors as colors
13
13
  import matplotlib.gridspec as gridspec
14
14
  from mpl_toolkits.mplot3d import Axes3D
15
+ from matplotlib.axes import Axes
15
16
  from IPython import get_ipython
16
17
  from IPython.display import display, HTML
17
18
  import statistics
@@ -19,8 +20,10 @@ import pandas as pd
19
20
  import os
20
21
  import sys
21
22
  import re
23
+ from typing import Optional, Dict
24
+ from .analysis.spikes import load_spikes_to_df
22
25
 
23
- from .util.util import CellVarsFile #, missing_units
26
+ from .util.util import CellVarsFile,load_nodes_from_config #, missing_units
24
27
  from bmtk.analyzer.utils import listify
25
28
 
26
29
  use_description = """
@@ -725,82 +728,92 @@ def connector_percent_matrix(csv_path: str = None, exclude_shell: bool = True,
725
728
  plt.tight_layout()
726
729
  plt.show()
727
730
 
728
- def raster_old(config=None,title=None,populations=['hippocampus']):
731
+ def raster(spikes_df: Optional[pd.DataFrame] = None, config: Optional[str] = None, network_name: Optional[str] = None,
732
+ ax: Optional[Axes] = None,tstart: Optional[float] = None,tstop: Optional[float] = None,
733
+ color_map: Optional[Dict[str, str]] = None) -> Axes:
729
734
  """
730
- old function probs dep
731
- """
732
- conf = util.load_config(config)
733
- spikes_path = os.path.join(conf["output"]["output_dir"],conf["output"]["spikes_file"])
734
- nodes = util.load_nodes_from_config(config)
735
- plot_spikes(nodes,spikes_path)
736
- return
737
-
738
- def raster(config=None,title=None,population=None,group_key='pop_name'):
739
- """
740
- old function probs dep or more to new spike module?
741
- """
742
- conf = util.load_config(config)
735
+ Plots a raster plot of neural spikes, with different colors for each population.
743
736
 
744
- cells_file = conf["networks"]["nodes"][0]["nodes_file"]
745
- cell_types_file = conf["networks"]["nodes"][0]["node_types_file"]
746
- spikes_path = os.path.join(conf["output"]["output_dir"],conf["output"]["spikes_file"])
747
-
748
- from bmtk.analyzer.visualization import spikes
749
- spikes.plot_spikes(cells_file,cell_types_file,spikes_path,population=population,group_key=group_key)
750
- return
751
-
752
- def plot_spikes(nodes, spikes_file,save_file=None):
753
- """
754
- old function probs dep
737
+ Parameters:
738
+ ----------
739
+ spikes_df : pd.DataFrame, optional
740
+ DataFrame containing spike data with columns 'timestamps', 'node_ids', and optional 'pop_name'.
741
+ config : str, optional
742
+ Path to the configuration file used to load node data.
743
+ network_name : str, optional
744
+ Specific network name to select from the configuration; if not provided, uses the first network.
745
+ ax : matplotlib.axes.Axes, optional
746
+ Axes on which to plot the raster; if None, a new figure and axes are created.
747
+ tstart : float, optional
748
+ Start time for filtering spikes; only spikes with timestamps greater than `tstart` will be plotted.
749
+ tstop : float, optional
750
+ Stop time for filtering spikes; only spikes with timestamps less than `tstop` will be plotted.
751
+ color_map : dict, optional
752
+ Dictionary specifying colors for each population. Keys should be population names, and values should be color values.
753
+
754
+ Returns:
755
+ -------
756
+ matplotlib.axes.Axes
757
+ Axes with the raster plot.
758
+
759
+ Notes:
760
+ -----
761
+ - If `config` is provided, the function merges population names from the node data with `spikes_df`.
762
+ - Each unique population (`pop_name`) in `spikes_df` will be represented by a different color if `color_map` is not specified.
763
+ - If `color_map` is provided, it should contain colors for all unique `pop_name` values in `spikes_df`.
755
764
  """
756
- import h5py
757
-
758
- spikes_h5 = h5py.File(spikes_file, 'r')
759
- spike_gids = np.array(spikes_h5['/spikes/gids'], dtype=np.uint)
760
- spike_times = np.array(spikes_h5['/spikes/timestamps'], dtype=np.float)
765
+ # Initialize axes if none provided
766
+ if ax is None:
767
+ _, ax = plt.subplots(1, 1)
768
+
769
+ # Filter spikes by time range if specified
770
+ if tstart is not None:
771
+ spikes_df = spikes_df[spikes_df['timestamps'] > tstart]
772
+ if tstop is not None:
773
+ spikes_df = spikes_df[spikes_df['timestamps'] < tstop]
774
+
775
+ # Load and merge node population data if config is provided
776
+ if config:
777
+ nodes = load_nodes_from_config(config)
778
+ if network_name:
779
+ nodes = nodes.get(network_name, {})
780
+ else:
781
+ nodes = list(nodes.values())[0] if nodes else {}
782
+ print("Grabbing first network; specify a network name to ensure correct node population is selected.")
761
783
 
762
- spikes = np.rot90(np.vstack((spike_gids,spike_times))) # Make array [[gid spiketime],[gid2 spiketime2]]
784
+ # Find common columns, but exclude the join key from the list
785
+ common_columns = spikes_df.columns.intersection(nodes.columns).tolist()
786
+ common_columns = [col for col in common_columns if col != 'node_ids'] # Remove our join key from the common list
763
787
 
764
- #spikes = spikes[spikes[:,0].argsort()] # Sort by cell number
788
+ # Drop all intersecting columns except the join key column from df2
789
+ spikes_df = spikes_df.drop(columns=common_columns)
790
+ # merge nodes and spikes df
791
+ spikes_df = spikes_df.merge(nodes['pop_name'], left_on='node_ids', right_index=True, how='left')
765
792
 
766
- """
767
- Author: Tyler Banks
768
- Loop through all spike files, create a list of when each cell spikes, plot.
769
- """
770
-
771
- cell_types = ['EC','CA3e','CA3o','CA3b','DGg','DGh','DGb']
772
- cell_nums = [30,63,8,8,384,32,32]
773
- d = [[] for _ in range(sum(cell_nums))]
774
-
775
- color_picker=['red','orange','yellow','green','blue','purple','black']
776
- colors = []
777
- offset=0
778
-
779
- for i, row in enumerate(spikes):
780
- d[int(row[0])+offset].append(row[1])
781
-
782
- for i, n in enumerate(cell_nums):
783
- for _ in range(n):
784
- colors.append(color_picker[i])
785
-
786
- fig, axs = plt.subplots(1,1)
787
- axs.eventplot(d,colors=colors)
788
- axs.set_title('Hipp BMTK')
789
- axs.set_ylabel('Cell Number')
790
- axs.set_xlabel('Time (ms)')
791
- axs.legend(cell_types[::-1])
792
-
793
- leg = axs.get_legend()
794
- for i,c in enumerate(color_picker):
795
- leg.legendHandles[-i-1].set_color(c)
793
+
794
+ # Get unique population names
795
+ unique_pop_names = spikes_df['pop_name'].unique()
796
796
 
797
- #splt.savefig('raster3_after_pycvode_fixes.png')
798
- if save_file:
799
- plt.savefig(save_file)
797
+ # Generate colors if no color_map is provided
798
+ if color_map is None:
799
+ cmap = plt.get_cmap('tab10') # Default colormap
800
+ color_map = {pop_name: cmap(i / len(unique_pop_names)) for i, pop_name in enumerate(unique_pop_names)}
801
+ else:
802
+ # Ensure color_map contains all population names
803
+ missing_colors = [pop for pop in unique_pop_names if pop not in color_map]
804
+ if missing_colors:
805
+ raise ValueError(f"color_map is missing colors for populations: {missing_colors}")
800
806
 
801
- plt.draw()
807
+ # Plot each population with its specified or generated color
808
+ for pop_name, group in spikes_df.groupby('pop_name'):
809
+ ax.scatter(group['timestamps'], group['node_ids'], label=pop_name, color=color_map[pop_name], s=0.5)
810
+
811
+ # Label axes
812
+ ax.set_xlabel("Time")
813
+ ax.set_ylabel("Node ID")
814
+ ax.legend(title="Population", loc='upper right', framealpha=0.9, markerfirst=False)
802
815
 
803
- return
816
+ return ax
804
817
 
805
818
  def plot_3d_positions(config=None, populations_list=None, group_by=None, title=None, save_file=None, subset=None):
806
819
  """
@@ -115,7 +115,7 @@ class SynapseTuner:
115
115
  - `set_up_cell()` should be called before setting up the synapse.
116
116
  - Synapse location, type, and properties are specified within `spec_syn_param` and `spec_settings`.
117
117
  """
118
- self.syn = getattr(h, self.conn['spec_syn_param']['level_of_detail'])(list(self.cell.all)[self.conn['spec_settings']['sec_id']](self.conn['spec_settings']['sec_x']))
118
+ self.syn = getattr(h, self.conn['spec_settings']['level_of_detail'])(list(self.cell.all)[self.conn['spec_settings']['sec_id']](self.conn['spec_settings']['sec_x']))
119
119
  for key, value in self.conn['spec_syn_param'].items():
120
120
  if isinstance(value, (int, float)): # Only create sliders for numeric values
121
121
  if hasattr(self.syn, key):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bmtool
3
- Version: 0.5.9.6
3
+ Version: 0.5.9.7
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -41,6 +41,7 @@ A collection of modules to make developing [Neuron](https://www.neuron.yale.edu/
41
41
  - [Getting Started](#Getting-Started)
42
42
  - [CLI](#CLI)
43
43
  - [Single Cell](#Single-Cell-Module)
44
+ - [Synapses](#synapses-module)
44
45
  - [Connectors](#Connectors-Module)
45
46
  - [Bmplot](#bmplot-Module)
46
47
  - [Graphs](#graphs-module)
@@ -335,6 +336,12 @@ bmtool util cell --hoc segmented_template.hoc vhsegbuild
335
336
  ```
336
337
  ex: [https://github.com/tjbanks/two-cell-hco](https://github.com/tjbanks/two-cell-hco)
337
338
 
339
+ ### Synapses Module
340
+ -[SynapticTuner](#synaptictuner)
341
+
342
+ #### SynapticTuner - Aids in the tuning of synapses by printing out synaptic properties and giving the user sliders in a Jupyter notebook to tune the synapse. For more info view the example [here](examples/synapses/synaptic_tuner.ipynb)
343
+
344
+
338
345
  ### Connectors Module
339
346
  - [UnidirectionConnector](#unidirectional-connector---unidirectional-connections-in-bmtk-network-model-with-given-probability-within-a-single-population-or-between-two-populations)
340
347
  - [ReciprocalConnector](#recipical-connector---buiilding-connections-in-bmtk-network-model-with-reciprocal-probability-within-a-single-population-or-between-two-populations)
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
6
6
 
7
7
  setup(
8
8
  name="bmtool",
9
- version='0.5.9.6',
9
+ version='0.5.9.7',
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