Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NutriMorph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DEBREUVE Eric
NutriMorph
Commits
d3df13f8
Commit
d3df13f8
authored
4 years ago
by
NADAL Morgane
Browse files
Options
Downloads
Patches
Plain Diff
solved soma_volume/convex_hull_volume issue
parent
62d76ae3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
brick/processing/best_fit_ellipsoid.py
+9
-9
9 additions, 9 deletions
brick/processing/best_fit_ellipsoid.py
brick/processing/graph_feat_extraction.py
+11
-11
11 additions, 11 deletions
brick/processing/graph_feat_extraction.py
brick/processing/input.py
+2
-2
2 additions, 2 deletions
brick/processing/input.py
with
22 additions
and
22 deletions
brick/processing/best_fit_ellipsoid.py
+
9
−
9
View file @
d3df13f8
...
...
@@ -142,19 +142,19 @@ def polyToParams3D(ellipsoid_coef: array_t, printMe: bool = False) -> tuple:
def
GetConvexHull3D
(
soma_sites
:
site_h
)
->
tuple
:
#
three_
D
=
np_
.
stack
((
soma_sites
[
0
],
soma_sites
[
1
],
soma_sites
[
2
]),
axis
=-
1
)
hull_
three_
D
=
ConvexHull
(
three_
D
)
volume_
of_CH
=
hull_
three_
D
.
volume
soma_3
D
=
np_
.
stack
((
soma_sites
[
0
],
soma_sites
[
1
],
soma_sites
[
2
]),
axis
=-
1
)
hull_
3
D
=
ConvexHull
(
soma_3
D
)
volume_
hull
=
hull_
3
D
.
volume
len_hull
=
len
(
hull_
three_
D
.
vertices
)
len_hull
=
len
(
hull_
3
D
.
vertices
)
hull
=
np_
.
zeros
((
len_hull
,
3
))
for
i
in
range
(
len
(
hull_
three_
D
.
vertices
)):
hull
[
i
]
=
three_
D
[
hull_
three_
D
.
vertices
[
i
]]
for
i
in
range
(
len
(
hull_
3
D
.
vertices
)):
hull
[
i
]
=
soma_3
D
[
hull_
3
D
.
vertices
[
i
]]
convex_hull
=
np_
.
transpose
(
hull
)
return
convex_hull
,
volume_
of_CH
return
convex_hull
,
volume_
hull
def
FindBestFittingEllipsoid3D
(
soma
:
soma_t
)
->
tuple
:
...
...
@@ -164,7 +164,7 @@ def FindBestFittingEllipsoid3D(soma: soma_t) -> tuple:
"""
# get convex hull
convex_hull
=
GetConvexHull3D
(
soma
.
sites
)
[
0
]
convex_hull
,
volume_hull
=
GetConvexHull3D
(
soma
.
sites
)
# fit ellipsoid on the convex hull
# # get ellipsoid polynomial coefficients
...
...
@@ -172,4 +172,4 @@ def FindBestFittingEllipsoid3D(soma: soma_t) -> tuple:
# # get ellipsoid 3D parameters
center
,
axes
,
orientation
,
spherical_coor
=
polyToParams3D
(
ellipsoid_coef
,
False
)
return
ellipsoid_coef
,
center
,
axes
,
orientation
,
spherical_coor
return
ellipsoid_coef
,
center
,
axes
,
orientation
,
spherical_coor
,
convex_hull
,
volume_hull
This diff is collapsed.
Click to expand it.
brick/processing/graph_feat_extraction.py
+
11
−
11
View file @
d3df13f8
...
...
@@ -280,19 +280,9 @@ def ExtractFeaturesInDF(name_file, somas, size_voxel_in_micron: list, bins_lengt
for
soma
in
somas
:
# -- Soma features
# Volume of the soma
volume_pixel_micron
=
round
(
np_
.
prod
(
size_voxel_in_micron
),
4
)
soma
.
volume_soma_micron
=
volume_pixel_micron
*
len
(
soma
.
sites
[
0
])
# Calculates volume of soma's convex hull
volume_convex_hull
=
volume_pixel_micron
*
bf_
.
GetConvexHull3D
(
soma
.
sites
)[
1
]
# 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
=
soma
.
volume_soma_micron
/
volume_convex_hull
# Axes of the best fitting ellipsoid
# a > b > c
_
,
_
,
soma
.
axes_ellipsoid
,
_
,
spherical_coor
=
bf_
.
FindBestFittingEllipsoid3D
(
soma
)
_
,
_
,
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
]
...
...
@@ -302,6 +292,16 @@ def ExtractFeaturesInDF(name_file, somas, size_voxel_in_micron: list, bins_lengt
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 soma
soma
.
volume_soma_micron
=
in_
.
ToMicron
(
len
(
soma
.
sites
[
0
]),
size_voxel_in_micron
,
dimension
=
(
0
,
1
,
2
),
decimals
=
3
)
# Calculates volume of soma's convex hull
volume_convex_hull
=
in_
.
ToMicron
(
volume_convex_hull
,
size_voxel_in_micron
,
dimension
=
(
0
,
1
,
2
))
# 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
=
soma
.
volume_soma_micron
/
volume_convex_hull
# TODO Solve issue V_soma > V_convexHull
# -- Extension features
# Graph features
...
...
This diff is collapsed.
Click to expand it.
brick/processing/input.py
+
2
−
2
View file @
d3df13f8
...
...
@@ -147,7 +147,7 @@ def FindVoxelDimensionInMicron(data_path: str, size_voxel_in_micron: list = None
raise
ValueError
(
'
/!\ Unable to find the voxel dimensions in micron. Specify it in the parameters.
'
)
def
ToPixel
(
micron
:
float
,
voxel_size_micron
:
array_
t
,
dimension
:
tuple
=
(
0
,),
decimals
:
int
=
None
)
->
int
:
def
ToPixel
(
micron
:
float
,
voxel_size_micron
:
lis
t
,
dimension
:
tuple
=
(
0
,),
decimals
:
int
=
None
)
->
int
:
'''
Dimension correspond to the axis (X,Y,Z) = (0,1,2). Can be used for distance, area and volumes.
'''
...
...
@@ -155,7 +155,7 @@ def ToPixel(micron: float, voxel_size_micron: array_t, dimension: tuple = (0,),
return
round
(
micron
/
(
mt_
.
prod
(
voxel_size_micron
[
axis
]
for
axis
in
dimension
)),
decimals
)
def
ToMicron
(
pixel
:
float
,
voxel_size_micron
:
array_
t
,
dimension
:
tuple
=
(
0
,),
decimals
:
int
=
None
)
->
float
:
def
ToMicron
(
pixel
:
float
,
voxel_size_micron
:
lis
t
,
dimension
:
tuple
=
(
0
,),
decimals
:
int
=
None
)
->
float
:
'''
Dimension correspond to the axis (X,Y,Z) = (0,1,2). Can be used for distance, area and volumes.
'''
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment