Skip to content

Commit

Permalink
major upd : asynchronous intake
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-grim committed Jan 11, 2024
1 parent 0899829 commit 0bf602b
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 277 deletions.
36 changes: 4 additions & 32 deletions src/deep_neurographs/feature_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,42 +164,14 @@ def generate_img_profiles(neurograph, path, anisotropy=[1.0, 1.0, 1.0]):
)
img = utils.normalize_img(img)
for edge in neurograph.mutable_edges:
if neurograph.optimize_alignment or neurograph.optimize_path:
xyz = to_img_coords(neurograph, edge)
path = geometry_utils.sample_path(xyz, N_PROFILE_POINTS)
else:
i, j = tuple(edge)
xyz_i = utils.world_to_img(neurograph, i)
xyz_j = utils.world_to_img(neurograph, j)
path = geometry_utils.make_line(xyz_i, xyz_j, N_PROFILE_POINTS)
xyz_i, xyz_j = neurograph.get_edge_attr("xyz", edge)
xyz_i = utils.world_to_img(neurograph, xyz_i)
xyz_j = utils.world_to_img(neurograph, xyz_j)
path = geometry_utils.make_line(xyz_i, xyz_j, N_PROFILE_POINTS)
features[edge] = geometry_utils.get_profile(img, path, window=WINDOW)
return features


def to_img_coords(neurograph, edge):
"""
Converts xyz coordinate of each vertex in "edge" from real world to image
coordinates.
Parameters
----------
neurograph : NeuroGraph
NeuroGraph generated from a directory of swcs generated from a
predicted segmentation.
edge : frozenset
The edge from "neurograph" to perform coordinate transformation.
Returns
-------
img_coords : numpy.ndarray
Image coordinates of each vertex from "edge".
"""
xyz_list = neurograph.edges[edge]["xyz"]
img_coords = [utils.world_to_img(neurograph, xyz) for xyz in xyz_list]
return np.array(img_coords)


def generate_mutable_skel_features(neurograph):
features = dict()
for edge in neurograph.mutable_edges:
Expand Down
4 changes: 2 additions & 2 deletions src/deep_neurographs/geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@


# Directional Vectors
def get_directional(neurograph, i, proposal_tangent, window=5):
def get_directional(neurograph, i, proposal_tangent, window=5, n_svd_points=10):
directionals = []
d = neurograph.optimize_depth
d = n_svd_points
for branch in neurograph.get_branches(i):
if branch.shape[0] >= window + d:
xyz = deepcopy(branch[d:, :])
Expand Down
23 changes: 14 additions & 9 deletions src/deep_neurographs/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
Routines that extract the irreducible components of a graph.
--define what an irreducible is
leafs : set
Nodes with degreee 1.
junctions : set
Nodes with degree > 2.
edges : dict
Set of edges connecting nodes in leafs and junctions. The keys are
pairs of nodes connected by an edge and values are a dictionary of
attributes.
--define what a branch is
"""
Expand Down Expand Up @@ -41,14 +50,10 @@ def get_irreducibles(swc_dict, prune=True, depth=16, smooth=True):
Returns
-------
leafs : set
Nodes with degreee 1.
junctions : set
Nodes with degree > 2.
edges : dict
Set of edges connecting nodes in leafs and junctions. The keys are
pairs of nodes connected by an edge and values are a dictionary of
attributes.
dict
Irreducibles stored in a dictionary where key-values are type of
irreducible (i.e. leaf, junction, or edge) and corresponding set of
all irreducibles from the graph of that type.
"""
# Initializations
Expand Down Expand Up @@ -80,7 +85,7 @@ def get_irreducibles(swc_dict, prune=True, depth=16, smooth=True):
nbs = append_value(nbs, root, j)
nbs = append_value(nbs, j, root)
root = None
return leafs, junctions, edges
return {"leafs": leafs, "junctions": junctions, "edges": edges}


def get_irreducible_nodes(graph):
Expand Down
Loading

0 comments on commit 0bf602b

Please sign in to comment.