nettracer3d 0.3.0__tar.gz → 0.3.2__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.
- nettracer3d-0.3.2/PKG-INFO +49 -0
- nettracer3d-0.3.2/README.md +16 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/pyproject.toml +1 -1
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/community_extractor.py +37 -3
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/nettracer.py +27 -13
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/nettracer_gui.py +10 -1
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/network_analysis.py +40 -5
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/network_draw.py +37 -3
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/node_draw.py +37 -3
- nettracer3d-0.3.2/src/nettracer3d.egg-info/PKG-INFO +49 -0
- nettracer3d-0.3.0/PKG-INFO +0 -41
- nettracer3d-0.3.0/README.md +0 -8
- nettracer3d-0.3.0/src/nettracer3d.egg-info/PKG-INFO +0 -41
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/LICENSE +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/setup.cfg +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/__init__.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/hub_getter.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/modularity.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/morphology.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/proximity.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/simple_network.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d/smart_dilate.py +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d.egg-info/SOURCES.txt +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d.egg-info/dependency_links.txt +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d.egg-info/requires.txt +0 -0
- {nettracer3d-0.3.0 → nettracer3d-0.3.2}/src/nettracer3d.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: nettracer3d
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
|
|
5
|
+
Author-email: Liam McLaughlin <boom2449@gmail.com>
|
|
6
|
+
Project-URL: User_Manual, https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
7
|
+
Project-URL: Reference_Citation_For_Use, https://doi.org/10.1101/2024.07.29.605633
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy
|
|
16
|
+
Requires-Dist: scikit-image
|
|
17
|
+
Requires-Dist: Pillow
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: networkx
|
|
20
|
+
Requires-Dist: opencv-python-headless
|
|
21
|
+
Requires-Dist: openpyxl
|
|
22
|
+
Requires-Dist: pandas
|
|
23
|
+
Requires-Dist: plotly
|
|
24
|
+
Requires-Dist: python-louvain
|
|
25
|
+
Requires-Dist: tifffile
|
|
26
|
+
Requires-Dist: PyQt6
|
|
27
|
+
Provides-Extra: cuda11
|
|
28
|
+
Requires-Dist: cupy-cuda11x; extra == "cuda11"
|
|
29
|
+
Provides-Extra: cuda12
|
|
30
|
+
Requires-Dist: cupy-cuda12x; extra == "cuda12"
|
|
31
|
+
Provides-Extra: cupy
|
|
32
|
+
Requires-Dist: cupy; extra == "cupy"
|
|
33
|
+
|
|
34
|
+
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, run a python script in your env with the following commands:
|
|
35
|
+
|
|
36
|
+
#Start
|
|
37
|
+
|
|
38
|
+
from nettracer3d import nettracer_gui
|
|
39
|
+
|
|
40
|
+
nettracer_gui.run_gui()
|
|
41
|
+
|
|
42
|
+
#End
|
|
43
|
+
|
|
44
|
+
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
|
|
45
|
+
for a user manual that provides older documentation.
|
|
46
|
+
|
|
47
|
+
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
48
|
+
|
|
49
|
+
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
|
@@ -0,0 +1,16 @@
|
|
|
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, run a python script in your env with the following commands:
|
|
2
|
+
|
|
3
|
+
#Start
|
|
4
|
+
|
|
5
|
+
from nettracer3d import nettracer_gui
|
|
6
|
+
|
|
7
|
+
nettracer_gui.run_gui()
|
|
8
|
+
|
|
9
|
+
#End
|
|
10
|
+
|
|
11
|
+
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
|
|
12
|
+
for a user manual that provides older documentation.
|
|
13
|
+
|
|
14
|
+
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
15
|
+
|
|
16
|
+
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
|
@@ -118,9 +118,43 @@ def get_border_nodes(partition, G):
|
|
|
118
118
|
|
|
119
119
|
return border_nodes, intercom_connections, set(connected_coms)
|
|
120
120
|
|
|
121
|
-
def downsample(data, factor):
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
def downsample(data, factor, directory=None, order=0):
|
|
122
|
+
"""
|
|
123
|
+
Can be used to downsample an image by some arbitrary factor. Downsampled output will be saved to the active directory if none is specified.
|
|
124
|
+
|
|
125
|
+
:param data: (Mandatory, string or ndarray) - If string, a path to a tif file to downsample. Note that the ndarray alternative is for internal use mainly and will not save its output.
|
|
126
|
+
:param factor: (Mandatory, int) - A factor by which to downsample the image.
|
|
127
|
+
:param directory: (Optional - Val = None, string) - A filepath to save outputs.
|
|
128
|
+
:param order: (Optional - Val = 0, int) - The order of interpolation for scipy.ndimage.zoom
|
|
129
|
+
:returns: a downsampled ndarray.
|
|
130
|
+
"""
|
|
131
|
+
# Load the data if it's a file path
|
|
132
|
+
if isinstance(data, str):
|
|
133
|
+
data2 = data
|
|
134
|
+
data = tifffile.imread(data)
|
|
135
|
+
else:
|
|
136
|
+
data2 = None
|
|
137
|
+
|
|
138
|
+
# Check if Z dimension is too small relative to downsample factor
|
|
139
|
+
if data.ndim == 3 and data.shape[0] < factor * 4:
|
|
140
|
+
print(f"Warning: Z dimension ({data.shape[0]}) is less than 4x the downsample factor ({factor}). "
|
|
141
|
+
f"Skipping Z-axis downsampling to preserve resolution.")
|
|
142
|
+
zoom_factors = (1, 1/factor, 1/factor)
|
|
143
|
+
else:
|
|
144
|
+
zoom_factors = 1/factor
|
|
145
|
+
|
|
146
|
+
# Apply downsampling
|
|
147
|
+
data = zoom(data, zoom_factors, order=order)
|
|
148
|
+
|
|
149
|
+
# Save if input was a file path
|
|
150
|
+
if isinstance(data2, str):
|
|
151
|
+
if directory is None:
|
|
152
|
+
filename = "downsampled.tif"
|
|
153
|
+
else:
|
|
154
|
+
filename = f"{directory}/downsampled.tif"
|
|
155
|
+
tifffile.imwrite(filename, data)
|
|
156
|
+
|
|
157
|
+
return data
|
|
124
158
|
|
|
125
159
|
def labels_to_boolean(label_array, labels_list):
|
|
126
160
|
# Use np.isin to create a boolean array with a single operation
|
|
@@ -1342,35 +1342,44 @@ def directory_info(directory = None):
|
|
|
1342
1342
|
|
|
1343
1343
|
#CLASSLESS FUNCTIONS THAT MAY BE USEFUL TO USERS TO RUN DIRECTLY THAT SUPPORT ANALYSIS IN SOME WAY. NOTE THESE METHODS SOMETIMES ARE USED INTERNALLY AS WELL:
|
|
1344
1344
|
|
|
1345
|
-
def downsample(data, factor, directory
|
|
1345
|
+
def downsample(data, factor, directory=None, order=0):
|
|
1346
1346
|
"""
|
|
1347
1347
|
Can be used to downsample an image by some arbitrary factor. Downsampled output will be saved to the active directory if none is specified.
|
|
1348
|
+
|
|
1348
1349
|
:param data: (Mandatory, string or ndarray) - If string, a path to a tif file to downsample. Note that the ndarray alternative is for internal use mainly and will not save its output.
|
|
1349
1350
|
:param factor: (Mandatory, int) - A factor by which to downsample the image.
|
|
1350
1351
|
:param directory: (Optional - Val = None, string) - A filepath to save outputs.
|
|
1352
|
+
:param order: (Optional - Val = 0, int) - The order of interpolation for scipy.ndimage.zoom
|
|
1351
1353
|
:returns: a downsampled ndarray.
|
|
1352
1354
|
"""
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
# Downsample the input data by a specified factor
|
|
1356
|
-
|
|
1357
|
-
if type(data) == str:
|
|
1355
|
+
# Load the data if it's a file path
|
|
1356
|
+
if isinstance(data, str):
|
|
1358
1357
|
data2 = data
|
|
1359
1358
|
data = tifffile.imread(data)
|
|
1360
1359
|
else:
|
|
1361
1360
|
data2 = None
|
|
1361
|
+
|
|
1362
|
+
# Check if Z dimension is too small relative to downsample factor
|
|
1363
|
+
if data.ndim == 3 and data.shape[0] < factor * 4:
|
|
1364
|
+
print(f"Warning: Z dimension ({data.shape[0]}) is less than 4x the downsample factor ({factor}). "
|
|
1365
|
+
f"Skipping Z-axis downsampling to preserve resolution.")
|
|
1366
|
+
zoom_factors = (1, 1/factor, 1/factor)
|
|
1367
|
+
else:
|
|
1368
|
+
zoom_factors = 1/factor
|
|
1362
1369
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1370
|
+
# Apply downsampling
|
|
1371
|
+
data = zoom(data, zoom_factors, order=order)
|
|
1372
|
+
|
|
1373
|
+
# Save if input was a file path
|
|
1374
|
+
if isinstance(data2, str):
|
|
1366
1375
|
if directory is None:
|
|
1367
|
-
filename =
|
|
1376
|
+
filename = "downsampled.tif"
|
|
1368
1377
|
else:
|
|
1369
1378
|
filename = f"{directory}/downsampled.tif"
|
|
1370
1379
|
tifffile.imwrite(filename, data)
|
|
1371
|
-
|
|
1380
|
+
|
|
1372
1381
|
return data
|
|
1373
|
-
|
|
1382
|
+
|
|
1374
1383
|
def binarize(arrayimage, directory = None):
|
|
1375
1384
|
"""
|
|
1376
1385
|
Can be used to binarize an image. Binary output will be saved to the active directory if none is specified.
|
|
@@ -3337,7 +3346,12 @@ class Network_3D:
|
|
|
3337
3346
|
|
|
3338
3347
|
print("Converting all edge objects to nodes...")
|
|
3339
3348
|
|
|
3340
|
-
|
|
3349
|
+
if self._nodes is not None:
|
|
3350
|
+
max_node = np.max(self._nodes)
|
|
3351
|
+
else:
|
|
3352
|
+
max_node = None
|
|
3353
|
+
|
|
3354
|
+
df, identity_dict, max_node = network_analysis.edge_to_node(self._network_lists, self._node_identities, maxnode = max_node)
|
|
3341
3355
|
|
|
3342
3356
|
self._network_lists = network_analysis.read_excel_to_lists(df)
|
|
3343
3357
|
self._network, net_weights = network_analysis.weighted_network(df)
|
|
@@ -4948,6 +4948,10 @@ class ResizeDialog(QDialog):
|
|
|
4948
4948
|
# Process highlight overlay if it exists
|
|
4949
4949
|
if self.parent().highlight_overlay is not None:
|
|
4950
4950
|
self.parent().highlight_overlay = n3d.resize(self.parent().highlight_overlay, resize, order)
|
|
4951
|
+
if my_network.search_region is not None:
|
|
4952
|
+
my_network.search_region = n3d.resize(my_network.search_region, resize, order)
|
|
4953
|
+
|
|
4954
|
+
|
|
4951
4955
|
else:
|
|
4952
4956
|
# Process each channel
|
|
4953
4957
|
if array_shape == self.parent().original_shape:
|
|
@@ -4962,6 +4966,8 @@ class ResizeDialog(QDialog):
|
|
|
4962
4966
|
if self.parent().highlight_overlay is not None:
|
|
4963
4967
|
self.parent().highlight_overlay = n3d.upsample_with_padding(self.parent().highlight_overlay, original_shape = self.parent().original_shape)
|
|
4964
4968
|
|
|
4969
|
+
my_network.search_region = n3d.upsample_with_padding(my_network.search_region, original_shape = self.parent().original_shape)
|
|
4970
|
+
|
|
4965
4971
|
|
|
4966
4972
|
# Update slider range based on new z-dimension
|
|
4967
4973
|
for channel in self.parent().channel_data:
|
|
@@ -6289,7 +6295,10 @@ class ModifyDialog(QDialog):
|
|
|
6289
6295
|
my_network.edge_to_node()
|
|
6290
6296
|
self.parent().load_channel(0, my_network.nodes, True)
|
|
6291
6297
|
self.parent().load_channel(1, my_network.edges, True)
|
|
6292
|
-
|
|
6298
|
+
try:
|
|
6299
|
+
self.parent().format_for_upperright_table(my_network.node_centroids, 'NodeID', ['Z', 'Y', 'X'], 'Node Centroids')
|
|
6300
|
+
except:
|
|
6301
|
+
pass
|
|
6293
6302
|
try:
|
|
6294
6303
|
if hasattr(my_network, 'network_lists'):
|
|
6295
6304
|
model = PandasModel(my_network.network_lists)
|
|
@@ -21,9 +21,43 @@ try:
|
|
|
21
21
|
except:
|
|
22
22
|
pass
|
|
23
23
|
|
|
24
|
-
def downsample(data, factor):
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
def downsample(data, factor, directory=None, order=0):
|
|
25
|
+
"""
|
|
26
|
+
Can be used to downsample an image by some arbitrary factor. Downsampled output will be saved to the active directory if none is specified.
|
|
27
|
+
|
|
28
|
+
:param data: (Mandatory, string or ndarray) - If string, a path to a tif file to downsample. Note that the ndarray alternative is for internal use mainly and will not save its output.
|
|
29
|
+
:param factor: (Mandatory, int) - A factor by which to downsample the image.
|
|
30
|
+
:param directory: (Optional - Val = None, string) - A filepath to save outputs.
|
|
31
|
+
:param order: (Optional - Val = 0, int) - The order of interpolation for scipy.ndimage.zoom
|
|
32
|
+
:returns: a downsampled ndarray.
|
|
33
|
+
"""
|
|
34
|
+
# Load the data if it's a file path
|
|
35
|
+
if isinstance(data, str):
|
|
36
|
+
data2 = data
|
|
37
|
+
data = tifffile.imread(data)
|
|
38
|
+
else:
|
|
39
|
+
data2 = None
|
|
40
|
+
|
|
41
|
+
# Check if Z dimension is too small relative to downsample factor
|
|
42
|
+
if data.ndim == 3 and data.shape[0] < factor * 4:
|
|
43
|
+
print(f"Warning: Z dimension ({data.shape[0]}) is less than 4x the downsample factor ({factor}). "
|
|
44
|
+
f"Skipping Z-axis downsampling to preserve resolution.")
|
|
45
|
+
zoom_factors = (1, 1/factor, 1/factor)
|
|
46
|
+
else:
|
|
47
|
+
zoom_factors = 1/factor
|
|
48
|
+
|
|
49
|
+
# Apply downsampling
|
|
50
|
+
data = zoom(data, zoom_factors, order=order)
|
|
51
|
+
|
|
52
|
+
# Save if input was a file path
|
|
53
|
+
if isinstance(data2, str):
|
|
54
|
+
if directory is None:
|
|
55
|
+
filename = "downsampled.tif"
|
|
56
|
+
else:
|
|
57
|
+
filename = f"{directory}/downsampled.tif"
|
|
58
|
+
tifffile.imwrite(filename, data)
|
|
59
|
+
|
|
60
|
+
return data
|
|
27
61
|
|
|
28
62
|
def compute_centroid(binary_stack, label):
|
|
29
63
|
"""
|
|
@@ -1168,7 +1202,7 @@ def isolate_internode_connections(networkfile, nodeIDs, ID1, ID2):
|
|
|
1168
1202
|
# Optional: Return the updated lists if needed
|
|
1169
1203
|
return master_list, output_dict
|
|
1170
1204
|
|
|
1171
|
-
def edge_to_node(network, node_identities = None):
|
|
1205
|
+
def edge_to_node(network, node_identities = None, maxnode = None):
|
|
1172
1206
|
"""Converts edge IDs into nodes, so that the node-edge relationships can be more easily visualized"""
|
|
1173
1207
|
|
|
1174
1208
|
if node_identities is not None and type(node_identities) == str:
|
|
@@ -1194,7 +1228,8 @@ def edge_to_node(network, node_identities = None):
|
|
|
1194
1228
|
nodesB = master_list[1]
|
|
1195
1229
|
edgesC = master_list[2]
|
|
1196
1230
|
allnodes = set(nodesA + nodesB)
|
|
1197
|
-
maxnode
|
|
1231
|
+
if maxnode is None:
|
|
1232
|
+
maxnode = max(allnodes)
|
|
1198
1233
|
print(f"Transposing all edge vals by {maxnode} to prevent ID overlap with preexisting nodes")
|
|
1199
1234
|
|
|
1200
1235
|
|
|
@@ -95,9 +95,43 @@ def draw_line_inplace(start, end, array):
|
|
|
95
95
|
# Set the line coordinates to 255 in the existing array
|
|
96
96
|
array[x_coords, y_coords, z_coords] = 255
|
|
97
97
|
|
|
98
|
-
def downsample(data, factor):
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
def downsample(data, factor, directory=None, order=0):
|
|
99
|
+
"""
|
|
100
|
+
Can be used to downsample an image by some arbitrary factor. Downsampled output will be saved to the active directory if none is specified.
|
|
101
|
+
|
|
102
|
+
:param data: (Mandatory, string or ndarray) - If string, a path to a tif file to downsample. Note that the ndarray alternative is for internal use mainly and will not save its output.
|
|
103
|
+
:param factor: (Mandatory, int) - A factor by which to downsample the image.
|
|
104
|
+
:param directory: (Optional - Val = None, string) - A filepath to save outputs.
|
|
105
|
+
:param order: (Optional - Val = 0, int) - The order of interpolation for scipy.ndimage.zoom
|
|
106
|
+
:returns: a downsampled ndarray.
|
|
107
|
+
"""
|
|
108
|
+
# Load the data if it's a file path
|
|
109
|
+
if isinstance(data, str):
|
|
110
|
+
data2 = data
|
|
111
|
+
data = tifffile.imread(data)
|
|
112
|
+
else:
|
|
113
|
+
data2 = None
|
|
114
|
+
|
|
115
|
+
# Check if Z dimension is too small relative to downsample factor
|
|
116
|
+
if data.ndim == 3 and data.shape[0] < factor * 4:
|
|
117
|
+
print(f"Warning: Z dimension ({data.shape[0]}) is less than 4x the downsample factor ({factor}). "
|
|
118
|
+
f"Skipping Z-axis downsampling to preserve resolution.")
|
|
119
|
+
zoom_factors = (1, 1/factor, 1/factor)
|
|
120
|
+
else:
|
|
121
|
+
zoom_factors = 1/factor
|
|
122
|
+
|
|
123
|
+
# Apply downsampling
|
|
124
|
+
data = zoom(data, zoom_factors, order=order)
|
|
125
|
+
|
|
126
|
+
# Save if input was a file path
|
|
127
|
+
if isinstance(data2, str):
|
|
128
|
+
if directory is None:
|
|
129
|
+
filename = "downsampled.tif"
|
|
130
|
+
else:
|
|
131
|
+
filename = f"{directory}/downsampled.tif"
|
|
132
|
+
tifffile.imwrite(filename, data)
|
|
133
|
+
|
|
134
|
+
return data
|
|
101
135
|
|
|
102
136
|
def draw_network_lattice(nodes, network, label_nodes = None):
|
|
103
137
|
|
|
@@ -5,9 +5,43 @@ from PIL import Image, ImageDraw, ImageFont
|
|
|
5
5
|
from scipy.ndimage import zoom
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def downsample(data, factor):
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
def downsample(data, factor, directory=None, order=0):
|
|
9
|
+
"""
|
|
10
|
+
Can be used to downsample an image by some arbitrary factor. Downsampled output will be saved to the active directory if none is specified.
|
|
11
|
+
|
|
12
|
+
:param data: (Mandatory, string or ndarray) - If string, a path to a tif file to downsample. Note that the ndarray alternative is for internal use mainly and will not save its output.
|
|
13
|
+
:param factor: (Mandatory, int) - A factor by which to downsample the image.
|
|
14
|
+
:param directory: (Optional - Val = None, string) - A filepath to save outputs.
|
|
15
|
+
:param order: (Optional - Val = 0, int) - The order of interpolation for scipy.ndimage.zoom
|
|
16
|
+
:returns: a downsampled ndarray.
|
|
17
|
+
"""
|
|
18
|
+
# Load the data if it's a file path
|
|
19
|
+
if isinstance(data, str):
|
|
20
|
+
data2 = data
|
|
21
|
+
data = tifffile.imread(data)
|
|
22
|
+
else:
|
|
23
|
+
data2 = None
|
|
24
|
+
|
|
25
|
+
# Check if Z dimension is too small relative to downsample factor
|
|
26
|
+
if data.ndim == 3 and data.shape[0] < factor * 4:
|
|
27
|
+
print(f"Warning: Z dimension ({data.shape[0]}) is less than 4x the downsample factor ({factor}). "
|
|
28
|
+
f"Skipping Z-axis downsampling to preserve resolution.")
|
|
29
|
+
zoom_factors = (1, 1/factor, 1/factor)
|
|
30
|
+
else:
|
|
31
|
+
zoom_factors = 1/factor
|
|
32
|
+
|
|
33
|
+
# Apply downsampling
|
|
34
|
+
data = zoom(data, zoom_factors, order=order)
|
|
35
|
+
|
|
36
|
+
# Save if input was a file path
|
|
37
|
+
if isinstance(data2, str):
|
|
38
|
+
if directory is None:
|
|
39
|
+
filename = "downsampled.tif"
|
|
40
|
+
else:
|
|
41
|
+
filename = f"{directory}/downsampled.tif"
|
|
42
|
+
tifffile.imwrite(filename, data)
|
|
43
|
+
|
|
44
|
+
return data
|
|
11
45
|
|
|
12
46
|
def upsample_with_padding(data, factor, original_shape):
|
|
13
47
|
# Upsample the input binary array while adding padding to match the original shape
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: nettracer3d
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
|
|
5
|
+
Author-email: Liam McLaughlin <boom2449@gmail.com>
|
|
6
|
+
Project-URL: User_Manual, https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
7
|
+
Project-URL: Reference_Citation_For_Use, https://doi.org/10.1101/2024.07.29.605633
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy
|
|
16
|
+
Requires-Dist: scikit-image
|
|
17
|
+
Requires-Dist: Pillow
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: networkx
|
|
20
|
+
Requires-Dist: opencv-python-headless
|
|
21
|
+
Requires-Dist: openpyxl
|
|
22
|
+
Requires-Dist: pandas
|
|
23
|
+
Requires-Dist: plotly
|
|
24
|
+
Requires-Dist: python-louvain
|
|
25
|
+
Requires-Dist: tifffile
|
|
26
|
+
Requires-Dist: PyQt6
|
|
27
|
+
Provides-Extra: cuda11
|
|
28
|
+
Requires-Dist: cupy-cuda11x; extra == "cuda11"
|
|
29
|
+
Provides-Extra: cuda12
|
|
30
|
+
Requires-Dist: cupy-cuda12x; extra == "cuda12"
|
|
31
|
+
Provides-Extra: cupy
|
|
32
|
+
Requires-Dist: cupy; extra == "cupy"
|
|
33
|
+
|
|
34
|
+
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, run a python script in your env with the following commands:
|
|
35
|
+
|
|
36
|
+
#Start
|
|
37
|
+
|
|
38
|
+
from nettracer3d import nettracer_gui
|
|
39
|
+
|
|
40
|
+
nettracer_gui.run_gui()
|
|
41
|
+
|
|
42
|
+
#End
|
|
43
|
+
|
|
44
|
+
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
|
|
45
|
+
for a user manual that provides older documentation.
|
|
46
|
+
|
|
47
|
+
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
48
|
+
|
|
49
|
+
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
nettracer3d-0.3.0/PKG-INFO
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: nettracer3d
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
|
|
5
|
-
Author-email: Liam McLaughlin <boom2449@gmail.com>
|
|
6
|
-
Project-URL: User_Manual, https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
7
|
-
Project-URL: Reference_Citation_For_Use, https://doi.org/10.1101/2024.07.29.605633
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: Other/Proprietary License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: numpy
|
|
15
|
-
Requires-Dist: scipy
|
|
16
|
-
Requires-Dist: scikit-image
|
|
17
|
-
Requires-Dist: Pillow
|
|
18
|
-
Requires-Dist: matplotlib
|
|
19
|
-
Requires-Dist: networkx
|
|
20
|
-
Requires-Dist: opencv-python-headless
|
|
21
|
-
Requires-Dist: openpyxl
|
|
22
|
-
Requires-Dist: pandas
|
|
23
|
-
Requires-Dist: plotly
|
|
24
|
-
Requires-Dist: python-louvain
|
|
25
|
-
Requires-Dist: tifffile
|
|
26
|
-
Requires-Dist: PyQt6
|
|
27
|
-
Provides-Extra: cuda11
|
|
28
|
-
Requires-Dist: cupy-cuda11x; extra == "cuda11"
|
|
29
|
-
Provides-Extra: cuda12
|
|
30
|
-
Requires-Dist: cupy-cuda12x; extra == "cuda12"
|
|
31
|
-
Provides-Extra: cupy
|
|
32
|
-
Requires-Dist: cupy; extra == "cupy"
|
|
33
|
-
|
|
34
|
-
NetTracer3D is a python package developed for 3D analysis of microscopic images in the .tif file format, such as lightsheet images, although it can also be used for 2D analysis if the user converts the 2D .tif file into a 3D stack first by appending the image together twice. NetTracer3D does not function on images directly, but rather on binary/labelled segmentations of image signal, and general requires one segmentation to serve as objects in a network (nodes) and one segmentation to serve as a connective media (edges), although it is possible to make networks from only edges.
|
|
35
|
-
|
|
36
|
-
Please see: https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
37
|
-
for a user manual that provides documentation and detailed information.
|
|
38
|
-
|
|
39
|
-
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
40
|
-
|
|
41
|
-
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
nettracer3d-0.3.0/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
NetTracer3D is a python package developed for 3D analysis of microscopic images in the .tif file format, such as lightsheet images, although it can also be used for 2D analysis if the user converts the 2D .tif file into a 3D stack first by appending the image together twice. NetTracer3D does not function on images directly, but rather on binary/labelled segmentations of image signal, and general requires one segmentation to serve as objects in a network (nodes) and one segmentation to serve as a connective media (edges), although it is possible to make networks from only edges.
|
|
2
|
-
|
|
3
|
-
Please see: https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
4
|
-
for a user manual that provides documentation and detailed information.
|
|
5
|
-
|
|
6
|
-
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
7
|
-
|
|
8
|
-
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: nettracer3d
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: Scripts for intializing and analyzing networks from segmentations of three dimensional images.
|
|
5
|
-
Author-email: Liam McLaughlin <boom2449@gmail.com>
|
|
6
|
-
Project-URL: User_Manual, https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
7
|
-
Project-URL: Reference_Citation_For_Use, https://doi.org/10.1101/2024.07.29.605633
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: Other/Proprietary License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: numpy
|
|
15
|
-
Requires-Dist: scipy
|
|
16
|
-
Requires-Dist: scikit-image
|
|
17
|
-
Requires-Dist: Pillow
|
|
18
|
-
Requires-Dist: matplotlib
|
|
19
|
-
Requires-Dist: networkx
|
|
20
|
-
Requires-Dist: opencv-python-headless
|
|
21
|
-
Requires-Dist: openpyxl
|
|
22
|
-
Requires-Dist: pandas
|
|
23
|
-
Requires-Dist: plotly
|
|
24
|
-
Requires-Dist: python-louvain
|
|
25
|
-
Requires-Dist: tifffile
|
|
26
|
-
Requires-Dist: PyQt6
|
|
27
|
-
Provides-Extra: cuda11
|
|
28
|
-
Requires-Dist: cupy-cuda11x; extra == "cuda11"
|
|
29
|
-
Provides-Extra: cuda12
|
|
30
|
-
Requires-Dist: cupy-cuda12x; extra == "cuda12"
|
|
31
|
-
Provides-Extra: cupy
|
|
32
|
-
Requires-Dist: cupy; extra == "cupy"
|
|
33
|
-
|
|
34
|
-
NetTracer3D is a python package developed for 3D analysis of microscopic images in the .tif file format, such as lightsheet images, although it can also be used for 2D analysis if the user converts the 2D .tif file into a 3D stack first by appending the image together twice. NetTracer3D does not function on images directly, but rather on binary/labelled segmentations of image signal, and general requires one segmentation to serve as objects in a network (nodes) and one segmentation to serve as a connective media (edges), although it is possible to make networks from only edges.
|
|
35
|
-
|
|
36
|
-
Please see: https://drive.google.com/drive/folders/1fTkz3n4LN9_VxKRKC8lVQSlrz_wq0bVn?usp=drive_link
|
|
37
|
-
for a user manual that provides documentation and detailed information.
|
|
38
|
-
|
|
39
|
-
NetTracer3D is free to use/fork for academic/nonprofit use so long as citation is provided, and is available for commercial use at a fee (see license file for information).
|
|
40
|
-
|
|
41
|
-
NetTracer3D was developed by Liam McLaughlin while working under Dr. Sanjay Jain at Washington University School of Medicine.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|