Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
2d546cd3
Commit
2d546cd3
authored
1 year ago
by
Felipe Delestro Matos
Browse files
Options
Downloads
Patches
Plain Diff
WIP
parent
497a6dad
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qim3d/gui/local_thickness.py
+33
-13
33 additions, 13 deletions
qim3d/gui/local_thickness.py
with
33 additions
and
13 deletions
qim3d/gui/local_thickness.py
+
33
−
13
View file @
2d546cd3
...
@@ -71,13 +71,13 @@ class Interface:
...
@@ -71,13 +71,13 @@ class Interface:
session
.
zpos
=
zpos
session
.
zpos
=
zpos
return
session
return
session
def
launch
(
self
,
**
kwargs
):
def
launch
(
self
,
img
=
None
):
# Show header
# Show header
if
self
.
show_header
:
if
self
.
show_header
:
internal_tools
.
gradio_header
(
self
.
title
,
self
.
port
)
internal_tools
.
gradio_header
(
self
.
title
,
self
.
port
)
# Create gradio interfaces
# Create gradio interfaces
interface
=
self
.
create_interface
()
interface
=
self
.
create_interface
(
img
=
img
)
# Set gradio verbose level
# Set gradio verbose level
if
self
.
verbose
:
if
self
.
verbose
:
...
@@ -89,10 +89,11 @@ class Interface:
...
@@ -89,10 +89,11 @@ class Interface:
quiet
=
quiet
,
quiet
=
quiet
,
height
=
self
.
height
,
height
=
self
.
height
,
width
=
self
.
width
,
width
=
self
.
width
,
**
kwargs
,
show_tips
=
False
,
)
)
def
create_interface
(
self
):
def
create_interface
(
self
,
img
=
None
):
print
(
img
)
with
gr
.
Blocks
(
css
=
self
.
css_path
)
as
gradio_interface
:
with
gr
.
Blocks
(
css
=
self
.
css_path
)
as
gradio_interface
:
gr
.
Markdown
(
gr
.
Markdown
(
"
# 3D Local thickness
\n
Interface for _Fast local thickness in 3D and 2D_ (https://github.com/vedranaa/local-thickness)
"
"
# 3D Local thickness
\n
Interface for _Fast local thickness in 3D and 2D_ (https://github.com/vedranaa/local-thickness)
"
...
@@ -276,6 +277,10 @@ class Session:
...
@@ -276,6 +277,10 @@ class Session:
self
.
vol_binary
=
None
self
.
vol_binary
=
None
self
.
vol_thickness
=
None
self
.
vol_thickness
=
None
self
.
zpos
=
0
self
.
zpos
=
0
self
.
vmin
=
None
self
.
vmax
=
None
self
.
vmin_lt
=
None
self
.
vmax_lt
=
None
class
Pipeline
:
class
Pipeline
:
...
@@ -289,16 +294,17 @@ class Pipeline:
...
@@ -289,16 +294,17 @@ class Pipeline:
if
session
.
dark_objects
:
if
session
.
dark_objects
:
session
.
vol
=
np
.
invert
(
session
.
vol
)
session
.
vol
=
np
.
invert
(
session
.
vol
)
if
session
.
flip_z
:
# Get min and max values for visualization
session
.
vol
=
np
.
flip
(
session
.
vol
,
axis
=
0
)
session
.
vmin
=
np
.
min
(
session
.
vol
)
session
.
vmax
=
np
.
max
(
session
.
vol
)
return
session
return
session
def
show_slice
(
self
,
vol
,
z_idx
,
cmap
=
"
viridis
"
):
def
show_slice
(
self
,
vol
,
z_idx
,
vmin
=
None
,
vmax
=
None
,
cmap
=
"
viridis
"
):
plt
.
close
()
plt
.
close
()
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
self
.
figsize
,
self
.
figsize
))
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
self
.
figsize
,
self
.
figsize
))
ax
.
imshow
(
vol
[
z_idx
],
interpolation
=
"
nearest
"
,
cmap
=
cmap
)
ax
.
imshow
(
vol
[
z_idx
],
interpolation
=
"
nearest
"
,
cmap
=
cmap
,
vmin
=
vmin
,
vmax
=
vmax
)
# Adjustments
# Adjustments
ax
.
axis
(
"
off
"
)
ax
.
axis
(
"
off
"
)
...
@@ -308,8 +314,14 @@ class Pipeline:
...
@@ -308,8 +314,14 @@ class Pipeline:
def
input_viz
(
self
,
session
):
def
input_viz
(
self
,
session
):
# Generate input visualization
# Generate input visualization
z_idx
=
int
(
session
.
zpos
*
session
.
vol
.
shape
[
0
])
z_idx
=
int
(
session
.
zpos
*
(
session
.
vol
.
shape
[
0
]
-
1
))
fig
=
self
.
show_slice
(
vol
=
session
.
vol
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_originals
)
fig
=
self
.
show_slice
(
vol
=
session
.
vol
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_originals
,
vmin
=
session
.
vmin
,
vmax
=
session
.
vmax
,
)
return
fig
return
fig
def
make_binary
(
self
,
session
):
def
make_binary
(
self
,
session
):
...
@@ -321,7 +333,7 @@ class Pipeline:
...
@@ -321,7 +333,7 @@ class Pipeline:
def
binary_viz
(
self
,
session
):
def
binary_viz
(
self
,
session
):
# Generate input visualization
# Generate input visualization
z_idx
=
int
(
session
.
zpos
*
session
.
vol_binary
.
shape
[
0
])
z_idx
=
int
(
session
.
zpos
*
(
session
.
vol_binary
.
shape
[
0
]
-
1
)
)
fig
=
self
.
show_slice
(
fig
=
self
.
show_slice
(
vol
=
session
.
vol_binary
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_originals
vol
=
session
.
vol_binary
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_originals
)
)
...
@@ -330,13 +342,21 @@ class Pipeline:
...
@@ -330,13 +342,21 @@ class Pipeline:
def
compute_localthickness
(
self
,
session
):
def
compute_localthickness
(
self
,
session
):
session
.
vol_thickness
=
lt
.
local_thickness
(
session
.
vol_binary
,
session
.
lt_scale
)
session
.
vol_thickness
=
lt
.
local_thickness
(
session
.
vol_binary
,
session
.
lt_scale
)
# Valus for visualization
session
.
vmin_lt
=
np
.
min
(
session
.
vol_thickness
)
session
.
vmax_lt
=
np
.
max
(
session
.
vol_thickness
)
return
session
return
session
def
output_viz
(
self
,
session
):
def
output_viz
(
self
,
session
):
# Generate input visualization
# Generate input visualization
z_idx
=
int
(
session
.
zpos
*
session
.
vol_thickness
.
shape
[
0
])
z_idx
=
int
(
session
.
zpos
*
(
session
.
vol_thickness
.
shape
[
0
]
-
1
)
)
fig
=
self
.
show_slice
(
fig
=
self
.
show_slice
(
vol
=
session
.
vol_thickness
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_lt
vol
=
session
.
vol_thickness
,
z_idx
=
z_idx
,
cmap
=
session
.
cmap_lt
,
vmin
=
session
.
vmin_lt
,
vmax
=
session
.
vmax_lt
,
)
)
return
fig
return
fig
...
...
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