Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sjromuel
Masterarbeit
Commits
d3661208
Commit
d3661208
authored
Nov 27, 2020
by
Robin
Browse files
d
parent
e4fa4640
Changes
3
Hide whitespace changes
Inline
Side-by-side
RobinNet/allModelsCreatePredNpys.py
View file @
d3661208
...
...
@@ -238,13 +238,13 @@ def main():
os
.
makedirs
(
npy_savepath
)
np
.
save
(
npy_savepath
+
"_pred3D"
,
y_pred3d
)
output_volume
=
np
.
squeeze
(
y_pred3d
)
output_volume
=
np
.
squeeze
(
X_test
)
output_nifty
=
nib
.
Nifti1Image
(
output_volume
,
np
.
eye
(
4
))
fname
=
npy_savepath
+
'_Scan.nii.gz'
nib
.
save
(
output_nifty
,
fname
)
output_label
=
np
.
argmax
(
output_volume
,
axis
=-
1
)
output_label
=
np
.
argmax
(
y_pred3d
,
axis
=-
1
)
output_label
=
output_label
.
astype
(
np
.
uint8
)
output_label_nifty
=
nib
.
Nifti1Image
(
output_label
,
np
.
eye
(
4
))
...
...
RobinNet/dice_gt_seg.py
View file @
d3661208
...
...
@@ -18,7 +18,7 @@ from nets.Unet import dice_loss
def
main
():
mr
=
Tru
e
mr
=
Fals
e
if
mr
:
file_path
=
"data/npy_thresh/"
gt_types
=
[
'ctseg'
,
'ctthresh'
,
'unetpred'
]
...
...
@@ -189,6 +189,10 @@ def main():
all3dhdds
.
append
(
hdd3d
)
except
:
pass
dice_Score16
.
append
(
np
.
mean
(
patient_dsc
))
print
(
"Dice Score for patient"
,
patientnumber
,
np
.
mean
(
patient_dsc
))
print
(
"All 3d-HDDs for"
,
gt_type
,
": "
,
all3dhdds
)
#print("Dice-Score mean: ", np.mean(dice_Score16))
#print("Dice-Score std: ", np.std(dice_Score16))
...
...
@@ -422,4 +426,4 @@ def show_loss_plot(slice, loss_list):
if
__name__
==
"__main__"
:
main
()
\ No newline at end of file
main
()
necro_to_nifty.py
0 → 100644
View file @
d3661208
import
numpy
as
np
import
os
import
nibabel
as
nib
from
os
import
listdir
from
os.path
import
isfile
,
join
import
SimpleITK
as
sitk
src_path
=
"../hueftdaten/"
folders
=
[
"T1/"
,
"T2/"
]
for
folder
in
folders
:
for
i
in
range
(
1
,
40
):
patient_folder
=
'P'
+
str
(
i
).
zfill
(
2
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
src_path
+
folder
,
patient_folder
)):
reader
=
sitk
.
ImageFileReader
()
for
f
in
listdir
(
os
.
path
.
join
(
src_path
,
patient_folder
)):
cur_file_path
=
join
(
src_path
,
patient_folder
,
f
)
print
(
f
)
if
isfile
(
cur_file_path
):
if
'.gipl'
in
f
:
# cur_file_path_dst = join(dst_path, f)
reader
.
SetFileName
(
cur_file_path
)
pimgs
=
reader
.
Execute
()
pimgs_array
=
sitk
.
GetArrayFromImage
(
pimgs
)
if
"seg"
in
cur_file_path
:
output_label
=
np
.
argmax
(
pimgs_array
,
axis
=-
1
)
output_label
=
output_label
.
astype
(
np
.
uint8
)
output_label_nifty
=
nib
.
Nifti1Image
(
output_label
,
np
.
eye
(
4
))
fname
=
cur_file_path
+
'.nii.gz'
nib
.
save
(
output_label_nifty
,
fname
)
elif
"necro"
in
cur_file_path
or
"kopf"
in
cur_file_path
:
output_volume
=
np
.
squeeze
(
pimgs_array
)
output_nifty
=
nib
.
Nifti1Image
(
output_volume
,
np
.
eye
(
4
))
fname
=
cur_file_path
+
'.nii.gz'
nib
.
save
(
output_nifty
,
fname
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment