Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Christopher Randolph Rhodes
model_server
Commits
c4884883
Commit
c4884883
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Focus 3d patches now brought into workflow parameters
parent
22210950
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extensions/chaeo/products.py
+15
-9
15 additions, 9 deletions
extensions/chaeo/products.py
extensions/chaeo/workflows.py
+12
-16
12 additions, 16 deletions
extensions/chaeo/workflows.py
with
27 additions
and
25 deletions
extensions/chaeo/products.py
+
15
−
9
View file @
c4884883
...
@@ -13,6 +13,16 @@ from extensions.chaeo.annotators import draw_box_on_patch
...
@@ -13,6 +13,16 @@ from extensions.chaeo.annotators import draw_box_on_patch
from
model_server.accessors
import
GenericImageDataAccessor
from
model_server.accessors
import
GenericImageDataAccessor
from
model_server.process
import
pad
,
rescale
,
resample_to_8bit
from
model_server.process
import
pad
,
rescale
,
resample_to_8bit
def
_focus_metrics
():
return
{
'
max_intensity
'
:
lambda
x
:
np
.
max
(
x
),
'
stdev
'
:
lambda
x
:
np
.
std
(
x
),
'
max_sobel
'
:
lambda
x
:
np
.
max
(
sobel
(
x
)),
'
rms_sobel
'
:
lambda
x
:
sqrt
(
np
.
mean
(
sobel
(
x
)
**
2
)),
'
entropy
'
:
lambda
x
:
shannon_entropy
(
x
),
'
moment
'
:
lambda
x
:
moment
(
x
.
flatten
(),
moment
=
2
),
}
def
_write_patch_to_file
(
where
,
fname
,
data
):
def
_write_patch_to_file
(
where
,
fname
,
data
):
ext
=
fname
.
split
(
'
.
'
)[
-
1
].
upper
()
ext
=
fname
.
split
(
'
.
'
)[
-
1
].
upper
()
where
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
where
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
...
@@ -41,6 +51,7 @@ def export_patches_from_zstack(
...
@@ -41,6 +51,7 @@ def export_patches_from_zstack(
pad_to
:
int
=
256
,
pad_to
:
int
=
256
,
make_3d
:
bool
=
False
,
make_3d
:
bool
=
False
,
prefix
=
'
patch
'
,
prefix
=
'
patch
'
,
focus_metric
:
str
=
None
,
**
kwargs
**
kwargs
):
):
assert
stack
.
chroma
==
1
,
'
Expecting monochromatic image data
'
assert
stack
.
chroma
==
1
,
'
Expecting monochromatic image data
'
...
@@ -65,7 +76,9 @@ def export_patches_from_zstack(
...
@@ -65,7 +76,9 @@ def export_patches_from_zstack(
patch
=
patch3d
patch
=
patch3d
# make a 2d patch, find optimal z-position determined by focus_metric function
# make a 2d patch, find optimal z-position determined by focus_metric function
elif
foc
:
=
kwargs
.
get
(
'
focus_metric
'
):
elif
focus_metric
is
not
None
:
foc
=
_focus_metrics
()[
focus_metric
]
sp_sl
=
np
.
s_
[
y0
:
y1
,
x0
:
x1
,
:,
:]
sp_sl
=
np
.
s_
[
y0
:
y1
,
x0
:
x1
,
:,
:]
subpatch
=
patch3d
[
sp_sl
]
subpatch
=
patch3d
[
sp_sl
]
...
@@ -125,14 +138,7 @@ def export_3d_patches_with_focus_metrics(
...
@@ -125,14 +138,7 @@ def export_3d_patches_with_focus_metrics(
def
get_zstack_focus_metrics
(
zs
):
def
get_zstack_focus_metrics
(
zs
):
nz
=
zs
.
shape
[
3
]
nz
=
zs
.
shape
[
3
]
me
=
{
me
=
_focus_metrics
()
'
max_intensity
'
:
lambda
x
:
np
.
max
(
x
),
'
stdev
'
:
lambda
x
:
np
.
std
(
x
),
'
max_sobel
'
:
lambda
x
:
np
.
max
(
sobel
(
x
)),
'
rms_sobel
'
:
lambda
x
:
sqrt
(
np
.
mean
(
sobel
(
x
)
**
2
)),
'
entropy
'
:
lambda
x
:
shannon_entropy
(
x
),
'
moment
'
:
lambda
x
:
moment
(
x
.
flatten
(),
moment
=
2
),
}
dd
=
{}
dd
=
{}
for
zi
in
range
(
0
,
nz
):
for
zi
in
range
(
0
,
nz
):
spf
=
zs
[:,
:,
:,
zi
]
spf
=
zs
[:,
:,
:,
zi
]
...
...
This diff is collapsed.
Click to expand it.
extensions/chaeo/workflows.py
+
12
−
16
View file @
c4884883
...
@@ -60,33 +60,29 @@ def export_patches_from_multichannel_zstack(
...
@@ -60,33 +60,29 @@ def export_patches_from_multichannel_zstack(
zmask_acc
=
InMemoryDataAccessor
(
zmask
)
zmask_acc
=
InMemoryDataAccessor
(
zmask
)
ti
.
click
(
'
generate_zmasks
'
)
ti
.
click
(
'
generate_zmasks
'
)
# export patches
import
numpy
as
np
from
skimage.filters
import
gaussian
,
sobel
# def zs_projector(zs):
# sigma = 1.5
# blur = gaussian(sobel(zs), sigma)
# argmax = np.argmax(blur, axis=3, keepdims=True)
# return np.take_along_axis(zs, argmax, axis=3)
#
# def zs_annotate_best_focus(zs):
# pass
files
=
export_patches_from_zstack
(
files
=
export_patches_from_zstack
(
# Path(where_output) / '2d_patches',
Path
(
where_output
)
/
'
3d_patches
'
,
Path
(
where_output
)
/
'
3d_patches
'
,
stack
.
get_one_channel_data
(
patches_channel
),
stack
.
get_one_channel_data
(
patches_channel
),
zmask_meta
,
zmask_meta
,
prefix
=
fstem
,
prefix
=
fstem
,
# draw_bounding_box=True,
draw_bounding_box
=
False
,
draw_bounding_box
=
False
,
rescale_clip
=
0.0
,
rescale_clip
=
0.0
,
# projector=zs_projector,
make_3d
=
True
,
make_3d
=
True
,
)
)
ti
.
click
(
'
export_patches
'
)
ti
.
click
(
'
export_patches
'
)
files
=
export_patches_from_zstack
(
Path
(
where_output
)
/
'
2d_patches
'
,
stack
.
get_one_channel_data
(
patches_channel
),
zmask_meta
,
prefix
=
fstem
,
draw_bounding_box
=
False
,
rescale_clip
=
0.0
,
make_3d
=
False
,
focus_metric
=
'
max_sobel
'
,
)
ti
.
click
(
'
export_patches
'
)
# export annotated zstack
# export annotated zstack
annotated
=
InMemoryDataAccessor
(
annotated
=
InMemoryDataAccessor
(
draw_boxes_on_3d_image
(
draw_boxes_on_3d_image
(
...
...
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