bmtool 0.5.7.2__py3-none-any.whl → 0.5.9__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/bmplot.py +64 -28
- bmtool/connectors.py +15 -8
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/METADATA +1 -1
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/RECORD +8 -8
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/WHEEL +1 -1
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/LICENSE +0 -0
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/entry_points.txt +0 -0
- {bmtool-0.5.7.2.dist-info → bmtool-0.5.9.dist-info}/top_level.txt +0 -0
bmtool/bmplot.py
CHANGED
@@ -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
|
-
|
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
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
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
|
-
|
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
|
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"]
|
756
|
-
|
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(
|
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(
|
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
|
780
|
-
|
781
|
-
|
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
|
-
|
793
|
-
if
|
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
|
bmtool/connectors.py
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
1278
|
-
|
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
|
-
|
1504
|
-
|
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,8 +1,8 @@
|
|
1
1
|
bmtool/SLURM.py,sha256=AX5MKV7dD-XwS8SROnW1IyesZ3jDwMf0txO6mHxTbuw,13694
|
2
2
|
bmtool/__init__.py,sha256=ZStTNkAJHJxG7Pwiy5UgCzC4KlhMS5pUNPtUJZVwL_Y,136
|
3
3
|
bmtool/__main__.py,sha256=TmFkmDxjZ6250nYD4cgGhn-tbJeEm0u-EMz2ajAN9vE,650
|
4
|
-
bmtool/bmplot.py,sha256=
|
5
|
-
bmtool/connectors.py,sha256=
|
4
|
+
bmtool/bmplot.py,sha256=XN7XPhhVFv6352KciBiPN59wU9x0hoNQ67caLn1ZTZk,47931
|
5
|
+
bmtool/connectors.py,sha256=8FbQXewdI9Q0Dlx6cVbM3hPKt9ead4WEDkG22tyKa2o,72187
|
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
|
@@ -16,9 +16,9 @@ bmtool/util/commands.py,sha256=zJF-fiLk0b8LyzHDfvewUyS7iumOxVnj33IkJDzux4M,64396
|
|
16
16
|
bmtool/util/util.py,sha256=24E5rUoDU86nqypDF4uZJkuJKO1BrwrQE8lZzAxu1kw,56770
|
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.5.
|
20
|
-
bmtool-0.5.
|
21
|
-
bmtool-0.5.
|
22
|
-
bmtool-0.5.
|
23
|
-
bmtool-0.5.
|
24
|
-
bmtool-0.5.
|
19
|
+
bmtool-0.5.9.dist-info/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
|
20
|
+
bmtool-0.5.9.dist-info/METADATA,sha256=uqQ0aU9ChnJupHjVXUpTzu0IEfesh6rfY2etN5qg4zM,24129
|
21
|
+
bmtool-0.5.9.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
22
|
+
bmtool-0.5.9.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
|
23
|
+
bmtool-0.5.9.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
|
24
|
+
bmtool-0.5.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|