Mentions légales du service

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

usable version of dilatation/erosion during connexion of extensions

parent 44c1e086
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,7 @@ def ShortestPathFromToN(
extension: extension_t,
costs: array_t,
candidate_points_fct: Callable,
all_end_points: tuple = None,
all_end_points: list = None,
extensions: tuple = None,
max_straight_sq_dist: float = np_.inf,
erode_path: bool = False,
......@@ -114,12 +114,12 @@ def ShortestPathFromToN(
# -- important for dilatation/erosion process
for candidate, indx in enumerate(candidate_points):
# Verify if end point
if candidate not in zip(*all_end_points):
if candidate not in all_end_points:
# Here necessary to delete the 2 closest points next to the end points
# because if the all extension is candidate there might be a endpoint
# that will be polluted by the connection
not_allowed = set()
for e_p in zip(*all_end_points):
for e_p in all_end_points:
not_allowed_ = set(
(e_p[0] + i, e_p[1] + j, e_p[2] + k)
for i in (-2, -1, 0, 1, 2)
......@@ -177,7 +177,7 @@ def ShortestPathFromToN(
def ValidateConnection(
glial_cmp: glial_cmp_t, extension: glial_cmp_t, end_point: tuple, dijkstra_path: site_path_h, costs: array_t,
glial_cmp: glial_cmp_t, extension: glial_cmp_t, end_point: tuple, dijkstra_path: site_path_h, costs: array_t, all_ep: list,
) -> None:
'''
Keep the connection path in the glial_cmp.
......@@ -200,6 +200,8 @@ def ValidateConnection(
# restrain the verification to the soma <-> ext step
# Store the new endpoints of the extended extension - TODO update the end point vector
all_ep.remove(end_point)
if type(glial_cmp) is soma_t:
end_point = UpdateEndPointsWithConnexionPath(connection_path, end_point)
glial_cmp.ext_roots.append((extension.uid, end_point))
......@@ -218,28 +220,13 @@ def ValidateConnection(
extension.sites = tuple(extension.sites)
def UpdateEndPointsWithConnexionPath(connexion_path: tuple, end_point: tuple) -> tuple:
#
if connexion_path is None:
return end_point
else:
# /!\ may yield a bug
# Update the end point vector - delete the old endpoint
# # reformat to modify them
# all_end_points_var = list(all_end_points)
# all_end_points = []
# for i in all_end_points_var:
# indx = list(i)
# all_end_points.append(indx)
# # delete the connected end point
# if end_point in zip(*all_end_points):
# idx = list(zip(*all_end_points)).index(end_point)
# for i in range(3):
# all_end_points[i].pop(idx)
# else:
# print("WARNING: End point not in the all end points vectors !")
# Search the connection point link to the extension
connexion_path = tuple(zip(*connexion_path))
......@@ -251,15 +238,9 @@ def UpdateEndPointsWithConnexionPath(connexion_path: tuple, end_point: tuple) ->
if i != 0 or j != 0 or k != 0)
if connexion_path[0] in close_end_pt:
# for i in range(3):
# all_end_points.append(connexion_path[-1][i])
# all_end_points = tuple(all_end_points)
return connexion_path[-1]
elif connexion_path[-1] in close_end_pt:
# for i in range(3):
# all_end_points.append(connexion_path[0][i])
# all_end_points = tuple(all_end_points)
return connexion_path[0]
......@@ -298,7 +279,7 @@ def Erode(path: Tuple[tuple],
for point in path:
# find out whether this is a end point or not
if point in zip(*all_end_points):
if point in all_end_points:
ErodeEndPoint(point, costs_map, extension, image)
else:
# build a new path with no endpoints inside
......
......@@ -205,7 +205,7 @@ def NutriMorph(data_path: str,
# iv_.image_verification(image, channel) # -> PySide2 user interface # TODO: must return the modified image!
# /!\ conflicts between some versions of PySide2 and Python3
image = image[:, 800:, 300:]
# image = image[:, 800:, 300:]
img_shape = image.shape
#
print(f"IMAGE: s.{img_shape} t.{image.dtype} m.{image.min()} M.{image.max()}")
......@@ -351,7 +351,7 @@ def NutriMorph(data_path: str,
# Create global end point map for extensions
glob_ext_ep_map = xt_.EndPointMap(ext_nfo["lmp"] > 0)
all_end_points = glob_ext_ep_map.nonzero()
all_end_points = list(zip(*glob_ext_ep_map.nonzero())) # updated in ValidateConnexion
#
elapsed_time = tm_.gmtime(tm_.time() - start_time)
......@@ -411,7 +411,7 @@ def NutriMorph(data_path: str,
# length in pixel and max_weighted_length_c too
if length <= max_weighted_length_c:
# Validate and update all the fields + dilate again the whole extension
cn_.ValidateConnection(soma, extension, end_point, path, dijkstra_costs)
cn_.ValidateConnection(soma, extension, end_point, path, dijkstra_costs, all_ep=all_end_points)
if dilatation_erosion:
# Dilate extensions
cn_.Dilate(extension.sites, dijkstra_costs)
......@@ -495,7 +495,7 @@ def NutriMorph(data_path: str,
# If so, returns the extensions containing the path last site.
tgt_extenstion = extension_t.ExtensionContainingSite(extensions, path[-1])
# Validate connexion: update the glial component objects and store more info in their fields
cn_.ValidateConnection(tgt_extenstion, extension, end_point, path, dijkstra_costs)
cn_.ValidateConnection(tgt_extenstion, extension, end_point, path, dijkstra_costs, all_ep=all_end_points)
if dilatation_erosion:
# Dilate extensions
cn_.Dilate(extension.sites, dijkstra_costs)
......@@ -618,7 +618,7 @@ def NutriMorph(data_path: str,
else:
features_df.to_csv(f"{name_dir}\\{name_file}.csv")
#
elapsed_time = tm_.gmtime(tm_.time() - start_time)
print(f"\nElapsed Time={tm_.strftime('%Hh %Mm %Ss', elapsed_time)}")
print(f"DONE: {tm_.strftime('%a, %b %d %Y @ %H:%M:%S')}\n")
......
......@@ -49,7 +49,8 @@ parameter3 : None
; then your parameter has the value string: 'None', and not None
[Input]
data_path : .\\data\\DIO_6H_6_1.70bis_2.2_3.tif
data_path : \\path_to_tif_imgs_or_directories
#.\\data\\DIO_6H_6_1.70bis_2.2_3.tif
; direct data path to the image
channel : G
; Can take the values R, G or B.
......@@ -61,10 +62,10 @@ save_images : \\path_where_to_save_MIP_and_graphs
; if None, no saving. Otherwise, path where to save images (MIP & graphs)
save_csv : \\path_where_to_save_features_csv
; where to save the csv. if None, by default it is in the .tif directory
dilatation_erosion : False
dilatation_erosion : True
; Choose whether to perform erosion/dilation on the extensions during the connexion process.
; For the moment, better results are achieved without it, but doing dilatation_erosion is theoretically more rigorous
statistical_analysis : True
; Better results are achieved with it, and doing dilatation_erosion is theoretically more rigorous
statistical_analysis : False
[Somas]
soma_low_c : 0.15
......
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