nettracer3d 0.7.3__py3-none-any.whl → 0.7.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.
Potentially problematic release.
This version of nettracer3d might be problematic. Click here for more details.
- nettracer3d/community_extractor.py +17 -39
- nettracer3d/modularity.py +41 -264
- nettracer3d/nettracer.py +31 -99
- nettracer3d/nettracer_gui.py +506 -271
- nettracer3d/network_analysis.py +0 -178
- nettracer3d/segmenter.py +84 -724
- nettracer3d/segmenter_GPU.py +1286 -0
- nettracer3d/simple_network.py +2 -150
- {nettracer3d-0.7.3.dist-info → nettracer3d-0.7.5.dist-info}/METADATA +8 -7
- nettracer3d-0.7.5.dist-info/RECORD +21 -0
- {nettracer3d-0.7.3.dist-info → nettracer3d-0.7.5.dist-info}/WHEEL +1 -1
- nettracer3d-0.7.3.dist-info/RECORD +0 -20
- {nettracer3d-0.7.3.dist-info → nettracer3d-0.7.5.dist-info}/entry_points.txt +0 -0
- {nettracer3d-0.7.3.dist-info → nettracer3d-0.7.5.dist-info}/licenses/LICENSE +0 -0
- {nettracer3d-0.7.3.dist-info → nettracer3d-0.7.5.dist-info}/top_level.txt +0 -0
nettracer3d/simple_network.py
CHANGED
|
@@ -119,109 +119,6 @@ def geometric_positions(centroids, shape):
|
|
|
119
119
|
return xy_pos, z_pos
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def show_community_network(excel_file_path, geometric = False, geo_info = None, directory = None):
|
|
123
|
-
|
|
124
|
-
if type(excel_file_path) == str:
|
|
125
|
-
master_list = read_excel_to_lists(excel_file_path)
|
|
126
|
-
else:
|
|
127
|
-
master_list = excel_file_path
|
|
128
|
-
|
|
129
|
-
edges = list(zip(master_list[0], master_list[1]))
|
|
130
|
-
|
|
131
|
-
# Create a graph
|
|
132
|
-
G = nx.Graph()
|
|
133
|
-
|
|
134
|
-
# Add edges from the DataFrame
|
|
135
|
-
G.add_edges_from(edges)
|
|
136
|
-
|
|
137
|
-
# Print basic information about the graph
|
|
138
|
-
num_nodes = G.number_of_nodes()
|
|
139
|
-
num_edges = G.number_of_edges()
|
|
140
|
-
|
|
141
|
-
print("Number of nodes:", num_nodes)
|
|
142
|
-
print("Number of edges:", num_edges)
|
|
143
|
-
|
|
144
|
-
# Calculate the average degree connectivity
|
|
145
|
-
average_degree_connectivity = nx.average_degree_connectivity(G)
|
|
146
|
-
print("Average degree connectivity:", average_degree_connectivity)
|
|
147
|
-
|
|
148
|
-
# Calculate the average number of edges attached to a node
|
|
149
|
-
average_edges_per_node = num_nodes/num_edges
|
|
150
|
-
print("Average edges per node:", average_edges_per_node)
|
|
151
|
-
|
|
152
|
-
# Calculate and display modularity for each connected component
|
|
153
|
-
connected_components = list(nx.connected_components(G))
|
|
154
|
-
for i, component in enumerate(connected_components):
|
|
155
|
-
subgraph = G.subgraph(component)
|
|
156
|
-
component_communities = list(community.label_propagation_communities(subgraph))
|
|
157
|
-
modularity = community.modularity(subgraph, component_communities)
|
|
158
|
-
print(f"Label propogation modularity for component with {len(component)} nodes: {modularity}")
|
|
159
|
-
|
|
160
|
-
# Visualize the graph with nodes colored by community
|
|
161
|
-
pos = nx.spring_layout(G)
|
|
162
|
-
|
|
163
|
-
# Detect communities using label propagation
|
|
164
|
-
communities = list(community.label_propagation_communities(G))
|
|
165
|
-
|
|
166
|
-
print(f"label prop communities: {communities}")
|
|
167
|
-
|
|
168
|
-
# Assign a color to each node based on its community
|
|
169
|
-
node_colors = {}
|
|
170
|
-
for i, community_nodes in enumerate(communities):
|
|
171
|
-
color = mcolors.to_hex(plt.cm.tab10(i / len(communities))[:3])
|
|
172
|
-
for node in community_nodes:
|
|
173
|
-
node_colors[node] = color
|
|
174
|
-
|
|
175
|
-
if geometric:
|
|
176
|
-
for node in list(G.nodes()):
|
|
177
|
-
if node not in geo_info[0]:
|
|
178
|
-
G.remove_node(node)
|
|
179
|
-
print(f"Removing node {node} from network visualization (no centroid - likely due to downsampling when finding centroids)")
|
|
180
|
-
|
|
181
|
-
pos, z_pos = geometric_positions(geo_info[0], geo_info[1])
|
|
182
|
-
node_sizes_list = [z_pos[node] for node in G.nodes()]
|
|
183
|
-
node_color_list = [node_colors[node] for node in G.nodes()]
|
|
184
|
-
nx.draw(G, pos, with_labels=True, font_color='black', font_weight='bold', node_size = node_sizes_list, node_color = node_color_list, alpha=0.8, font_size = 12)
|
|
185
|
-
else:
|
|
186
|
-
# Get color list for nodes
|
|
187
|
-
node_color_list = [node_colors[node] for node in G.nodes()]
|
|
188
|
-
# Draw the graph with node colors
|
|
189
|
-
nx.draw(G, pos, with_labels=True, font_color='black', font_weight='bold', node_size=100, node_color = node_color_list, alpha = 0.8)
|
|
190
|
-
|
|
191
|
-
if directory is not None:
|
|
192
|
-
plt.savefig(f'{directory}/community_label_propogation_network_plot.png')
|
|
193
|
-
|
|
194
|
-
plt.show()
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def modularity(G, solo_mod):
|
|
198
|
-
|
|
199
|
-
if not solo_mod:
|
|
200
|
-
|
|
201
|
-
# Calculate and display modularity for each connected component
|
|
202
|
-
return_dict = {}
|
|
203
|
-
connected_components = list(nx.connected_components(G))
|
|
204
|
-
for i, component in enumerate(connected_components):
|
|
205
|
-
subgraph = G.subgraph(component)
|
|
206
|
-
component_communities = list(community.label_propagation_communities(subgraph))
|
|
207
|
-
modularity = community.modularity(subgraph, component_communities)
|
|
208
|
-
print(f"Label propogation modularity for component with {len(component)} nodes: {modularity}")
|
|
209
|
-
return_dict[len(component)] = modularity
|
|
210
|
-
|
|
211
|
-
return return_dict
|
|
212
|
-
|
|
213
|
-
else:
|
|
214
|
-
# Step 1: Detect communities using label propagation
|
|
215
|
-
communities = list(community.label_propagation_communities(G))
|
|
216
|
-
|
|
217
|
-
# Step 2: Calculate modularity
|
|
218
|
-
modularity = community.modularity(G, communities)
|
|
219
|
-
|
|
220
|
-
print(f"Modularity of network is {modularity}")
|
|
221
|
-
|
|
222
|
-
return modularity
|
|
223
|
-
|
|
224
|
-
|
|
225
122
|
def show_simple_network(excel_file_path, geometric = False, geo_info = None, directory = None):
|
|
226
123
|
|
|
227
124
|
if type(excel_file_path) == str:
|
|
@@ -248,7 +145,7 @@ def show_simple_network(excel_file_path, geometric = False, geo_info = None, dir
|
|
|
248
145
|
nx.draw(G, pos, with_labels=True, font_color='black', font_weight='bold', node_size= node_sizes_list, alpha=0.8, font_size = 12)
|
|
249
146
|
else:
|
|
250
147
|
# Visualize the graph with different edge colors for each community
|
|
251
|
-
pos = nx.spring_layout(G)
|
|
148
|
+
pos = nx.spring_layout(G, iterations = 15)
|
|
252
149
|
nx.draw(G, pos, with_labels=True, font_color='red', font_weight='bold', node_size=10)
|
|
253
150
|
|
|
254
151
|
if directory is not None:
|
|
@@ -372,49 +269,4 @@ def show_identity_network(excel_file_path, node_identities, geometric=False, geo
|
|
|
372
269
|
|
|
373
270
|
if __name__ == "__main__":
|
|
374
271
|
|
|
375
|
-
|
|
376
|
-
excel_file_path = input("Excel file?: ")
|
|
377
|
-
|
|
378
|
-
master_list = read_excel_to_lists(excel_file_path)
|
|
379
|
-
|
|
380
|
-
edges = zip(master_list[0], master_list[1])
|
|
381
|
-
|
|
382
|
-
#df = pd.read_excel(excel_file_path)
|
|
383
|
-
|
|
384
|
-
# Create a graph
|
|
385
|
-
G = nx.Graph()
|
|
386
|
-
|
|
387
|
-
# Add edges from the DataFrame
|
|
388
|
-
#edges = df.values # Assuming the columns are named "Node1" and "Node2"
|
|
389
|
-
G.add_edges_from(edges)
|
|
390
|
-
|
|
391
|
-
# Print basic information about the graph
|
|
392
|
-
print("Number of nodes:", G.number_of_nodes())
|
|
393
|
-
print("Number of edges:", G.number_of_edges())
|
|
394
|
-
|
|
395
|
-
# Calculate the average degree connectivity
|
|
396
|
-
#average_degree_connectivity = nx.average_degree_connectivity(G)
|
|
397
|
-
#print("Average degree connectivity:", average_degree_connectivity)
|
|
398
|
-
|
|
399
|
-
# Calculate the average number of edges attached to a node
|
|
400
|
-
#average_edges_per_node = sum(k * v for k, v in average_degree_connectivity.items()) / G.number_of_nodes()
|
|
401
|
-
#print("Average edges per node:", average_edges_per_node)
|
|
402
|
-
|
|
403
|
-
# Visualize the graph with different edge colors for each community
|
|
404
|
-
pos = nx.spring_layout(G)
|
|
405
|
-
nx.draw(G, pos, with_labels=True, font_color='red', font_weight='bold', node_size=10)
|
|
406
|
-
|
|
407
|
-
#connected_components = list(nx.connected_components(G))
|
|
408
|
-
#for i, component in enumerate(connected_components):
|
|
409
|
-
#communities = community.label_propagation_communities(G.subgraph(component))
|
|
410
|
-
|
|
411
|
-
# Assign a different color to each community
|
|
412
|
-
#colors = [mcolors.to_hex(plt.cm.tab10(i / len(connected_components))[:3]) for _ in range(len(component))]
|
|
413
|
-
|
|
414
|
-
#nx.draw_networkx_edges(G, pos, edgelist=G.subgraph(component).edges(), edge_color=colors)
|
|
415
|
-
|
|
416
|
-
#num_nodes = len(component)
|
|
417
|
-
#modularity = community.modularity(G.subgraph(component), communities)
|
|
418
|
-
#print(f"Modularity for component with {num_nodes} nodes:", modularity)
|
|
419
|
-
|
|
420
|
-
plt.show()
|
|
272
|
+
pass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nettracer3d
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.5
|
|
4
4
|
Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
|
|
5
5
|
Author-email: Liam McLaughlin <liamm@wustl.edu>
|
|
6
6
|
Project-URL: Documentation, https://nettracer3d.readthedocs.io/en/latest/
|
|
@@ -22,7 +22,6 @@ Requires-Dist: opencv-python-headless
|
|
|
22
22
|
Requires-Dist: openpyxl
|
|
23
23
|
Requires-Dist: pandas
|
|
24
24
|
Requires-Dist: napari
|
|
25
|
-
Requires-Dist: python-louvain
|
|
26
25
|
Requires-Dist: tifffile
|
|
27
26
|
Requires-Dist: qtrangeslider
|
|
28
27
|
Requires-Dist: PyQt6
|
|
@@ -73,9 +72,11 @@ NetTracer3D is free to use/fork for academic/nonprofit use so long as citation i
|
|
|
73
72
|
|
|
74
73
|
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
|
75
74
|
|
|
76
|
-
-- Version 0.7.
|
|
75
|
+
-- Version 0.7.5 Updates --
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
* Bug fixes
|
|
78
|
+
* The segmenter GPU option has been updated to include 2D segmentation and to also be able to load/save models.
|
|
79
|
+
* A new function (Analyze -> Stats -> Calculate Generic Network Histograms has been added (gives a few histograms about the network and their corresponding tables. Previously stats mostly gave averages).
|
|
80
|
+
* The function 'Analyze -> Data/Overlays -> Get Hub Information' now looks for the upper hubs unique to each separate network component. It will also ignore smaller components that have too few nodes to be reasonably considered having hubs relative to the threshold the user sets.
|
|
81
|
+
* The function to split non-connected nodes has been improved a bit (its faster albeit still slowish - its a tough operation)
|
|
82
|
+
* Removed python-louvain dependence, now uses networkx for Louvain partitioning. (On top of this, now the user can set the random seed they desire for partitioning for reproducibility purposes).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
nettracer3d/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
nettracer3d/community_extractor.py,sha256=vzckLJfubplcQUAIr4UNgezxUJIdeFmH6CTWk8jYjOw,23739
|
|
3
|
+
nettracer3d/modularity.py,sha256=1Qg8Vc7Cl8nkkJxz_Z8tNR8hK1b-ZrFrMVUl4SKGLY8,21825
|
|
4
|
+
nettracer3d/morphology.py,sha256=jyDjYzrZ4LvI5jOyw8DLsxmo-i5lpqHsejYpW7Tq7Mo,19786
|
|
5
|
+
nettracer3d/nettracer.py,sha256=2xAImidzKkYEA_5Ja18v9vMUYgFUEwJB8v8-QCKfi8A,213593
|
|
6
|
+
nettracer3d/nettracer_gui.py,sha256=3NCvn39toIldZPkZRL-Z7N5jei4uVMTiKC8qDwYRpqw,435381
|
|
7
|
+
nettracer3d/network_analysis.py,sha256=h-5yzUWdE0hcWYy8wcBA5LV1bRhdqiMnKbQLrRzb1Sw,41443
|
|
8
|
+
nettracer3d/network_draw.py,sha256=F7fw6Pcf4qWOhdKwLmhwqWdschbDlHzwCVolQC9imeU,14117
|
|
9
|
+
nettracer3d/node_draw.py,sha256=k3sCTfUCJs3aH1C1q1gTNxDz9EAQbBd1hsUIJajxRx8,9823
|
|
10
|
+
nettracer3d/proximity.py,sha256=nlVBXzJ6r84TlP8UaLcdamWifYn-jfVIF0uB-56k_Js,24752
|
|
11
|
+
nettracer3d/run.py,sha256=xYeaAc8FCx8MuzTGyL3NR3mK7WZzffAYAH23bNRZYO4,127
|
|
12
|
+
nettracer3d/segmenter.py,sha256=BD9vxnblDKXfmR8hLP_iVqqfVngH6opz4Q7V6sxc2KM,60062
|
|
13
|
+
nettracer3d/segmenter_GPU.py,sha256=Fqr0Za6X2ss4rfaziqOhvhBfbGDPHkHw6fVxs39lZaU,53862
|
|
14
|
+
nettracer3d/simple_network.py,sha256=Ft_81VhVQ3rqoXvuYnsckXuxCcQSJfakhOfkFaclxZY,9340
|
|
15
|
+
nettracer3d/smart_dilate.py,sha256=69z9Bn8xtA7rkhcVpqd1PxRSxxRFnIQse9lc2-LU4TU,25879
|
|
16
|
+
nettracer3d-0.7.5.dist-info/licenses/LICENSE,sha256=gM207DhJjWrxLuEWXl0Qz5ISbtWDmADfjHp3yC2XISs,888
|
|
17
|
+
nettracer3d-0.7.5.dist-info/METADATA,sha256=LZ1yklegdfJSA-NZaC-qrZQ10Q3QqhtVCAav5F8fFtU,5021
|
|
18
|
+
nettracer3d-0.7.5.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
19
|
+
nettracer3d-0.7.5.dist-info/entry_points.txt,sha256=Nx1rr_0QhJXDBHAQg2vcqCzLMKBzSHfwy3xwGkueVyc,53
|
|
20
|
+
nettracer3d-0.7.5.dist-info/top_level.txt,sha256=zsYy9rZwirfCEOubolhee4TyzqBAL5gSUeFMzhFTX8c,12
|
|
21
|
+
nettracer3d-0.7.5.dist-info/RECORD,,
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
nettracer3d/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
nettracer3d/community_extractor.py,sha256=5v9SCCLX3P1RX0fjPVKH5NHMFkMolZ5BTe0bR_a67xg,24479
|
|
3
|
-
nettracer3d/modularity.py,sha256=FH3GpTHorRNkdQULe-2DWgFE3i0_u__hrao7Nx_6Ge4,30249
|
|
4
|
-
nettracer3d/morphology.py,sha256=jyDjYzrZ4LvI5jOyw8DLsxmo-i5lpqHsejYpW7Tq7Mo,19786
|
|
5
|
-
nettracer3d/nettracer.py,sha256=aNeRZq6EAbtPC3uEtgIX35t7y0PtGUc3I4BEk9H7ato,218669
|
|
6
|
-
nettracer3d/nettracer_gui.py,sha256=CsVMxHu3vP61gMIgebqejYE14W7mxTM9GsTOiNWdhDU,427477
|
|
7
|
-
nettracer3d/network_analysis.py,sha256=q1q7lxtA3lebxitfC_jfiT9cnpYXJw4q0Oy2_-Aj8qE,48068
|
|
8
|
-
nettracer3d/network_draw.py,sha256=F7fw6Pcf4qWOhdKwLmhwqWdschbDlHzwCVolQC9imeU,14117
|
|
9
|
-
nettracer3d/node_draw.py,sha256=k3sCTfUCJs3aH1C1q1gTNxDz9EAQbBd1hsUIJajxRx8,9823
|
|
10
|
-
nettracer3d/proximity.py,sha256=nlVBXzJ6r84TlP8UaLcdamWifYn-jfVIF0uB-56k_Js,24752
|
|
11
|
-
nettracer3d/run.py,sha256=xYeaAc8FCx8MuzTGyL3NR3mK7WZzffAYAH23bNRZYO4,127
|
|
12
|
-
nettracer3d/segmenter.py,sha256=gJS2AXqHhnw29cbzIxAah2LsrE7_7XnzG7mYSAovZ4I,87847
|
|
13
|
-
nettracer3d/simple_network.py,sha256=fP1gkDdtQcHruEZpUdasKdZeVacoLOxKhR3bY0L1CAQ,15426
|
|
14
|
-
nettracer3d/smart_dilate.py,sha256=69z9Bn8xtA7rkhcVpqd1PxRSxxRFnIQse9lc2-LU4TU,25879
|
|
15
|
-
nettracer3d-0.7.3.dist-info/licenses/LICENSE,sha256=gM207DhJjWrxLuEWXl0Qz5ISbtWDmADfjHp3yC2XISs,888
|
|
16
|
-
nettracer3d-0.7.3.dist-info/METADATA,sha256=u4XjD4sr34bx8r9aHsoN30sqbZ71QBIleSJL6saZFDY,4467
|
|
17
|
-
nettracer3d-0.7.3.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
18
|
-
nettracer3d-0.7.3.dist-info/entry_points.txt,sha256=Nx1rr_0QhJXDBHAQg2vcqCzLMKBzSHfwy3xwGkueVyc,53
|
|
19
|
-
nettracer3d-0.7.3.dist-info/top_level.txt,sha256=zsYy9rZwirfCEOubolhee4TyzqBAL5gSUeFMzhFTX8c,12
|
|
20
|
-
nettracer3d-0.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|