Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
MPBA Radiomics
RADLER
Commits
1573ec4a
Commit
1573ec4a
authored
Mar 11, 2020
by
Alessia Marcolini
Browse files
Handle subdatasets with property decorators
parent
6f3c869c
Changes
1
Hide whitespace changes
Inline
Side-by-side
dataset.py
View file @
1573ec4a
...
...
@@ -95,17 +95,17 @@ class NumpyCSVDataset(Dataset):
# filter the clinical file in order to keep files that are really on disk
clinical
=
clinical
.
loc
[
clinical
[
'filename'
].
isin
(
available_files
)]
self
.
_filenames
_full
=
clinical
[
'filename'
].
values
self
.
_patients
_full
=
clinical
[
'patient'
].
values
self
.
_labels
_full
=
clinical
[
label_col
].
values
self
.
_filenames
=
clinical
[
'filename'
].
values
self
.
_patients
=
clinical
[
'patient'
].
values
self
.
_labels
=
clinical
[
label_col
].
values
self
.
indices
=
np
.
arange
(
len
(
self
.
_filenames
_full
))
self
.
indices
=
np
.
arange
(
len
(
self
.
_filenames
))
def
__getitem__
(
self
,
idx
):
label
=
self
.
_labels
_full
[
self
.
indices
[
idx
]]
filename
=
self
.
_filenames
_full
[
self
.
indices
[
idx
]]
patient
=
self
.
_patients
_full
[
self
.
indices
[
idx
]]
data_file
=
self
.
data_dir
/
self
.
_filenames
_full
[
self
.
indices
[
idx
]]
label
=
self
.
_labels
[
self
.
indices
[
idx
]]
filename
=
self
.
_filenames
[
self
.
indices
[
idx
]]
patient
=
self
.
_patients
[
self
.
indices
[
idx
]]
data_file
=
self
.
data_dir
/
self
.
_filenames
[
self
.
indices
[
idx
]]
data
=
np
.
load
(
data_file
)
data
=
self
.
transforms
(
data
,
self
.
mode
,
self
.
size
)
...
...
@@ -118,21 +118,24 @@ class NumpyCSVDataset(Dataset):
}
return
output
def
get_labels
(
self
):
return
self
.
_labels_full
[
self
.
indices
]
@
property
def
labels
(
self
):
return
self
.
_labels
[
self
.
indices
]
def
get_files
(
self
):
return
self
.
_filenames_full
[
self
.
indices
]
@
property
def
filenames
(
self
):
return
self
.
_filenames
[
self
.
indices
]
def
get_patients
(
self
):
return
self
.
_patients_full
[
self
.
indices
]
@
property
def
patients
(
self
):
return
self
.
_patients
[
self
.
indices
]
def
__len__
(
self
):
return
len
(
self
.
indices
)
def
__shuffle__
(
self
):
idx_permut
=
np
.
random
.
permutation
(
self
.
__len__
())
self
.
_filenames
_full
=
self
.
_filenames
_full
[
idx_permut
]
self
.
_labels
_full
=
self
.
_labels
_full
[
idx_permut
]
self
.
_patients
_full
=
self
.
_patients
_full
[
idx_permut
]
self
.
_filenames
=
self
.
_filenames
[
idx_permut
]
self
.
_labels
=
self
.
_labels
[
idx_permut
]
self
.
_patients
=
self
.
_patients
[
idx_permut
]
self
.
indices
=
self
.
indices
[
idx_permut
]
Write
Preview
Markdown
is supported
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