bmtool 0.5.7.2__tar.gz → 0.5.9__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.7.2 → bmtool-0.5.9}/PKG-INFO +1 -1
  2. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/bmplot.py +64 -28
  3. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/connectors.py +15 -8
  4. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/PKG-INFO +1 -1
  5. {bmtool-0.5.7.2 → bmtool-0.5.9}/setup.py +1 -1
  6. {bmtool-0.5.7.2 → bmtool-0.5.9}/LICENSE +0 -0
  7. {bmtool-0.5.7.2 → bmtool-0.5.9}/README.md +0 -0
  8. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/SLURM.py +0 -0
  9. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/__init__.py +0 -0
  10. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/__main__.py +0 -0
  11. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/debug/__init__.py +0 -0
  12. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/debug/commands.py +0 -0
  13. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/debug/debug.py +0 -0
  14. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/graphs.py +0 -0
  15. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/manage.py +0 -0
  16. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/plot_commands.py +0 -0
  17. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/singlecell.py +0 -0
  18. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/synapses.py +0 -0
  19. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/util/__init__.py +0 -0
  20. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/util/commands.py +0 -0
  21. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/util/neuron/__init__.py +0 -0
  22. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/util/neuron/celltuner.py +0 -0
  23. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool/util/util.py +0 -0
  24. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/SOURCES.txt +0 -0
  25. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/dependency_links.txt +0 -0
  26. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/entry_points.txt +0 -0
  27. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/requires.txt +0 -0
  28. {bmtool-0.5.7.2 → bmtool-0.5.9}/bmtool.egg-info/top_level.txt +0 -0
  29. {bmtool-0.5.7.2 → bmtool-0.5.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bmtool
3
- Version: 0.5.7.2
3
+ Version: 0.5.9
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -480,8 +480,14 @@ def plot_connection_info(text, num, source_labels,target_labels, title, syn_info
480
480
  # Loop over data dimensions and create text annotations.
481
481
  for i in range(num_source):
482
482
  for j in range(num_target):
483
- edge_info = text[i,j]
484
- graph_dict[str(source_labels[i])+'2'+str(target_labels[j])] = edge_info
483
+ edge_info = text[i, j]
484
+
485
+ # Initialize the dictionary for the source node if not already done
486
+ if source_labels[i] not in graph_dict:
487
+ graph_dict[source_labels[i]] = {}
488
+
489
+ # Add edge info for the target node
490
+ graph_dict[source_labels[i]][target_labels[j]] = edge_info
485
491
  if syn_info =='2' or syn_info =='3':
486
492
  if num_source > 8 and num_source <20:
487
493
  fig_text = ax1.text(j, i, edge_info,
@@ -726,71 +732,101 @@ def plot_spikes(nodes, spikes_file,save_file=None):
726
732
 
727
733
  return
728
734
 
729
- def plot_3d_positions(config=None,populations_list=None,group_by=None,title=None,save_file=None):
735
+ def plot_3d_positions(config=None, populations_list=None, group_by=None, title=None, save_file=None, subset=None):
730
736
  """
731
- plots a 3D graph of all cells with x,y,z location
732
- config: A BMTK simulation config
733
- populations_list: Which network(s) to plot
734
- group_by: How to name cell groups
735
- title: plot title
736
- save_file: If plot should be saved
737
+ Plots a 3D graph of all cells with x, y, z location.
738
+
739
+ Parameters:
740
+ - config: A BMTK simulation config
741
+ - populations_list: Which network(s) to plot
742
+ - group_by: How to name cell groups
743
+ - title: Plot title
744
+ - save_file: If plot should be saved
745
+ - subset: Take every Nth row. This will make plotting large network graphs easier to see.
737
746
  """
738
747
 
739
748
  if not config:
740
749
  raise Exception("config not defined")
741
- if populations_list == None:
750
+
751
+ if populations_list is None:
742
752
  populations_list = "all"
753
+
754
+ # Set group keys (e.g., node types)
743
755
  group_keys = group_by
744
- if title == None:
756
+ if title is None:
745
757
  title = "3D positions"
746
758
 
759
+ # Load nodes from the configuration
747
760
  nodes = util.load_nodes_from_config(config)
748
761
 
762
+ # Get the list of populations to plot
749
763
  if 'all' in populations_list:
750
764
  populations = list(nodes)
751
765
  else:
752
766
  populations = populations_list.split(",")
753
-
767
+
768
+ # Split group_by into list
754
769
  group_keys = group_keys.split(",")
755
- group_keys += (len(populations)-len(group_keys)) * ["node_type_id"] #Extend the array to default values if not enough given
756
- fig = plt.figure(figsize=(10,10))
770
+ group_keys += (len(populations) - len(group_keys)) * ["node_type_id"] # Extend the array to default values if not enough given
771
+ if len(group_keys) > 1:
772
+ raise Exception("Only one group by is supported currently!")
773
+
774
+ fig = plt.figure(figsize=(10, 10))
757
775
  ax = fig.add_subplot(projection='3d')
758
776
  handles = []
759
- for nodes_key,group_key in zip(list(nodes),group_keys):
760
- if 'all' not in populations and nodes_key not in populations:
761
- continue
762
-
763
- nodes_df = nodes[nodes_key]
764
777
 
778
+ for pop in (list(nodes)):
779
+
780
+ if 'all' not in populations and pop not in populations:
781
+ continue
782
+
783
+ nodes_df = nodes[pop]
784
+ group_key = group_keys[0]
785
+
786
+ # If group_key is provided, ensure the column exists in the dataframe
765
787
  if group_key is not None:
766
788
  if group_key not in nodes_df:
767
- raise Exception('Could not find column {}'.format(group_key))
789
+ raise Exception(f"Could not find column '{group_key}' in {pop}")
790
+
768
791
  groupings = nodes_df.groupby(group_key)
769
-
770
792
  n_colors = nodes_df[group_key].nunique()
771
- color_norm = colors.Normalize(vmin=0, vmax=(n_colors-1))
793
+ color_norm = colors.Normalize(vmin=0, vmax=(n_colors - 1))
772
794
  scalar_map = cmx.ScalarMappable(norm=color_norm, cmap='hsv')
773
- color_map = [scalar_map.to_rgba(i) for i in range(0, n_colors)]
795
+ color_map = [scalar_map.to_rgba(i) for i in range(n_colors)]
774
796
  else:
775
797
  groupings = [(None, nodes_df)]
776
798
  color_map = ['blue']
777
799
 
800
+ # Loop over groupings and plot
778
801
  for color, (group_name, group_df) in zip(color_map, groupings):
779
- if "pos_x" not in group_df: #could also check model type == virtual
780
- continue #can't plot them if there isn't an xy coordinate (may be virtual)
781
- h = ax.scatter(group_df["pos_x"],group_df["pos_y"],group_df["pos_z"],color=color,label=group_name)
802
+ if "pos_x" not in group_df or "pos_y" not in group_df or "pos_z" not in group_df:
803
+ print(f"Warning: Missing position columns in group '{group_name}' for {pop}. Skipping this group.")
804
+ continue # Skip if position columns are missing
805
+
806
+ # Subset the dataframe by taking every Nth row if subset is provided
807
+ if subset is not None:
808
+ group_df = group_df.iloc[::subset]
809
+
810
+ h = ax.scatter(group_df["pos_x"], group_df["pos_y"], group_df["pos_z"], color=color, label=group_name)
782
811
  handles.append(h)
812
+
783
813
  if not handles:
814
+ print("No data to plot.")
784
815
  return
816
+
817
+ # Set plot title and legend
785
818
  plt.title(title)
786
819
  plt.legend(handles=handles)
787
820
 
821
+ # Draw the plot
788
822
  plt.draw()
789
823
 
824
+ # Save the plot if save_file is provided
790
825
  if save_file:
791
826
  plt.savefig(save_file)
792
- notebook = is_notebook
793
- if notebook == False:
827
+
828
+ # Show the plot if running outside of a notebook
829
+ if not is_notebook:
794
830
  plt.show()
795
831
 
796
832
  return
@@ -580,9 +580,11 @@ class ReciprocalConnector(AbstractConnector):
580
580
  self.source = source
581
581
  self.target = target
582
582
  if self.source is None or len(self.source) == 0:
583
- raise ValueError("Source nodes do not exists")
583
+ src_str, trg_str = self.get_nodes_info()
584
+ raise ValueError(f"{src_str} nodes do not exists")
584
585
  if self.target is None or len(self.target) == 0:
585
- raise ValueError("Target nodes do not exists")
586
+ src_str, trg_str = self.get_nodes_info()
587
+ raise ValueError(f"{trg_str} nodes do not exists")
586
588
 
587
589
  # Setup nodes
588
590
  self.recurrent = is_same_pop(self.source, self.target, quick=self.quick)
@@ -1130,9 +1132,11 @@ class UnidirectionConnector(AbstractConnector):
1130
1132
  self.source = source
1131
1133
  self.target = target
1132
1134
  if self.source is None or len(self.source) == 0:
1133
- raise ValueError("Source nodes do not exists")
1135
+ src_str, trg_str = self.get_nodes_info()
1136
+ raise ValueError(f"{src_str} nodes do not exists")
1134
1137
  if self.target is None or len(self.target) == 0:
1135
- raise ValueError("Target nodes do not exists")
1138
+ src_str, trg_str = self.get_nodes_info()
1139
+ raise ValueError(f"{trg_str} nodes do not exists")
1136
1140
  self.n_pair = len(self.source) * len(self.target)
1137
1141
 
1138
1142
  def edge_params(self):
@@ -1179,6 +1183,7 @@ class UnidirectionConnector(AbstractConnector):
1179
1183
  + src_str + "\n to " + trg_str,flush=True)
1180
1184
 
1181
1185
  # Make random connections
1186
+
1182
1187
  p_arg = self.p_arg(source, target)
1183
1188
  p = self.p(p_arg)
1184
1189
  possible = p > 0
@@ -1274,8 +1279,9 @@ class GapJunction(UnidirectionConnector):
1274
1279
  def setup_nodes(self, source=None, target=None):
1275
1280
  super().setup_nodes(source=source, target=target)
1276
1281
  if len(self.source) != len(self.target):
1277
- raise ValueError("Source and target must be the same for "
1278
- "gap junction.")
1282
+ src_str, trg_str = self.get_nodes_info()
1283
+ raise ValueError(f"Source and target must be the same for "
1284
+ f"gap junction. Nodes are {src_str} and {trg_str}")
1279
1285
  self.n_source = len(self.source)
1280
1286
 
1281
1287
  def make_connection(self, source, target, *args, **kwargs):
@@ -1500,8 +1506,9 @@ class OneToOneSequentialConnector(AbstractConnector):
1500
1506
  source, target = target, source
1501
1507
  if self.target_count == 0:
1502
1508
  if source is None or len(source) == 0:
1503
- raise ValueError(("Target" if self.partition_source else
1504
- "Source") + " nodes do not exists")
1509
+ src_str, trg_str = self.get_nodes_info()
1510
+ raise ValueError((f"{trg_str}" if self.partition_source else
1511
+ f"{src_str}") + " nodes do not exists")
1505
1512
  self.source = source
1506
1513
  self.n_source = len(source)
1507
1514
  if target is None or len(target) == 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bmtool
3
- Version: 0.5.7.2
3
+ Version: 0.5.9
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.5.7.2',
9
+ version='0.5.9',
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