Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mu-map
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tamino Huxohl
mu-map
Commits
12533d9d
Commit
12533d9d
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
add polar maps and script to create video of attenuation maps
parent
c12e5f00
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mu_map/scripts/create_video.py
+67
-0
67 additions, 0 deletions
mu_map/scripts/create_video.py
res/polar_maps.png
+0
-0
0 additions, 0 deletions
res/polar_maps.png
with
67 additions
and
0 deletions
mu_map/scripts/create_video.py
0 → 100644
+
67
−
0
View file @
12533d9d
import
os
import
cv2
as
cv
import
numpy
as
np
import
torch
from
mu_map.dataset.default
import
MuMapDataset
from
mu_map.dataset.transform
import
PadCropTranform
,
SequenceTransform
from
mu_map.models.unet
import
UNet
from
mu_map.util
import
to_grayscale
,
COLOR_WHITE
from
mu_map.random_search.cgan
import
load_params
from
mu_map.vis.slices
import
join_images
torch
.
set_grad_enabled
(
False
)
random_search_iter_dir
=
"
cgan_random_search/001
"
params
=
load_params
(
os
.
path
.
join
(
random_search_iter_dir
,
"
params.json
"
))
print
(
params
[
"
normalization
"
])
print
(
params
[
"
generator_features
"
])
dataset
=
MuMapDataset
(
"
data/second/
"
,
transform_normalization
=
SequenceTransform
(
[
params
[
"
normalization
"
],
PadCropTranform
(
dim
=
3
,
size
=
32
)]
),
split_name
=
"
test
"
,
scatter_correction
=
False
,
)
recon
,
mu_map_ct
=
dataset
[
1
]
mu_map_ct
=
mu_map_ct
.
squeeze
().
numpy
()
device
=
torch
.
device
(
"
cpu
"
)
model
=
UNet
(
features
=
params
[
"
generator_features
"
])
model
.
load_state_dict
(
torch
.
load
(
os
.
path
.
join
(
random_search_iter_dir
,
"
snapshots/val_min_generator.pth
"
),
map_location
=
device
)
)
mu_map_dl
=
model
(
recon
.
unsqueeze
(
dim
=
0
)).
squeeze
().
numpy
()
mu_map_dl
=
np
.
clip
(
mu_map_dl
,
0
,
mu_map_ct
.
max
())
volumes
=
[
mu_map_ct
,
mu_map_dl
,
np
.
abs
(
mu_map_dl
-
mu_map_ct
)]
min_val
=
0
max_val
=
max
(
mu_map_ct
.
max
(),
mu_map_dl
.
max
())
print
(
mu_map_ct
.
max
(),
mu_map_dl
.
max
())
fourcc
=
cv
.
VideoWriter_fourcc
(
*
"
mp4v
"
)
frame_size
=
(
512
,
3
*
512
+
2
*
10
)
print
(
f
"
Frame size
{
frame_size
}
"
)
# video_writer = cv.VideoWriter("mu_map_comparison.mp4", fourcc, 25, frame_size, isColor=False)
video_writer
=
cv
.
VideoWriter
(
"
mu_map_comparison.mp4
"
,
cv
.
VideoWriter_fourcc
(
*
"
mp4v
"
),
25
,
frame_size
[::
-
1
],
isColor
=
False
)
for
i
in
range
(
mu_map_ct
.
shape
[
0
]):
images
=
map
(
lambda
volume
:
volume
[
i
],
volumes
)
images
=
map
(
lambda
img
:
to_grayscale
(
img
,
min_val
=
min_val
,
max_val
=
max_val
),
images
)
images
=
map
(
lambda
img
:
cv
.
resize
(
img
,
(
512
,
512
)),
images
)
images
=
list
(
images
)
txt
=
f
"
{
str
(
i
)
:{
len
(
str
(
mu_map_ct
.
shape
[
0
]))
}}
/
{
mu_map_ct
.
shape
[
0
]
}
"
cv
.
putText
(
images
[
0
],
txt
,
(
0
,
30
),
cv
.
FONT_HERSHEY_SIMPLEX
,
1
,
255
,
3
)
image
=
join_images
(
images
)
for
i
in
range
(
5
):
video_writer
.
write
(
image
)
video_writer
.
release
()
This diff is collapsed.
Click to expand it.
res/polar_maps.png
0 → 100644
+
0
−
0
View file @
12533d9d
1.13 MiB
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