Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 09ae9de9 authored by NADAL Morgane's avatar NADAL Morgane
Browse files

added some features

parent 57c59876
No related branches found
No related tags found
No related merge requests found
......@@ -394,34 +394,53 @@ for soma in somas:
#
elapsed_time = tm_.gmtime(tm_.time() - start_time)
# --- Some info about the skeleton graphs
print(
f"\n\n--- Graph infos\n"
f"N nodes={soma.skl_graph.n_nodes}\n"
f"N edges={soma.skl_graph.n_edges}\n"
f"Highest degree={soma.skl_graph.highest_degree}/{soma.skl_graph.highest_degree_w_nodes}\n"
f"Length={soma.skl_graph.length}<-{soma.skl_graph.edge_lengths}\n"
f"Width=Hom.{soma.skl_graph.reduced_width()}/Het.{soma.skl_graph.heterogeneous_reduced_width()}<-{soma.skl_graph.edge_reduced_widths()}\n "
f"Area as WxL={soma.skl_graph.reduced_width() * soma.skl_graph.length}\n"
f"Area as WW Length={soma.skl_graph.ww_length}<-{soma.skl_graph.edge_ww_lengths}\n\n"
)
# --- Extract features
print('--- Extracting features')
# -- Soma features
# Volume of the soma
# Soma features
print('-- Soma')
# # Volume of the soma
volume_pixel_micron = round(mt_.prod(size_voxel_in_micron[axis] for axis in (0, 1, 2)), 4)
soma.volume_soma_micron = volume_pixel_micron * len(soma.sites[0])
print("Soma volume = ", soma.volume_soma_micron)
# Axes of the best fitting ellipsoid
# # Axes of the best fitting ellipsoid
soma.axes_ellipsoid = bf_.FindBestFittingEllipsoid3D(soma)[2]
print(soma.axes_ellipsoid)
print("Axes of best fitting ellipsoid : ", soma.axes_ellipsoid)
# -- Extension features
# # Graph features
N_nodes = soma.skl_graph.n_nodes # number of nodes
N_ext = soma.skl_graph.n_edges - len(soma.graph_roots) # number of edges except the constructed ones from node soma to the roots
N_primary_ext = len(soma.graph_roots) # number of primary edges = linked to the soma except the constructed ones from node soma to the roots
N_sec_ext = N_ext - N_primary_ext # number of secondary edges = not linked to the soma.
highest_degree = soma.skl_graph.fct_degree # highest degree of the nodes except the soma
highest_degree_w_node = soma.skl_graph.highest_degree_w_nodes # highest degree of the nodes with the node coordinates except the soma
N_nodes_of_highest_degree = len(highest_degree_w_node[1]) # number of nodes of highest degree
# min, mean and max degrees of non-leaves nodes
min_degree = soma.skl_graph.fct_degree_except_leaves(min)
mean_degree = soma.skl_graph.fct_degree_except_leaves(np_.mean)
max_degree = soma.skl_graph.fct_degree_except_leaves(max)
print(
f"\n-- Extensions\n"
f"N nodes = {N_nodes}\n"
f"N edges = {N_ext}\n"
f"N primary extensions = {N_primary_ext}\n"
f"N secondary extensions = {N_sec_ext}\n"
#
f"Highest degree (except soma) = {highest_degree}/{highest_degree_w_node}\n"
f"N nodes with highest degree = {N_nodes_of_highest_degree}\n"
f"Min/Mean/Max degree (except soma & leaves) = {min_degree}/{mean_degree}/{max_degree}\n"
#
f"Length={soma.skl_graph.length}<-{soma.skl_graph.edge_lengths}\n"
f"Width=Hom.{soma.skl_graph.reduced_width()}/Het.{soma.skl_graph.heterogeneous_reduced_width()}<-{soma.skl_graph.edge_reduced_widths()}\n "
f"Area as WxL={soma.skl_graph.reduced_width() * soma.skl_graph.length}\n"
f"Area as WW Length={soma.skl_graph.ww_length}<-{soma.skl_graph.edge_ww_lengths}\n\n"
)
# TODO = Add all the info in a csv or pandas df
#
elapsed_time = tm_.gmtime(tm_.time() - start_time)
......
# Copyright CNRS/Inria/UNS
# Contributor(s): Eric Debreuve (since 2018)
# Contributor(s): Eric Debreuve (since 2018), Morgane Nadal (2020)
#
# eric.debreuve@cnrs.fr
#
......@@ -49,8 +49,12 @@ class skl_graph_t(skl_nfgraph_t):
return self.number_of_edges()
@property
def highest_degree(self) -> int:
return max(degree for ___, degree in self.degree)
def fct_degree(self, fct: callable = max) -> int:
return fct(list(degree for node, degree in self.degree if "S" not in node))
@property
def fct_degree_except_leaves(self, fct: callable = max) -> int:
return fct(list(degree for node, degree in self.degree if "S" not in node and degree != 1))
@property
def highest_degree_w_nodes(self) -> Tuple[int, List[str]]:
......@@ -58,11 +62,12 @@ class skl_graph_t(skl_nfgraph_t):
max_degree = -1
at_nodes = None
for node, degree in self.degree:
if degree > max_degree:
max_degree = degree
at_nodes = [node]
elif degree == max_degree:
at_nodes.append(node)
if "S" not in node:
if degree > max_degree:
max_degree = degree
at_nodes = [node]
elif degree == max_degree:
at_nodes.append(node)
return max_degree, at_nodes
......@@ -91,7 +96,7 @@ class skl_graph_t(skl_nfgraph_t):
return sum(self.edge_ww_lengths)
def edge_reduced_widths(
self, reduce_fct: Callable[[Iterable[float]], float] = np_.mean
self, reduce_fct: Callable[[Iterable[float]], float] = np_.mean
) -> Tuple[float, ...]:
#
return tuple(
......@@ -99,7 +104,7 @@ class skl_graph_t(skl_nfgraph_t):
)
def reduced_width(
self, reduce_fct: Callable[[Iterable[float]], float] = np_.mean
self, reduce_fct: Callable[[Iterable[float]], float] = np_.mean
) -> float:
#
all_widths = []
......@@ -110,9 +115,9 @@ class skl_graph_t(skl_nfgraph_t):
return reduce_fct(all_widths)
def heterogeneous_reduced_width(
self,
edge_reduce_fct: Callable[[Iterable[float]], float] = np_.mean,
final_reduce_fct: Callable[[Iterable[float]], float] = np_.mean,
self,
edge_reduce_fct: Callable[[Iterable[float]], float] = np_.mean,
final_reduce_fct: Callable[[Iterable[float]], float] = np_.mean,
) -> float:
#
return final_reduce_fct(self.edge_reduced_widths(edge_reduce_fct))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment