Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hyunji
/
A-Performance-Evaluation-of-CNN-for-Brain-Age-Prediction-Using-Structural-MRI-Data
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Hyunji
2021-12-20 04:26:37 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
525807982e32fe8fd640c16b9ce902afaf0af580
52580798
1 parent
745d7f92
dataset
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
2DCNN/src/common/dataset.py
2DCNN/src/common/dataset.py
0 → 100644
View file @
5258079
import
logging
from
box
import
Box
from
torchvision.transforms
import
transforms
from
src.common.data.ukbb_brain_age
import
UKBBBrainAGE
from
src.common.data_utils
import
frame_drop
logger
=
logging
.
getLogger
()
def
get_dataset
(
name
,
test_csv
=
None
,
train_csv
=
None
,
valid_csv
=
None
,
root_path
=
None
,
train_num_sample
=-
1
,
frame_keep_style
=
"random"
,
frame_keep_fraction
=
1.0
,
frame_dim
=
1
,
impute
=
False
,
**
kwargs
):
""" return dataset """
if
name
==
"brain_age"
:
# Transformations to remove frames
frame_drop_transform
=
lambda
x
:
frame_drop
(
x
,
frame_keep_style
=
frame_keep_style
,
frame_keep_fraction
=
frame_keep_fraction
,
frame_dim
=
frame_dim
,
impute
=
impute
)
# Transformation to add noise to frames
transform
=
transforms
.
Compose
([
frame_drop_transform
])
train_data
=
UKBBBrainAGE
(
root
=
root_path
,
metadatafile
=
train_csv
,
num_sample
=
train_num_sample
,
transform
=
transform
)
test_data
=
UKBBBrainAGE
(
root
=
root_path
,
metadatafile
=
test_csv
,
transform
=
transform
)
valid_data
=
UKBBBrainAGE
(
root
=
root_path
,
metadatafile
=
valid_csv
if
valid_csv
else
test_csv
,
transform
=
transform
)
return
Box
({
"train"
:
train_data
,
"test"
:
test_data
,
"valid"
:
valid_data
}),
{}
logger
.
error
(
f
"Invalid data name {name} specified"
)
raise
Exception
(
f
"Invalid data name {name} specified"
)
Please
register
or
login
to post a comment