Mentions légales du service

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

solved bug: singular matrices in best fitting ellipsoid

parent 1e026ed9
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ def ls_ellipsoid(xx: array_t, yy: array_t, zz: array_t) -> array_t: # finds the
return (ellipsoid_coef)
except:
print("Singular matrix, cannot find the best fitting ellipsoid.")
print("WARNING: Singular matrix, cannot find the best fitting ellipsoid. The soma will probably be deleted in the resulting table. \n")
return (np_.zeros(9))
......@@ -179,7 +179,7 @@ def FindBestFittingEllipsoid3D(soma: soma_t) -> tuple:
# # get ellipsoid polynomial coefficients
ellipsoid_coef = ls_ellipsoid(convex_hull[0], convex_hull[1], convex_hull[2])
if ellipsoid_coef == (np_.zeros(9)):
if ellipsoid_coef.all() == 0:
return ellipsoid_coef, "NaN", "NaN", "NaN", "NaN", "NaN", "NaN"
else:
......
......@@ -293,22 +293,30 @@ def ExtractFeaturesInDF(name_file, somas, size_voxel_in_micron: list, bins_lengt
_, _, soma.axes_ellipsoid, _, spherical_coor,_, volume_convex_hull = bf_.FindBestFittingEllipsoid3D(soma)
# This ratios give info about the shape of the soma. ex: rather flat, rather patatoide, rather spherical...
Coef_axes_ellips_b__a = soma.axes_ellipsoid[0] / soma.axes_ellipsoid[2]
Coef_axes_ellips_c__a = soma.axes_ellipsoid[1] / soma.axes_ellipsoid[2]
# Spherical angles give the orientation of the somas in the 3D volume
spherical_angles_eva = (spherical_coor[0][1], spherical_coor[0][2])
spherical_angles_evb = (spherical_coor[1][1], spherical_coor[1][2])
# Volume of the in micron**3
soma.volume_soma_micron = in_.ToMicron(len(soma.sites[0]), size_voxel_in_micron, dimension=(0, 1, 2), decimals=2)
# Calculates volume of soma's convex hull in voxel volume
# Take into account anisotropy of the 3D space ( volume = x * y * z with z > x=y)
volume_convex_hull = volume_convex_hull * size_voxel_in_micron[2] / size_voxel_in_micron[0]
# Volume of the soma / Volume of its convex hull gives the info about the convexity of the soma
# If close to 0, the soma has a lot of invaginations, if close to 1, it is smooth and convex
Coef_V_soma__V_convex_hull = len(soma.sites[0]) / round(volume_convex_hull + 0.5)
if type(soma.axes_ellipsoid[0]) is str:
Coef_axes_ellips_b__a = None
Coef_axes_ellips_c__a = None
spherical_angles_eva = None
spherical_angles_evb = None
soma.volume_soma_micron = None
Coef_V_soma__V_convex_hull = None
else:
Coef_axes_ellips_b__a = soma.axes_ellipsoid[0] / soma.axes_ellipsoid[2]
Coef_axes_ellips_c__a = soma.axes_ellipsoid[1] / soma.axes_ellipsoid[2]
# Spherical angles give the orientation of the somas in the 3D volume
spherical_angles_eva = (spherical_coor[0][1], spherical_coor[0][2])
spherical_angles_evb = (spherical_coor[1][1], spherical_coor[1][2])
# Volume of the in micron**3
soma.volume_soma_micron = in_.ToMicron(len(soma.sites[0]), size_voxel_in_micron, dimension=(0, 1, 2), decimals=2)
# Calculates volume of soma's convex hull in voxel volume
# Take into account anisotropy of the 3D space ( volume = x * y * z with z > x=y)
volume_convex_hull = volume_convex_hull * size_voxel_in_micron[2] / size_voxel_in_micron[0]
# Volume of the soma / Volume of its convex hull gives the info about the convexity of the soma
# If close to 0, the soma has a lot of invaginations, if close to 1, it is smooth and convex
Coef_V_soma__V_convex_hull = len(soma.sites[0]) / round(volume_convex_hull + 0.5)
# -- Extension features
# Graph features
......
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