Skip to content

Commit 49b4a43

Browse files
anna-grimanna-grim
andauthored
Bug path parser (#152)
* bugs: path parser, write * bug: skeleton writer: * bug: write skeleton graph --------- Co-authored-by: anna-grim <[email protected]>
1 parent 6f0a39c commit 49b4a43

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/segmentation_skeleton_metrics/skeleton_graph.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,24 +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
307-
text_buffer.write("\n" + "# id, type, z, y, x, r, pid")
308+
text_buffer.write(self.get_color())
309+
text_buffer.write("\n# id, type, z, y, x, r, pid")
308310

309311
# Write entries
312+
cnt = 1
310313
node_to_idx = defaultdict(lambda: -1)
311314
for i, j in nx.dfs_edges(self):
312315
# Special Case: Root
313316
if len(node_to_idx) == 0:
314-
write_entry(i, node_to_idx[i])
317+
write_entry(i, -1)
315318

316319
# General Case: Non-Root
317-
write_entry(j, node_to_idx[i])
320+
cnt += 1
321+
write_entry(j, i)
318322

319323
# Finish
320324
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)