nettracer3d 0.4.3__tar.gz → 0.4.5__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 (27) hide show
  1. {nettracer3d-0.4.3/src/nettracer3d.egg-info → nettracer3d-0.4.5}/PKG-INFO +17 -3
  2. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/README.md +1 -1
  3. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/pyproject.toml +28 -6
  4. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/nettracer.py +53 -5
  5. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/nettracer_gui.py +751 -32
  6. nettracer3d-0.4.5/src/nettracer3d/segmenter.py +693 -0
  7. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/smart_dilate.py +75 -6
  8. {nettracer3d-0.4.3 → nettracer3d-0.4.5/src/nettracer3d.egg-info}/PKG-INFO +17 -3
  9. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d.egg-info/SOURCES.txt +1 -0
  10. nettracer3d-0.4.5/src/nettracer3d.egg-info/requires.txt +44 -0
  11. nettracer3d-0.4.3/src/nettracer3d.egg-info/requires.txt +0 -23
  12. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/LICENSE +0 -0
  13. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/setup.cfg +0 -0
  14. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/__init__.py +0 -0
  15. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/community_extractor.py +0 -0
  16. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/hub_getter.py +0 -0
  17. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/modularity.py +0 -0
  18. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/morphology.py +0 -0
  19. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/network_analysis.py +0 -0
  20. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/network_draw.py +0 -0
  21. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/node_draw.py +0 -0
  22. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/proximity.py +0 -0
  23. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/run.py +0 -0
  24. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d/simple_network.py +0 -0
  25. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d.egg-info/dependency_links.txt +0 -0
  26. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d.egg-info/entry_points.txt +0 -0
  27. {nettracer3d-0.4.3 → nettracer3d-0.4.5}/src/nettracer3d.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nettracer3d
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
5
5
  Author-email: Liam McLaughlin <boom2449@gmail.com>
6
6
  Project-URL: User_Manual, https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
11
11
  Requires-Python: >=3.8
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
- Requires-Dist: numpy
14
+ Requires-Dist: numpy==1.26.4
15
15
  Requires-Dist: scipy
16
16
  Requires-Dist: scikit-image
17
17
  Requires-Dist: Pillow
@@ -25,14 +25,28 @@ Requires-Dist: python-louvain
25
25
  Requires-Dist: tifffile
26
26
  Requires-Dist: qtrangeslider
27
27
  Requires-Dist: PyQt6
28
+ Requires-Dist: scikit-learn
28
29
  Provides-Extra: cuda11
29
30
  Requires-Dist: cupy-cuda11x; extra == "cuda11"
31
+ Requires-Dist: torch==2.2.0+cu118; extra == "cuda11"
32
+ Requires-Dist: torchvision==0.17.0+cu118; extra == "cuda11"
33
+ Requires-Dist: torchaudio==2.2.0+cu118; extra == "cuda11"
30
34
  Provides-Extra: cuda12
31
35
  Requires-Dist: cupy-cuda12x; extra == "cuda12"
36
+ Requires-Dist: torch==2.2.0+cu121; extra == "cuda12"
37
+ Requires-Dist: torchvision==0.17.0+cu121; extra == "cuda12"
38
+ Requires-Dist: torchaudio==2.2.0+cu121; extra == "cuda12"
32
39
  Provides-Extra: cupy
33
40
  Requires-Dist: cupy; extra == "cupy"
41
+ Requires-Dist: torch; extra == "cupy"
42
+ Requires-Dist: torchvision; extra == "cupy"
43
+ Requires-Dist: torchaudio; extra == "cupy"
44
+ Provides-Extra: gpu
45
+ Requires-Dist: cupy-cuda11x; (platform_system == "Linux" and platform_machine == "x86_64") and extra == "gpu"
46
+ Requires-Dist: cupy-cuda12x; platform_system == "Windows" and extra == "gpu"
47
+ Requires-Dist: cupy; platform_system == "Darwin" and extra == "gpu"
34
48
 
