nettracer3d 0.7.6__py3-none-any.whl → 0.7.8__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.
- nettracer3d/community_extractor.py +13 -29
- nettracer3d/excelotron.py +1719 -0
- nettracer3d/modularity.py +6 -9
- nettracer3d/neighborhoods.py +354 -0
- nettracer3d/nettracer.py +400 -13
- nettracer3d/nettracer_gui.py +1120 -229
- nettracer3d/proximity.py +89 -9
- nettracer3d/smart_dilate.py +20 -15
- {nettracer3d-0.7.6.dist-info → nettracer3d-0.7.8.dist-info}/METADATA +11 -2
- nettracer3d-0.7.8.dist-info/RECORD +23 -0
- {nettracer3d-0.7.6.dist-info → nettracer3d-0.7.8.dist-info}/WHEEL +1 -1
- nettracer3d-0.7.6.dist-info/RECORD +0 -21
- {nettracer3d-0.7.6.dist-info → nettracer3d-0.7.8.dist-info}/entry_points.txt +0 -0
- {nettracer3d-0.7.6.dist-info → nettracer3d-0.7.8.dist-info}/licenses/LICENSE +0 -0
- {nettracer3d-0.7.6.dist-info → nettracer3d-0.7.8.dist-info}/top_level.txt +0 -0
|
@@ -533,46 +533,30 @@ def assign_node_colors(node_list: List[int], labeled_array: np.ndarray) -> Tuple
|
|
|
533
533
|
return rgba_array, node_to_color_names
|
|
534
534
|
|
|
535
535
|
def assign_community_colors(community_dict: Dict[int, int], labeled_array: np.ndarray) -> Tuple[np.ndarray, Dict[int, str]]:
|
|
536
|
-
"""
|
|
537
|
-
Assign distinct colors to communities and create an RGBA image.
|
|
538
|
-
|
|
539
|
-
Args:
|
|
540
|
-
community_dict: Dictionary mapping node IDs to community numbers
|
|
541
|
-
labeled_array: 3D numpy array with labels corresponding to node IDs
|
|
536
|
+
"""Ultra-fast version using lookup table approach."""
|
|
542
537
|
|
|
543
|
-
|
|
544
|
-
Tuple of (RGBA-coded numpy array (H, W, D, 4), dictionary mapping nodes to color names)
|
|
545
|
-
"""
|
|
546
|
-
# Get unique communities and their sizes
|
|
538
|
+
# Same setup as before
|
|
547
539
|
communities = set(community_dict.values())
|
|
548
540
|
community_sizes = Counter(community_dict.values())
|
|
549
|
-
|
|
550
|
-
# Sort communities by size (descending)
|
|
551
541
|
sorted_communities = sorted(communities, key=lambda x: community_sizes[x], reverse=True)
|
|
552
542
|
|
|
553
|
-
# Generate distinct colors
|
|
554
543
|
colors = generate_distinct_colors(len(communities))
|
|
544
|
+
colors_rgba = np.array([(r, g, b, 255) for r, g, b in colors], dtype=np.uint8)
|
|
555
545
|
|
|
556
|
-
# Convert RGB colors to RGBA by adding alpha channel
|
|
557
|
-
colors_rgba = [(r, g, b, 255) for r, g, b in colors] # Full opacity for colored regions
|
|
558
|
-
|
|
559
|
-
# Create mapping from community to color
|
|
560
546
|
community_to_color = {comm: colors_rgba[i] for i, comm in enumerate(sorted_communities)}
|
|
561
|
-
|
|
562
|
-
# Create mapping from node ID to color
|
|
563
547
|
node_to_color = {node: community_to_color[comm] for node, comm in community_dict.items()}
|
|
564
548
|
|
|
565
|
-
# Create
|
|
566
|
-
|
|
549
|
+
# Create lookup table - this is the key optimization
|
|
550
|
+
max_label = max(max(labeled_array.flat), max(node_to_color.keys()) if node_to_color else 0)
|
|
551
|
+
color_lut = np.zeros((max_label + 1, 4), dtype=np.uint8) # Transparent by default
|
|
567
552
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
# Convert the RGB portion of community_to_color back to RGB for color naming
|
|
553
|
+
for node_id, color in node_to_color.items():
|
|
554
|
+
color_lut[node_id] = color
|
|
555
|
+
|
|
556
|
+
# Single vectorized operation - this is much faster!
|
|
557
|
+
rgba_array = color_lut[labeled_array]
|
|
558
|
+
|
|
559
|
+
# Rest remains the same
|
|
576
560
|
community_to_color_rgb = {k: tuple(v[:3]) for k, v in community_to_color.items()}
|
|
577
561
|
node_to_color_names = convert_node_colors_to_names(community_to_color_rgb)
|
|
578
562
|
|