Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
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
Swain Lab
aliby
alibylite
Commits
cde198c5
Commit
cde198c5
authored
2 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
clean(fun/cell): simplify code
parent
3b9c9eda
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
extraction/core/functions/cell.py
+7
-13
7 additions, 13 deletions
extraction/core/functions/cell.py
tests/aliby/test_post_processing.py
+3
-0
3 additions, 0 deletions
tests/aliby/test_post_processing.py
tests/aliby/test_tiler.py
+1
-1
1 addition, 1 deletion
tests/aliby/test_tiler.py
with
11 additions
and
14 deletions
extraction/core/functions/cell.py
+
7
−
13
View file @
cde198c5
...
...
@@ -20,14 +20,12 @@ from scipy import ndimage
from
sklearn.cluster
import
KMeans
def
area
(
cell_mask
,
trap_image
=
None
):
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
def
area
(
cell_mask
):
return
np
.
sum
(
cell_mask
,
dtype
=
int
)
def
eccentricity
(
cell_mask
,
trap_image
=
None
):
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
def
eccentricity
(
cell_mask
):
min_ax
,
maj_ax
=
min_maj_approximation
(
cell_mask
)
return
np
.
sqrt
(
maj_ax
**
2
-
min_ax
**
2
)
/
maj_ax
...
...
@@ -101,20 +99,18 @@ def k2_top_median(cell_mask, trap_image):
return
k2_top_median
def
volume
(
cell_mask
,
trap_image
=
None
):
def
volume
(
cell_mask
):
"""
Volume from a cell mask, assuming an ellipse.
Assumes the mask is the median plane of the ellipsoid.
Assumes rotational symmetry around the major axis.
"""
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
min_ax
,
maj_ax
=
min_maj_approximation
(
cell_mask
,
trap_image
)
min_ax
,
maj_ax
=
min_maj_approximation
(
cell_mask
)
return
(
4
*
math
.
pi
*
min_ax
**
2
*
maj_ax
)
/
3
def
conical_volume
(
cell_mask
,
trap_image
=
None
):
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
def
conical_volume
(
cell_mask
):
padded
=
np
.
pad
(
cell_mask
,
1
,
mode
=
"
constant
"
,
constant_values
=
0
)
nearest_neighbor
=
(
...
...
@@ -123,15 +119,14 @@ def conical_volume(cell_mask, trap_image=None):
return
4
*
(
nearest_neighbor
.
sum
())
def
spherical_volume
(
cell_mask
,
trap_image
=
None
):
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
def
spherical_volume
(
cell_mask
):
area
=
cell_mask
.
sum
()
r
=
np
.
sqrt
(
area
/
np
.
pi
)
return
(
4
*
np
.
pi
*
r
**
3
)
/
3
def
min_maj_approximation
(
cell_mask
,
trap_image
=
None
):
def
min_maj_approximation
(
cell_mask
):
"""
Length approximation of minor and major axes of an ellipse from mask.
...
...
@@ -139,7 +134,6 @@ def min_maj_approximation(cell_mask, trap_image=None):
:param trap_image:
:return:
"""
assert
trap_image
is
None
,
"
Passed image to mask-only function
"
padded
=
np
.
pad
(
cell_mask
,
1
,
mode
=
"
constant
"
,
constant_values
=
0
)
nn
=
ndimage
.
morphology
.
distance_transform_edt
(
padded
==
1
)
*
padded
...
...
This diff is collapsed.
Click to expand it.
tests/aliby/test_post_processing.py
+
3
−
0
View file @
cde198c5
...
...
@@ -15,6 +15,9 @@ from aliby.post_processing import (
)
@pytest.mark.skip
(
reason
=
"
No longer usable, post_processing unused inside aliby. Kept temporarily
"
)
class
VolumeEstimation
(
unittest
.
TestCase
):
def
test_conical
(
self
):
radius
=
np
.
random
.
choice
(
range
(
60
,
100
))
...
...
This diff is collapsed.
Click to expand it.
tests/aliby/test_tiler.py
+
1
−
1
View file @
cde198c5
import
argparse
from
aliby.io.
omero
import
ImageLocal
from
aliby.io.
image
import
ImageLocal
# from aliby.experiment import ExperimentLocal
from
aliby.tile.tiler
import
Tiler
,
TilerParameters
...
...
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