Skip to content

Commit

Permalink
Feat absorb reducibles (#237)
Browse files Browse the repository at this point in the history
* feat: absorb reducible nodes

* bug: save results during inference rounds

---------

Co-authored-by: anna-grim <[email protected]>
  • Loading branch information
anna-grim and anna-grim authored Sep 19, 2024
1 parent 5abaf66 commit e4e61a9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/deep_neurographs/run_graphtrace_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ def run_schedule(self, fragments_pointer, search_radius_schedule):

# Main
self.build_graph(fragments_pointer)
for search_radius in search_radius_schedule:
for round_id, search_radius in enumerate(search_radius_schedule):
print(f"--- Round {round_id + 1}: Radius = {search_radius} ---")
round_id += 1
self.generate_proposals(search_radius=search_radius)
self.run_inference()
self.save_results()
self.save_results(round_id=round_id)
t, unit = util.time_writer(time() - t0)
print(f"Total Runtime: {round(t, 4)} {unit}\n")

Expand Down Expand Up @@ -267,15 +269,15 @@ def save_results(self, round_id=None):
None
"""
print("(4) Saving Results")
name = "corrected-processed-swcs.zip"
path = os.path.join(self.output_dir, name + ".zip")
suffix = f"-{round_id}" if round_id else ""
filename = f"corrected-processed-swcs{suffix}.zip"
path = os.path.join(self.output_dir, filename)
self.graph.to_zipped_swcs(path)
self.save_connections()
self.save_connections(round_id=round_id)
self.write_metadata()

# --- io ---
def save_connections(self):
def save_connections(self, round_id=None):
"""
Saves predicted connections between connected components in a txt file.
Expand All @@ -288,7 +290,8 @@ def save_connections(self):
None
"""
path = os.path.join(self.output_dir, "connections.txt")
suffix = f"-{round_id}" if round_id else ""
path = os.path.join(self.output_dir, f"connections{suffix}.txt")
with open(path, "w") as f:
for id_1, id_2 in self.graph.merged_ids:
f.write(f"{id_1}, {id_2}" + "\n")
Expand Down

0 comments on commit e4e61a9

Please sign in to comment.