Skip to content

Commit

Permalink
refactor: output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-grim committed Oct 30, 2024
1 parent a25423f commit eac48eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
28 changes: 16 additions & 12 deletions src/deep_neurographs/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(

# Set output directory
date = datetime.today().strftime("%Y-%m-%d")
self.output_dir = f"{output_dir}/{segmentation_id}-{date}"
self.output_dir = output_dir
util.mkdir(self.output_dir, delete=True)
if self.log_runtimes:
log_path = os.path.join(self.output_dir, "runtimes.txt")
Expand Down Expand Up @@ -221,17 +221,7 @@ def build_graph(self, fragments_pointer):
prune_depth=self.graph_config.prune_depth,
)
self.graph = graph_builder.run(fragments_pointer)

# Filter fragments
n_curvy = fragment_filtering.remove_curvy(self.graph, 200)
n_curvy = util.reformat_number(n_curvy)
if self.graph_config.remove_doubles_bool:
n_doubles = fragment_filtering.remove_doubles(
self.graph, 200, self.graph_config.node_spacing
)
n_doubles = util.reformat_number(n_doubles)
self.report(f"# Double Fragments Deleted: {n_doubles}")
self.report(f"# Curvy Fragments Deleted: {n_curvy}")
self.filter_fragments()

# Save valid labels and current graph
swcs_path = os.path.join(self.output_dir, "processed-swcs.zip")
Expand All @@ -248,6 +238,20 @@ def build_graph(self, fragments_pointer):
self.report("\nInitial Graph...")
self.report_graph()

def filter_fragments(self):
# Filter curvy fragments
n_curvy = fragment_filtering.remove_curvy(self.graph, 200)
n_curvy = util.reformat_number(n_curvy)

# Filter doubles
if self.graph_config.remove_doubles_bool:
n_doubles = fragment_filtering.remove_doubles(
self.graph, 200, self.graph_config.node_spacing
)
n_doubles = util.reformat_number(n_doubles)
self.report(f"# Double Fragments Deleted: {n_doubles}")
self.report(f"# Curvy Fragments Deleted: {n_curvy}")

def generate_proposals(self, radius=None):
"""
Generates proposals for the fragment graph based on the specified
Expand Down
16 changes: 10 additions & 6 deletions src/deep_neurographs/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


def visualize_connected_components(
graph, line_width=5, return_data=False, title=""
graph, line_width=3, return_data=False, title=""
):
"""
Visualizes the connected components in "graph".
Expand Down Expand Up @@ -202,11 +202,15 @@ def plot_nodes(graph):
)


def plot_proposals(graph, proposals, color=None, line_width=3.5):
def plot_proposals(graph, proposals, color=None, line_width=5):
# Set preferences
if color is None:
line = dict(width=line_width)
else:
line = dict(color=color, width=line_width)

# Add traces
traces = []
line = (
dict(width=5) if color is None else dict(color=color, width=line_width)
)
for p in proposals:
xyz = graph.proposal_xyz(p)
trace = go.Scatter3d(
Expand All @@ -221,7 +225,7 @@ def plot_proposals(graph, proposals, color=None, line_width=3.5):
return traces


def plot_edges(graph, edges, color=None, line_width=3.5):
def plot_edges(graph, edges, color=None, line_width=3):
traces = []
line = (
dict(width=5) if color is None else dict(color=color, width=line_width)
Expand Down

0 comments on commit eac48eb

Please sign in to comment.