Skip to content

Commit 7b9a413

Browse files
author
anna-grim
committed
bug: write skeleton graph
1 parent 12e1162 commit 7b9a413

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/segmentation_skeleton_metrics/skeleton_graph.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,25 +297,28 @@ def to_zipped_swc(self, zip_writer):
297297
def write_entry(node, parent):
298298
x, y, z = tuple(self.voxels[i] * self.anisotropy)
299299
r = 2 if self.is_groundtruth else 3
300-
node_id = len(node_to_idx) + 1
300+
node_id = cnt
301+
parent_id = node_to_idx[parent]
301302
node_to_idx[node] = node_id
302-
text_buffer.write("\n" + f"{node_id} 2 {x} {y} {z} {r} {parent}")
303+
text_buffer.write(f"\n{node_id} 2 {x} {y} {z} {r} {parent_id}")
303304

304305
# Main
305306
with StringIO() as text_buffer:
306307
# Preamble
307308
text_buffer.write(self.get_color())
308-
text_buffer.write("\n" + "# id, type, z, y, x, r, pid")
309+
text_buffer.write("\n# id, type, z, y, x, r, pid")
309310

310311
# Write entries
312+
cnt = 1
311313
node_to_idx = defaultdict(lambda: -1)
312314
for i, j in nx.dfs_edges(self):
313315
# Special Case: Root
314316
if len(node_to_idx) == 0:
315-
write_entry(i, node_to_idx[i])
317+
write_entry(i, -1)
316318

317319
# General Case: Non-Root
318-
write_entry(j, node_to_idx[i])
320+
cnt += 1
321+
write_entry(j, i)
319322

320323
# Finish
321324
zip_writer.writestr(self.filename, text_buffer.getvalue())

src/segmentation_skeleton_metrics/utils/swc_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,14 @@ def read_from_gcs_swcs(self, bucket_name, swc_paths):
326326
with ThreadPoolExecutor() as executor:
327327
# Assign threads
328328
threads = list()
329+
cnt = 0
329330
for path in swc_paths:
330331
threads.append(
331332
executor.submit(self.read_from_gcs_swc, bucket_name, path)
332333
)
334+
cnt += 1
335+
if cnt > 2:
336+
break # temp
333337

334338
# Store results
335339
swc_dicts = deque()

src/segmentation_skeleton_metrics/utils/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,3 @@ def save_results(path, stats):
533533
sheet.write(i + 1, j + 1, round(stats[swc_id][metric], 4))
534534

535535
wb.save(path)
536-

0 commit comments

Comments
 (0)