bmtool 0.5.9__py3-none-any.whl → 0.5.9.5__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 +70 -0
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/METADATA +1 -1
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/RECORD +7 -7
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/WHEEL +1 -1
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/LICENSE +0 -0
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/entry_points.txt +0 -0
- {bmtool-0.5.9.dist-info → bmtool-0.5.9.5.dist-info}/top_level.txt +0 -0
bmtool/bmplot.py
CHANGED
@@ -405,6 +405,76 @@ def connection_histogram(config=None,nodes=None,edges=None,sources=[],targets=[]
|
|
405
405
|
tids = []
|
406
406
|
util.relation_matrix(config,nodes,edges,sources,targets,sids,tids,prepend_pop,relation_func=connection_pair_histogram,synaptic_info=synaptic_info)
|
407
407
|
|
408
|
+
def connection_distance(config: str,source: str,target: str,
|
409
|
+
source_cell_id: int,target_id_type: str) -> None:
|
410
|
+
"""
|
411
|
+
Plots the 3D spatial distribution of target nodes relative to a source node
|
412
|
+
and a histogram of distances from the source node to each target node.
|
413
|
+
|
414
|
+
Parameters:
|
415
|
+
----------
|
416
|
+
config: (str) A BMTK simulation config
|
417
|
+
sources: (str) network name(s) to plot
|
418
|
+
targets: (str) network name(s) to plot
|
419
|
+
source_cell_id : (int) ID of the source cell for calculating distances to target nodes.
|
420
|
+
target_id_type : (str) A string to filter target nodes based off the target_query.
|
421
|
+
|
422
|
+
"""
|
423
|
+
if not config:
|
424
|
+
raise Exception("config not defined")
|
425
|
+
if not source or not target:
|
426
|
+
raise Exception("Sources or targets not defined")
|
427
|
+
#if source != target:
|
428
|
+
#raise Exception("Code is setup for source and target to be the same! Look at source code for function to add feature")
|
429
|
+
|
430
|
+
# Load nodes and edges based on config file
|
431
|
+
nodes, edges = util.load_nodes_edges_from_config(config)
|
432
|
+
|
433
|
+
edge_network = source + "_to_" + target
|
434
|
+
node_network = source
|
435
|
+
|
436
|
+
# Filter edges to obtain connections originating from the source node
|
437
|
+
edge = edges[edge_network]
|
438
|
+
edge = edge[edge['source_node_id'] == source_cell_id]
|
439
|
+
if target_id_type:
|
440
|
+
edge = edge[edge['target_query'].str.contains(target_id_type, na=False)]
|
441
|
+
|
442
|
+
target_node_ids = edge['target_node_id']
|
443
|
+
|
444
|
+
# Filter nodes to obtain only the target and source nodes
|
445
|
+
node = nodes[node_network]
|
446
|
+
target_nodes = node.loc[node.index.isin(target_node_ids)]
|
447
|
+
source_node = node.loc[node.index == source_cell_id]
|
448
|
+
|
449
|
+
# Calculate distances between source node and each target node
|
450
|
+
target_positions = target_nodes[['pos_x', 'pos_y', 'pos_z']].values
|
451
|
+
source_position = np.array([source_node['pos_x'], source_node['pos_y'], source_node['pos_z']]).ravel() # Ensure 1D shape
|
452
|
+
distances = np.linalg.norm(target_positions - source_position, axis=1)
|
453
|
+
|
454
|
+
# Plot positions of source and target nodes in 3D space
|
455
|
+
fig = plt.figure(figsize=(8, 6))
|
456
|
+
ax = fig.add_subplot(111, projection='3d')
|
457
|
+
|
458
|
+
ax.scatter(target_nodes['pos_x'], target_nodes['pos_y'], target_nodes['pos_z'], c='blue', label="target cells")
|
459
|
+
ax.scatter(source_node['pos_x'], source_node['pos_y'], source_node['pos_z'], c='red', label="source cell")
|
460
|
+
|
461
|
+
# Optional: Add text annotations for distances
|
462
|
+
# for i, distance in enumerate(distances):
|
463
|
+
# ax.text(target_nodes['pos_x'].iloc[i], target_nodes['pos_y'].iloc[i], target_nodes['pos_z'].iloc[i],
|
464
|
+
# f'{distance:.2f}', color='black', fontsize=8, ha='center')
|
465
|
+
|
466
|
+
plt.legend()
|
467
|
+
plt.show()
|
468
|
+
|
469
|
+
# Plot distances in a separate 2D plot
|
470
|
+
plt.figure(figsize=(8, 6))
|
471
|
+
plt.hist(distances, bins=20, color='blue', edgecolor='black')
|
472
|
+
plt.xlabel("Distance")
|
473
|
+
plt.ylabel("Count")
|
474
|
+
plt.title("Distance from Source Node to Each Target Node")
|
475
|
+
plt.grid(True)
|
476
|
+
plt.show()
|
477
|
+
|
408
478
|
def edge_histogram_matrix(config=None,sources = None,targets=None,sids=None,tids=None,no_prepend_pop=None,edge_property = None,time = None,time_compare = None,report=None,title=None,save_file=None):
|
409
479
|
"""
|
410
480
|
write about function here
|
@@ -1,7 +1,7 @@
|
|
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=
|
4
|
+
bmtool/bmplot.py,sha256=pdwj1BG-NjVKb3sb-Sya2_9AjkqMm_iooQbEOuy5l3w,50931
|
5
5
|
bmtool/connectors.py,sha256=8FbQXewdI9Q0Dlx6cVbM3hPKt9ead4WEDkG22tyKa2o,72187
|
6
6
|
bmtool/graphs.py,sha256=K8BiughRUeXFVvAgo8UzrwpSClIVg7UfmIcvtEsEsk0,6020
|
7
7
|
bmtool/manage.py,sha256=_lCU0qBQZ4jSxjzAJUd09JEetb--cud7KZgxQFbLGSY,657
|
@@ -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.9.dist-info/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
|
20
|
-
bmtool-0.5.9.dist-info/METADATA,sha256=
|
21
|
-
bmtool-0.5.9.dist-info/WHEEL,sha256=
|
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,,
|
19
|
+
bmtool-0.5.9.5.dist-info/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
|
20
|
+
bmtool-0.5.9.5.dist-info/METADATA,sha256=v8IKa7wbwiu3s8oA-VxmYBR1xhkicRoAgakcotSpg0E,24131
|
21
|
+
bmtool-0.5.9.5.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
|
22
|
+
bmtool-0.5.9.5.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
|
23
|
+
bmtool-0.5.9.5.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
|
24
|
+
bmtool-0.5.9.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|