Skip to content

Commit 58b975a

Browse files
author
anna-grim
committed
refactor: updated doubles filtering
1 parent 37a47db commit 58b975a

5 files changed

Lines changed: 93 additions & 350 deletions

File tree

src/neuron_proofreader/proposal_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
)
2828
from neuron_proofreader.split_proofreading.proposal_generation import (
2929
ProposalGenerator,
30-
trim_endpoints_at_proposal
30+
trim_proposal_endpoints
3131
)
3232
from neuron_proofreader.utils import (
3333
geometry_util as geometry,
@@ -350,7 +350,7 @@ def trim_proposals(self):
350350
is_simple = self.is_simple(proposal)
351351
is_single = self.is_single_proposal(proposal)
352352
if is_simple and is_single:
353-
trim_endpoints_at_proposal(self, proposal)
353+
trim_proposal_endpoints(self, proposal)
354354

355355
# --- Proposal Feature Generation ---
356356
def proposal_attr(self, proposal, key):

src/neuron_proofreader/skeleton_graph.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
from collections import defaultdict
1414
from io import StringIO
1515
from scipy.spatial import KDTree
16+
from scipy.spatial import distance
1617

1718
import networkx as nx
1819
import numpy as np
1920
import zipfile
2021

21-
from neuron_proofreader.utils import (
22-
geometry_util, graph_util as gutil, img_util, util
23-
)
22+
from neuron_proofreader.utils import graph_util as gutil, img_util, util
2423

2524

2625
class SkeletonGraph(nx.Graph):
@@ -113,6 +112,7 @@ def load(self, swc_pointer):
113112
self.node_component_id = np.zeros((n), dtype=int)
114113
self.node_radius = np.zeros((n), dtype=np.float16)
115114
self.node_xyz = np.zeros((n, 3), dtype=np.float32)
115+
self.set_kdtree()
116116

117117
# Add irreducibles to graph
118118
component_id = 0
@@ -191,8 +191,8 @@ def _add_edge(self, edge_id, attrs, component_id):
191191
"""
192192
# Determine orientation of attributes
193193
i, j = tuple(edge_id)
194-
dist_i = geometry_util.dist(self.node_xyz[i], attrs["xyz"][0])
195-
dist_j = geometry_util.dist(self.node_xyz[j], attrs["xyz"][0])
194+
dist_i = distance.euclidean(self.node_xyz[i], attrs["xyz"][0])
195+
dist_j = distance.euclidean(self.node_xyz[j], attrs["xyz"][0])
196196
if dist_i < dist_j:
197197
start = i
198198
end = j
@@ -704,7 +704,7 @@ def dist(self, i, j):
704704
float
705705
Euclidean distance between nodes "i" and "j".
706706
"""
707-
return geometry_util.dist(self.node_xyz[i], self.node_xyz[j])
707+
return distance.euclidean(self.node_xyz[i], self.node_xyz[j])
708708

709709
def get_irreducible_edge(self, node):
710710
# Check node is non-branhching

src/neuron_proofreader/split_proofreading/proposal_generation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def find_node_candidates(self, leaf, radius):
141141
"""
142142
node_candidates = list()
143143
for node in self.get_nearby_nodes(leaf, radius):
144-
# check whether to move to leaf if allowing leaf-branch connections
144+
# UPDATE - check whether to move to leaf if allowing leaf-branch connections
145145
if self.is_valid_proposal(leaf, node):
146146
node_candidates.append(node)
147147
return node_candidates
@@ -257,7 +257,7 @@ def set_kdtree(self):
257257

258258

259259
# --- Trim Endpoints ---
260-
def trim_endpoints_at_proposal(graph, proposal, max_depth=20):
260+
def trim_proposal_endpoints(graph, proposal, max_depth=20):
261261
"""
262262
Trims branch endpoints corresponding to the given proposal.
263263

0 commit comments

Comments
 (0)