nettracer3d 0.3.8__py3-none-any.whl → 0.4.0__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/nettracer.py CHANGED
@@ -22,9 +22,7 @@ except:
22
22
  pass
23
23
  from . import node_draw
24
24
  from . import network_draw
25
- from skimage.morphology import skeletonize_3d
26
- #from skimage.segmentation import watershed
27
- from skimage.feature import peak_local_max
25
+ from skimage import morphology as mpg
28
26
  from concurrent.futures import ThreadPoolExecutor, as_completed
29
27
  from . import smart_dilate
30
28
  from . import modularity
@@ -864,6 +862,11 @@ def dilate_3D(tiff_array, dilated_x, dilated_y, dilated_z):
864
862
  """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.
865
863
  Arguments are an array, and the desired pixel dilation amounts in X, Y, Z."""
866
864
 
865
+
866
+ if dilated_x == 3 and dilated_y == 3 and dilated_z == 3:
867
+
868
+ return dilate_3D_old(tiff_array, dilated_x, dilated_y, dilated_z)
869
+
867
870
  def create_circular_kernel(diameter):
868
871
  """Create a 2D circular kernel with a given radius.
869
872
 
@@ -1500,7 +1503,7 @@ def skeletonize(arrayimage, directory = None):
1500
1503
  else:
1501
1504
  image = None
1502
1505
 
1503
- arrayimage = (skeletonize_3d(arrayimage))
1506
+ arrayimage = (mpg.skeletonize(arrayimage))
1504
1507
 
1505
1508
  if type(image) == str:
1506
1509
  if directory is None:
@@ -4182,6 +4185,51 @@ class Network_3D:
4182
4185
 
4183
4186
  return array
4184
4187
 
4188
+ def community_id_info(self):
4189
+ def invert_dict(d):
4190
+ inverted = {}
4191
+ for key, value in d.items():
4192
+ inverted.setdefault(value, []).append(key)
4193
+ return inverted
4194
+
4195
+ community_dict = invert_dict(self.communities)
4196
+ summation = 0
4197
+ id_set = set(self.node_identities.values())
4198
+ output = {sort: 0 for sort in id_set}
4199
+ template = copy.deepcopy(output)
4200
+
4201
+ for community in community_dict:
4202
+ counter = copy.deepcopy(template)
4203
+ nodes = community_dict[community]
4204
+ size = len(nodes)
4205
+ summation += size
4206
+
4207
+ # Count identities in this community
4208
+ for node in nodes:
4209
+ counter[self.node_identities[node]] += 1
4210
+
4211
+ # Convert to proportions within this community and weight by size
4212
+ for sort in counter:
4213
+ if size > 0: # Avoid division by zero
4214
+ counter[sort] = (counter[sort]) * size # proportion * size
4215
+
4216
+ # Add to running totals
4217
+ for sort, weighted_count in counter.items():
4218
+ output[sort] = output.get(sort, 0) + weighted_count
4219
+
4220
+ # Normalize by total size
4221
+ dictsum = 0
4222
+ for sort in output:
4223
+ output[sort] = output[sort]/summation
4224
+ dictsum += output[sort]
4225
+
4226
+ for sort in output:
4227
+ output[sort] = output[sort]/dictsum
4228
+
4229
+ return output
4230
+
4231
+
4232
+
4185
4233
 
4186
4234
  def kd_network(self, distance = 100, targets = None):
4187
4235
 
@@ -1784,8 +1784,10 @@ class ImageViewerWindow(QMainWindow):
1784
1784
  network_menu = analysis_menu.addMenu("Network")
1785
1785
  netshow_action = network_menu.addAction("Show Network")
1786
1786
  netshow_action.triggered.connect(self.show_netshow_dialog)
1787
- partition_action = network_menu.addAction("Community Partition + Community Stats")
1787
+ partition_action = network_menu.addAction("Community Partition +Generic Community Stats")
1788
1788
  partition_action.triggered.connect(self.show_partition_dialog)
1789
+ com_identity_action = network_menu.addAction("Identity Makeup of Network Communities (Weighted avg by community size)")
1790
+ com_identity_action.triggered.connect(self.handle_com_id)
1789
1791
  stats_menu = analysis_menu.addMenu("Stats")
1790
1792
  allstats_action = stats_menu.addAction("Calculate Generic Network Stats")
1791
1793
  allstats_action.triggered.connect(self.stats)
@@ -2996,6 +2998,21 @@ class ImageViewerWindow(QMainWindow):
2996
2998
  dialog = PartitionDialog(self)
2997
2999
  dialog.exec()
2998
3000
 
3001
+ def handle_com_id(self):
3002
+ if my_network.node_identities is None:
3003
+ print("Node identities must be set")
3004
+
3005
+ if my_network.communities is None:
3006
+ self.show_partition_dialog()
3007
+
3008
+ if my_network.communities is None:
3009
+ return
3010
+
3011
+ info = my_network.community_id_info()
3012
+
3013
+ self.format_for_upperright_table(info, 'Node Identity Type', 'Weighted Proportion in Communities', 'Weighted Average of Community Makeup')
3014
+
3015
+
2999
3016
  def show_radial_dialog(self):
3000
3017
  dialog = RadialDialog(self)
3001
3018
  dialog.exec()
@@ -4368,6 +4385,8 @@ class PartitionDialog(QDialog):
4368
4385
  except Exception as e:
4369
4386
  print(f"Error creating communities: {e}")
4370
4387
 
4388
+
4389
+
4371
4390
  class RadialDialog(QDialog):
4372
4391
 
4373
4392
  def __init__(self, parent=None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nettracer3d
3
- Version: 0.3.8
3
+ Version: 0.4.0
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
@@ -3,16 +3,16 @@ nettracer3d/community_extractor.py,sha256=8bRDJOfZhOFLtpkJVaDQrQ4O8wUywyr-EfVvW5
3
3
  nettracer3d/hub_getter.py,sha256=KiNtxdajLkwB1ftslvrh1FE1Ch9ZCFEmHSEEotwR-To,8298
4
4
  nettracer3d/modularity.py,sha256=V1f3s_vGd8EuVz27mzq6ycIGr0BWIpH7c7NU4QjgAHU,30247
5
5
  nettracer3d/morphology.py,sha256=wv7v06YUcn5lMyefcc_znQlXF5iDxvUdoc0fXOKlGTw,12982
6
- nettracer3d/nettracer.py,sha256=CfAdS3SnigL4TkfqwHRIg0WeBtwJ1nGysNq5pfSSwVU,201682
7
- nettracer3d/nettracer_gui.py,sha256=VJJE03DebIgK_A1Pga7tfUxiQOUXZ0fTYG5ZwThd35M,289339
6
+ nettracer3d/nettracer.py,sha256=sFwHz-Ghoft3nNS3H691EcMTpoeLKT3I_X-6m6vXpyg,203264
7
+ nettracer3d/nettracer_gui.py,sha256=GSTICp2V0MAwMpw6RcUrR0kdF721bpBOGMHnOK2LHLM,290039
8
8
  nettracer3d/network_analysis.py,sha256=MJBBjslA1k_R8ymid77U-qGSgzxFVfzGVQhE0IdhnbE,48046
9
9
  nettracer3d/network_draw.py,sha256=F7fw6Pcf4qWOhdKwLmhwqWdschbDlHzwCVolQC9imeU,14117
10
10
  nettracer3d/node_draw.py,sha256=BMiD_FrlOHeGD4AQZ_Emd152PfxFuMgGf2x4S0TOTnw,9752
11
11
  nettracer3d/proximity.py,sha256=KYs4QUbt1U79RLzTvt8BmrxeGVaeKOQ2brtzTjjA78c,11011
12
12
  nettracer3d/simple_network.py,sha256=fP1gkDdtQcHruEZpUdasKdZeVacoLOxKhR3bY0L1CAQ,15426
13
13
  nettracer3d/smart_dilate.py,sha256=howfO6Lw5PxNjkaOBSCjkmf7fyau_-_8iTct2mAuTAQ,22083
14
- nettracer3d-0.3.8.dist-info/LICENSE,sha256=gM207DhJjWrxLuEWXl0Qz5ISbtWDmADfjHp3yC2XISs,888
15
- nettracer3d-0.3.8.dist-info/METADATA,sha256=FS6GRDErGwT93g0XvCatJ36Z4s8olwVrgTrJER-ldks,2894
16
- nettracer3d-0.3.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- nettracer3d-0.3.8.dist-info/top_level.txt,sha256=zsYy9rZwirfCEOubolhee4TyzqBAL5gSUeFMzhFTX8c,12
18
- nettracer3d-0.3.8.dist-info/RECORD,,
14
+ nettracer3d-0.4.0.dist-info/LICENSE,sha256=gM207DhJjWrxLuEWXl0Qz5ISbtWDmADfjHp3yC2XISs,888
15
+ nettracer3d-0.4.0.dist-info/METADATA,sha256=lu39yZioerqbPHonV_S5P04-KeJlncq5MqitDJffkWw,2894
16
+ nettracer3d-0.4.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ nettracer3d-0.4.0.dist-info/top_level.txt,sha256=zsYy9rZwirfCEOubolhee4TyzqBAL5gSUeFMzhFTX8c,12
18
+ nettracer3d-0.4.0.dist-info/RECORD,,