Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MALIS
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
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
radjou
MALIS
Merge requests
!3
Upload New File
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Upload New File
cordina-main-patch-60379
into
main
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
cordina
requested to merge
cordina-main-patch-60379
into
main
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
81733ef1
1 commit,
3 years ago
1 file
+
141
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Notebook_EDA.ipynb
0 → 100644
+
141
−
0
Options
%% Cell type:code id: tags:
```
python
!
pip
install
pydicom
import
matplotlib.pyplot
as
plt
import
pydicom
from
pydicom.data
import
get_testdata_file
import
numpy
as
np
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
seaborn
as
sns
from
pathlib
import
Path
import
os
import
json
import
glob
import
random
import
collections
import
cv2
import
pandas
as
pd
import
pydicom
from
pydicom.pixel_data_handlers.util
import
apply_voi_lut
from
tqdm.notebook
import
tqdm
import
os
import
glob
from
sklearn.model_selection
import
train_test_split
from
sklearn.metrics
import
roc_auc_score
,
accuracy_score
,
log_loss
from
scipy
import
ndimage
import
tensorflow
as
tf
from
tensorflow
import
keras
from
tensorflow.keras.utils
import
to_categorical
from
tensorflow.keras
import
layers
from
matplotlib
import
animation
,
rc
rc
(
'
animation
'
,
html
=
'
jshtml
'
)
```
%% Cell type:code id: tags:
```
python
path_data
=
"
/kaggle/input/rsna-miccai-brain-tumor-radiogenomic-classification/
"
train_df
=
pd
.
read_csv
(
path_data
+
"
train_labels.csv
"
)
def
load_dicom
(
path
):
dicom
=
pydicom
.
read_file
(
path
,
force
=
True
)
data
=
dicom
.
pixel_array
data
=
data
-
np
.
min
(
data
)
if
np
.
max
(
data
)
!=
0
:
data
=
data
/
np
.
max
(
data
)
data
=
(
data
*
255
).
astype
(
np
.
uint8
)
return
data
def
visualize_sample
(
brats21id
,
slice_i
,
mgmt_value
,
types
=
(
"
FLAIR
"
,
"
T1w
"
,
"
T1wCE
"
,
"
T2w
"
)
):
plt
.
figure
(
figsize
=
(
10
,
3
))
patient_path
=
os
.
path
.
join
(
path_data
+
"
train/
"
,
str
(
brats21id
).
zfill
(
5
),
)
for
i
,
t
in
enumerate
(
types
,
1
):
t_paths
=
sorted
(
glob
.
glob
(
os
.
path
.
join
(
patient_path
,
t
,
"
*
"
)),
key
=
lambda
x
:
int
(
x
[:
-
4
].
split
(
"
-
"
)[
-
1
]),
)
data
=
load_dicom
(
t_paths
[
int
(
len
(
t_paths
)
*
slice_i
)])
plt
.
subplot
(
1
,
4
,
i
)
plt
.
imshow
(
data
,
cmap
=
"
gray
"
)
plt
.
title
(
f
"
{
t
}
"
,
fontsize
=
10
)
plt
.
axis
(
"
off
"
)
plt
.
show
()
def
create_animation
(
ims
):
fig
=
plt
.
figure
(
figsize
=
(
5
,
5
))
plt
.
axis
(
'
off
'
)
im
=
plt
.
imshow
(
ims
[
0
],
cmap
=
"
gray
"
)
def
animate_func
(
i
):
im
.
set_array
(
ims
[
i
])
#return [im]
return
animation
.
FuncAnimation
(
fig
,
animate_func
,
frames
=
len
(
ims
),
interval
=
1000
//
4
)
def
load_dicom_line
(
path
):
t_paths
=
sorted
(
glob
.
glob
(
os
.
path
.
join
(
path
,
"
*
"
)),
key
=
lambda
x
:
int
(
x
[:
-
4
].
split
(
"
-
"
)[
-
1
]),
)
images
=
[]
for
filename
in
t_paths
:
data
=
load_dicom
(
filename
)
if
data
.
max
()
==
0
:
continue
images
.
append
(
data
)
return
images
def
create_animation
(
ims
):
fig
=
plt
.
figure
(
figsize
=
(
5
,
5
))
plt
.
axis
(
'
off
'
)
im
=
plt
.
imshow
(
ims
[
0
],
cmap
=
"
gray
"
)
def
animate_func
(
i
):
im
.
set_array
(
ims
[
i
])
#return [im]
return
animation
.
FuncAnimation
(
fig
,
animate_func
,
frames
=
len
(
ims
),
interval
=
1000
//
4
)
def
load_dicom_line
(
path
):
t_paths
=
sorted
(
glob
.
glob
(
os
.
path
.
join
(
path
,
"
*
"
)),
key
=
lambda
x
:
int
(
x
[:
-
4
].
split
(
"
-
"
)[
-
1
]),
)
images
=
[]
for
filename
in
t_paths
:
data
=
load_dicom
(
filename
)
if
data
.
max
()
==
0
:
continue
images
.
append
(
data
)
return
images
create_animation
(
load_dicom_line
(
"
../input/rsna-miccai-brain-tumor-radiogenomic-classification/train/00176/T2w
"
))
```
%% Cell type:code id: tags:
```
python
```
Loading