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
44e96ffb
Commit
44e96ffb
authored
4 years ago
by
NADAL Morgane
Browse files
Options
Downloads
Patches
Plain Diff
usable version of dilatation/erosion during connexion of extensions
parent
44c1e086
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
brick/component/connection.py
+8
-27
8 additions, 27 deletions
brick/component/connection.py
nutrimorph.py
+5
-5
5 additions, 5 deletions
nutrimorph.py
parameters.ini
+5
-4
5 additions, 4 deletions
parameters.ini
with
18 additions
and
36 deletions
brick/component/connection.py
+
8
−
27
View file @
44e96ffb
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
nutrimorph.py
+
5
−
5
View file @
44e96ffb
...
...
@@ -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
"
\n
Elapsed Time=
{
tm_
.
strftime
(
'
%Hh %Mm %Ss
'
,
elapsed_time
)
}
"
)
print
(
f
"
DONE:
{
tm_
.
strftime
(
'
%a, %b %d %Y @ %H
:
%
M
:
%
S
'
)
}
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
parameters.ini
+
5
−
4
View file @
44e96ffb
...
...
@@ -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
:
Fals
e
dilatation_erosion
:
Tru
e
; Choose whether to perform erosion/dilation on the extensions during the connexion process.
;
For the moment, b
etter results are achieved with
out
it,
but
doing dilatation_erosion is theoretically more rigorous
statistical_analysis
:
Tru
e
;
B
etter results are achieved with it,
and
doing dilatation_erosion is theoretically more rigorous
statistical_analysis
:
Fals
e
[Somas]
soma_low_c
:
0.15
...
...
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