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
32eabd9b
Commit
32eabd9b
authored
2 years ago
by
Tamino Huxohl
Browse files
Options
Downloads
Patches
Plain Diff
add bland altman plot to perfusion evaluation
parent
c3db3b18
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mu_map/polar_map/eval_perfusion.py
+65
-0
65 additions, 0 deletions
mu_map/polar_map/eval_perfusion.py
with
65 additions
and
0 deletions
mu_map/polar_map/eval_perfusion.py
+
65
−
0
View file @
32eabd9b
from
typing
import
List
,
Optional
import
matplotlib
as
mlp
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
from
mu_map.polar_map.prepare
import
headers
from
mu_map.polar_map.prepare
import
headers
SIZE_DEFAULT
=
12
plt
.
rc
(
"
font
"
,
family
=
"
Arial
"
)
# controls default font
plt
.
rc
(
"
font
"
,
weight
=
"
normal
"
)
# controls default font
plt
.
rc
(
"
font
"
,
size
=
SIZE_DEFAULT
)
# controls default text sizes
plt
.
rc
(
"
axes
"
,
titlesize
=
16
)
# fontsize of the axes title
# COLORS=["#a6cee3", "#1f78b4", "#b2df8a"]
COLORS
=
[
"
#66c2a5
"
,
"
#fc8d62
"
,
"
#8da0cb
"
]
COLORS
=
COLORS
[::
-
1
]
def
bland_altman
(
data1
:
np
.
ndarray
,
data2
:
np
.
ndarray
,
ax
:
Optional
[
mlp
.
axes
.
Axes
]
=
None
):
ax
=
plt
.
subplot
()
if
ax
is
None
else
ax
mean
=
np
.
mean
([
data1
,
data2
],
axis
=
0
)
diff
=
data1
-
data2
# Difference between data1 and data2
md
=
np
.
mean
(
diff
)
# Mean of the difference
sd
=
np
.
std
(
diff
,
axis
=
0
)
# Standard deviation of the difference
ax
.
axhline
(
md
,
color
=
"
#fc8d59
"
,
linestyle
=
"
-
"
)
for
x
in
[
-
1.96
,
1.96
]:
ax
.
axhline
(
md
+
x
*
sd
,
color
=
"
black
"
,
linestyle
=
"
--
"
,
alpha
=
0.8
)
ax
.
scatter
(
mean
,
diff
,
color
=
"
#91bfdb
"
,
s
=
25
,
alpha
=
0.7
,
edgecolors
=
"
black
"
,
linewidths
=
0.3
)
ax
.
spines
[
"
left
"
].
set_visible
(
False
)
ax
.
spines
[
"
right
"
].
set_visible
(
False
)
ax
.
spines
[
"
top
"
].
set_visible
(
False
)
ax
.
grid
(
axis
=
"
both
"
,
alpha
=
0.5
,
linestyle
=
"
dotted
"
)
data
=
pd
.
read_csv
(
"
data/polar_maps/perfusion.csv
"
)
data
=
pd
.
read_csv
(
"
data/polar_maps/perfusion.csv
"
)
baseline
=
data
[
data
[
headers
.
ac
]
&
(
data
[
headers
.
type
]
==
"
symbia
"
)]
baseline
=
data
[
data
[
headers
.
ac
]
&
(
data
[
headers
.
type
]
==
"
symbia
"
)]
...
@@ -19,6 +56,34 @@ _correction_none = correction_none[keys_segments].values
...
@@ -19,6 +56,34 @@ _correction_none = correction_none[keys_segments].values
_correction_syn
=
correction_syn
[
keys_segments
].
values
_correction_syn
=
correction_syn
[
keys_segments
].
values
_correction_ct
=
correction_ct
[
keys_segments
].
values
_correction_ct
=
correction_ct
[
keys_segments
].
values
fig
,
axs
=
plt
.
subplots
(
1
,
2
,
figsize
=
(
12
,
6
))
bland_altman
(
_correction_none
.
flatten
(),
_correction_ct
.
flatten
(),
axs
[
0
])
bland_altman
(
_correction_syn
.
flatten
(),
_correction_ct
.
flatten
(),
axs
[
1
])
axs
[
0
].
set_title
(
"
No Attenuation Correction
"
)
axs
[
1
].
set_title
(
"
Synthetic Attenuation Correction
"
)
# fig, axs = plt.subplots(1, 3, figsize=(18, 6))
# bland_altman(_baseline.flatten(), _correction_none.flatten(), ax=axs[0])
# bland_altman(_baseline.flatten(), _correction_syn.flatten(), ax=axs[1])
# bland_altman(_baseline.flatten(), _correction_ct.flatten(), ax=axs[2])
def
normalize_axes
(
axes
:
List
[
mlp
.
axes
.
Axes
]):
x_min
=
min
(
map
(
lambda
ax
:
ax
.
get_xlim
()[
0
],
axes
))
x_max
=
max
(
map
(
lambda
ax
:
ax
.
get_xlim
()[
1
],
axes
))
y_min
=
min
(
map
(
lambda
ax
:
ax
.
get_ylim
()[
0
],
axes
))
y_max
=
max
(
map
(
lambda
ax
:
ax
.
get_ylim
()[
1
],
axes
))
for
ax
in
axs
:
ax
.
set_xlim
((
x_min
,
x_max
))
ax
.
set_ylim
((
y_min
,
y_max
))
normalize_axes
(
axs
)
# plt.hist(_correction_syn.flatten() - _correction_ct.flatten())
# plt.hist(_correction_none.flatten() - _correction_ct.flatten())
plt
.
show
()
exit
(
0
)
def
absolute_percent_error
(
prediction
:
np
.
ndarray
,
target
:
np
.
ndarray
)
->
float
:
def
absolute_percent_error
(
prediction
:
np
.
ndarray
,
target
:
np
.
ndarray
)
->
float
:
mean_p
=
prediction
.
mean
(
axis
=
0
)
mean_p
=
prediction
.
mean
(
axis
=
0
)
...
...
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