35
- NetTracer3D is a python package developed for both 2D and 3D analysis of microscopic images in the .tif file format. It supports generation of 3D networks showing the relationships between objects (or nodes) in three dimensional space, either based on their own proximity or connectivity via connecting objects such as nerves or blood vessels. In addition to these functionalities are several advanced 3D data processing algorithms, such as labeling of branched structures or abstraction of branched structures into networks. Note that nettracer3d uses segmented data, which can be segmented from other softwares such as ImageJ and imported into NetTracer3D, although it does offer its own segmentation via intensity or volumetric thresholding. NetTracer3D currently has a fully functional GUI. To use the GUI, after installing the nettracer3d package via pip, enter the command 'nettracer3d' in your command prompt:
49
+ NetTracer3D is a python package developed for both 2D and 3D analysis of microscopic images in the .tif file format. It supports generation of 3D networks showing the relationships between objects (or nodes) in three dimensional space, either based on their own proximity or connectivity via connecting objects such as nerves or blood vessels. In addition to these functionalities are several advanced 3D data processing algorithms, such as labeling of branched structures or abstraction of branched structures into networks. Note that nettracer3d uses segmented data, which can be segmented from other softwares such as ImageJ and imported into NetTracer3D, although it does offer its own segmentation via intensity and volumetric thresholding, or random forest machine learning segmentation. NetTracer3D currently has a fully functional GUI. To use the GUI, after installing the nettracer3d package via pip, enter the command 'nettracer3d' in your command prompt:
36
50
 
37
51
 
38
52
  This gui is built from the PyQt6 package and therefore may not function on dockers or virtual envs that are unable to support PyQt6 displays. More advanced documentation (especially for the GUI) is coming down the line, but for now please see: https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
@@ -1,4 +1,4 @@
1
- NetTracer3D is a python package developed for both 2D and 3D analysis of microscopic images in the .tif file format. It supports generation of 3D networks showing the relationships between objects (or nodes) in three dimensional space, either based on their own proximity or connectivity via connecting objects such as nerves or blood vessels. In addition to these functionalities are several advanced 3D data processing algorithms, such as labeling of branched structures or abstraction of branched structures into networks. Note that nettracer3d uses segmented data, which can be segmented from other softwares such as ImageJ and imported into NetTracer3D, although it does offer its own segmentation via intensity or volumetric thresholding. NetTracer3D currently has a fully functional GUI. To use the GUI, after installing the nettracer3d package via pip, enter the command 'nettracer3d' in your command prompt:
1
+ NetTracer3D is a python package developed for both 2D and 3D analysis of microscopic images in the .tif file format. It supports generation of 3D networks showing the relationships between objects (or nodes) in three dimensional space, either based on their own proximity or connectivity via connecting objects such as nerves or blood vessels. In addition to these functionalities are several advanced 3D data processing algorithms, such as labeling of branched structures or abstraction of branched structures into networks. Note that nettracer3d uses segmented data, which can be segmented from other softwares such as ImageJ and imported into NetTracer3D, although it does offer its own segmentation via intensity and volumetric thresholding, or random forest machine learning segmentation. NetTracer3D currently has a fully functional GUI. To use the GUI, after installing the nettracer3d package via pip, enter the command 'nettracer3d' in your command prompt:
2
2
 
3
3
 
4
4
  This gui is built from the PyQt6 package and therefore may not function on dockers or virtual envs that are unable to support PyQt6 displays. More advanced documentation (especially for the GUI) is coming down the line, but for now please see: https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "nettracer3d"
3
- version = "0.4.3"
3
+ version = "0.4.5"
4
4
  authors = [
5
5
  { name="Liam McLaughlin", email="boom2449@gmail.com" },
6
6
  ]
7
7
  description = "Scripts for intializing and analyzing networks from segmentations of three dimensional images."
