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
Andrei-Claudiu Roibu
BrainMapper
Commits
5c60c7c3
Commit
5c60c7c3
authored
Apr 08, 2020
by
Andrei-Claudiu Roibu
🖥
Browse files
bug fixes - fixed split function txt file writer: added string format
parent
99df6b78
Changes
1
Hide whitespace changes
Inline
Side-by-side
utils/data_utils.py
View file @
5c60c7c3
...
...
@@ -19,7 +19,6 @@ import numpy as np
import
nibabel
as
nib
import
torch
import
torch.utils.data
as
data
import
nibabel
as
nb
import
random
import
configparser
...
...
@@ -71,9 +70,9 @@ def data_test_train_validation_split(folder_location, train_percentage, validati
train
,
validation
,
test
=
np
.
split
(
subDirectoryList
,
[
int
(
train_percentage
/
100
*
len
(
subDirectoryList
)),
int
((
train_percentage
+
validation_percentage
)
/
100
*
len
(
subDirectoryList
))])
np
.
savetxt
(
'train.txt'
,
train
)
np
.
savetxt
(
'test.txt'
,
test
)
np
.
savetxt
(
'validation.txt'
,
validation
)
np
.
savetxt
(
'train.txt'
,
train
,
fmt
=
'%s'
)
np
.
savetxt
(
'test.txt'
,
test
,
fmt
=
'%s'
)
np
.
savetxt
(
'validation.txt'
,
validation
,
fmt
=
'%s'
)
def
update_shuffling_flag
(
file_name
):
""" Update shuffling flag
...
...
@@ -298,7 +297,7 @@ def load(file_path, orientation):
header (class): 'nibabel.nifti1.Nifti1Header' class object, containing image metadata
"""
nifty_volume
,
label_map
=
nb
.
load
(
file_path
[
0
]),
nb
.
load
(
file_path
[
1
])
nifty_volume
,
label_map
=
n
i
b
.
load
(
file_path
[
0
]),
n
i
b
.
load
(
file_path
[
1
])
volume
,
label_map
=
nifty_volume
.
get_fdata
(),
label_map
.
ged_fdata
()
# Do we need min-max normalization here? Will need to check when debuggint and testing
...
...
@@ -372,7 +371,7 @@ def load_and_preprocess_evaluation(file_path, orientation, min_max=True):
ValueError: "Orientation value is invalid. It must be either >>coronal<<, >>axial<< or >>sagital<< "
"""
nifty_volume
=
nb
.
load
(
file_path
[
0
])
nifty_volume
=
n
i
b
.
load
(
file_path
[
0
])
volume
=
nifty_volume
.
get_fdata
()
header
=
nifty_volume
.
header
...
...
@@ -397,5 +396,5 @@ def load_and_preprocess_evaluation(file_path, orientation, min_max=True):
if
__name__
==
"__main__"
:
folder_location
=
'
/well/win-biobank/projects/imaging/data/data3/subjectsAll/
'
tract_sum_generator
(
folder_location
)
folder_location
=
"..
/well/win-biobank/projects/imaging/data/data3/subjectsAll/
"
data_test_train_validation_split
(
folder_location
,
90
,
5
)
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