8
8
  dependencies = [
9
- "numpy",
9
+ "numpy == 1.26.4",
10
10
  "scipy",
11
11
  "scikit-image",
12
12
  "Pillow",
@@ -19,8 +19,10 @@ dependencies = [
19
19
  "python-louvain",
20
20
  "tifffile",
21
21
  "qtrangeslider",
22
- "PyQt6"
22
+ "PyQt6",
23
+ "scikit-learn"
23
24
  ]
25
+
24
26
  readme = "README.md"
25
27
  requires-python = ">=3.8"
26
28
  classifiers = [
@@ -30,9 +32,29 @@ classifiers = [
30
32
  ]
31
33
 
32
34
  [project.optional-dependencies]
33
- CUDA11 = ["cupy-cuda11x"]
34
- CUDA12 = ["cupy-cuda12x"]
35
- cupy = ["cupy"]
35
+ CUDA11 = [
36
+ "cupy-cuda11x",
37
+ "torch==2.2.0+cu118",
38
+ "torchvision==0.17.0+cu118",
39
+ "torchaudio==2.2.0+cu118"
40
+ ]
41
+ CUDA12 = [
42
+ "cupy-cuda12x",
43
+ "torch==2.2.0+cu121",
44
+ "torchvision==0.17.0+cu121",
45
+ "torchaudio==2.2.0+cu121"
46
+ ]
47
+ cupy = [
48
+ "cupy",
49
+ "torch", # Will get CPU version by default
50
+ "torchvision",
51
+ "torchaudio"
52
+ ]
53
+ GPU = [ # Meta-dependency that user can choose based on their CUDA version
54
+ "cupy-cuda11x ; platform_system=='Linux' and platform_machine=='x86_64'",
55
+ "cupy-cuda12x ; platform_system=='Windows'",
56
+ "cupy ; platform_system=='Darwin'"
57
+ ]
36
58
 
37
59
  [project.scripts]
38
60
  nettracer3d = "nettracer3d.run:main"
@@ -858,10 +858,26 @@ def hash_inners(search_region, inner_edges, GPU = True):
858
858
 
859
859
  return inner_edges
860
860
 
861
+
862
+ def dilate_2D(array, search, scaling = 1):
863
+
864
+ inv = array < 1
865
+
866
+ inv = smart_dilate.compute_distance_transform_distance(inv)
867
+
868
+ inv = inv * scaling
869
+
870
+ inv = inv <= search
871
+
872
+ return inv
873
+
874
+
861
875
  def dilate_3D(tiff_array, dilated_x, dilated_y, dilated_z):
862
876
  """Internal method to dilate an array in 3D. Dilation this way is much faster than using a distance transform although the latter is theoretically more accurate.
863
877
  Arguments are an array, and the desired pixel dilation amounts in X, Y, Z."""
864
878
 
879
+ if tiff_array.shape[0] == 1:
880
+ return dilate_2D(tiff_array, ((dilated_x - 1) / 2))
865
881
 
866
882
  if dilated_x == 3 and dilated_y == 3 and dilated_z == 3:
867
883
 
@@ -996,6 +1012,8 @@ def dilate_3D_recursive(tiff_array, dilated_x, dilated_y, dilated_z, step_size=N
996
1012
 
997
1013
  Each dilation parameter represents (n-1)/2 steps outward from the object.
998
1014
  """
1015
+ if tiff_array.shape[0] == 1:
1016
+ return dilate_2D(tiff_array, ((dilated_x - 1) / 2))
999
1017
  # Calculate the smallest dimension of the array
1000
1018
  min_dim = min(tiff_array.shape)
1001
1019
 
@@ -1836,6 +1854,7 @@ def watershed(image, directory = None, proportion = 0.1, GPU = True, smallest_ra
1836
1854
  gotoexcept = 1/0
1837
1855
 
1838
1856
  except (cp.cuda.memory.OutOfMemoryError, ZeroDivisionError) as e:
1857
+
1839
1858
  if predownsample is None:
1840
1859
  down_factor = smart_dilate.catch_memory(e) #Obtain downsample amount based on memory missing
1841
1860
  else:
@@ -1866,8 +1885,12 @@ def watershed(image, directory = None, proportion = 0.1, GPU = True, smallest_ra
1866
1885
 
1867
1886
  labels, _ = label_objects(distance)
1868
1887
 
1888
+ if len(labels.shape) ==2:
1889
+ labels = np.expand_dims(labels, axis = 0)
1890
+
1869
1891
  del distance
1870
1892
 
1893
+
1871
1894
  if labels.shape[1] < original_shape[1]: #If downsample was used, upsample output
1872
1895
  labels = upsample_with_padding(labels, downsample_needed, original_shape)
1873
1896
  labels = labels * old_mask
@@ -1876,8 +1899,7 @@ def watershed(image, directory = None, proportion = 0.1, GPU = True, smallest_ra
1876
1899
  labels = smart_dilate.smart_label(image, labels, GPU = GPU, predownsample = predownsample2)
1877
1900
 
1878
1901
  if directory is None:
1879
- tifffile.imwrite("Watershed_output.tif", labels)
1880
- print("Watershed saved to 'Watershed_output.tif'")
1902
+ pass
1881
1903
  else:
1882
1904
  tifffile.imwrite(f"{directory}/Watershed_output.tif", labels)
1883
1905
  print(f"Watershed saved to {directory}/'Watershed_output.tif'")
@@ -2410,6 +2432,7 @@ class Network_3D:
2410
2432
  Can be called on a Network_3D object to save the node centroids properties to hard mem as a .xlsx file. It will save to the active directory if none is specified.
2411
2433
  :param directory: (Optional - Val = None; String). The path to an indended directory to save the centroids to.
2412
2434
  """
2435
+
2413
2436
  if self._node_centroids is not None:
2414
2437
  if directory is None:
2415
2438
  network_analysis._save_centroid_dictionary(self._node_centroids, 'node_centroids.xlsx')
@@ -2420,7 +2443,14 @@ class Network_3D:
2420
2443
  print(f"Centroids saved to {directory}/node_centroids.xlsx")
2421
2444
 
2422
2445
  if self._node_centroids is None:
2423
- print("Node centroids attribute is empty, did not save...")
2446
+ if directory is None:
2447
+ network_analysis._save_centroid_dictionary({}, 'node_centroids.xlsx')
2448
+ print("Centroids saved to node_centroids.xlsx")
2449
+
2450
+ if directory is not None:
2451
+ network_analysis._save_centroid_dictionary({}, f'{directory}/node_centroids.xlsx')
2452
+ print(f"Centroids saved to {directory}/node_centroids.xlsx")
2453
+
2424
2454
 
2425
2455
  def save_edge_centroids(self, directory = None):
2426
2456
  """
@@ -2438,6 +2468,13 @@ class Network_3D:
2438
2468
 
2439
2469
  if self._edge_centroids is None:
2440
2470
  print("Edge centroids attribute is empty, did not save...")
2471
+ if directory is None:
2472
+ network_analysis._save_centroid_dictionary({}, 'edge_centroids.xlsx', index = 'Edge ID')
2473
+ print("Centroids saved to edge_centroids.xlsx")
2474
+
2475
+ if directory is not None:
2476
+ network_analysis._save_centroid_dictionary({}, f'{directory}/edge_centroids.xlsx', index = 'Edge ID')
2477
+ print(f"Centroids saved to {directory}/edge_centroids.xlsx")
2441
2478
 
2442
2479
  def save_search_region(self, directory = None):
2443
2480
  """
@@ -2490,7 +2527,13 @@ class Network_3D:
2490
2527
  print(f"Node identities saved to {directory}/node_identities.xlsx")
2491
2528
 
2492
2529
  if self._node_identities is None:
2493
- print("Node identities attribute is empty...")
2530
+ if directory is None:
2531
+ network_analysis.save_singval_dict({}, 'NodeID', 'Identity', 'node_identities.xlsx')
2532
+ print("Node identities saved to node_identities.xlsx")
2533
+
2534
+ if directory is not None:
2535
+ network_analysis.save_singval_dict({}, 'NodeID', 'Identity', f'{directory}/node_identities.xlsx')
2536
+ print(f"Node identities saved to {directory}/node_identities.xlsx")
2494
2537
 
2495
2538
  def save_communities(self, directory = None):
2496
2539
  """
@@ -2507,8 +2550,13 @@ class Network_3D:
2507
2550
  print(f"Communities saved to {directory}/node_communities.xlsx")
2508
2551
 
2509
2552
  if self._communities is None:
2510
- print("Communities attribute is empty...")
2553
+ if directory is None:
2554
+ network_analysis.save_singval_dict({}, 'NodeID', 'Community', 'node_communities.xlsx')
2555
+ print("Communities saved to node_communities.xlsx")
2511
2556
 
2557
+ if directory is not None:
2558
+ network_analysis.save_singval_dict({}, 'NodeID', 'Community', f'{directory}/node_communities.xlsx')
2559
+ print(f"Communities saved to {directory}/node_communities.xlsx")
2512
2560
 
2513
2561
  def save_network_overlay(self, directory = None, filename = None):
2514
2562