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
2d2cd6eb
Commit
2d2cd6eb
authored
Jul 29, 2020
by
Andrei Roibu
Browse files
bug fixes
parent
5e5d88cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
run.py
View file @
2d2cd6eb
...
...
@@ -45,7 +45,6 @@ from utils.settings import Settings
import
utils.data_evaluation_utils
as
evaluations
from
utils.data_logging_utils
import
LogWriter
from
utils.common_utils
import
create_folder
from
utils.preprocessor
import
data_preparation
,
update_shuffling_flag
# Set the default floating point tensor type to FloatTensor
...
...
utils/hdf5_generator.py
View file @
2d2cd6eb
...
...
@@ -16,10 +16,10 @@ Usage:
import
os
import
h5py
import
numpy
as
np
import
utils.
data_utils
as
data_utils
import
utils.
preprocessor
as
preprocessor
from
utils.
settings
import
Settings
from
utils.
common_utils
import
create_folder
import
data_utils
as
data_utils
import
preprocessor
as
preprocessor
from
settings
import
Settings
from
common_utils
import
create_folder
def
convert_hdf5
(
data_parameters
,
file_information
):
...
...
@@ -125,6 +125,12 @@ def write_hdf5(input_volumes, target_volumes, file_information, mode):
mode (str): String indicating the type of data observed
"""
if
os
.
path
.
exists
(
file_information
[
mode
][
'input'
]):
os
.
remove
(
file_information
[
mode
][
'input'
])
if
os
.
path
.
exists
(
file_information
[
mode
][
'target'
]):
os
.
remove
(
file_information
[
mode
][
'target'
])
with
h5py
.
File
(
file_information
[
mode
][
'input'
],
'w'
)
as
data_handle
:
data_handle
.
create_dataset
(
'input'
,
data
=
input_volumes
)
...
...
@@ -141,11 +147,11 @@ if __name__ == "__main__":
create_folder
(
data_parameters
[
'data_folder_name'
])
file_information
=
{
'train'
:
{
"input"
:
os
.
path
.
join
(
data_parameters
[
'data_
directory
'
],
data_parameters
[
'input_data_train'
]),
"target"
:
os
.
path
.
join
(
data_parameters
[
'data_
directory
'
],
data_parameters
[
'target_data_train'
]),
'train'
:
{
"input"
:
os
.
path
.
join
(
data_parameters
[
'data_
folder_name
'
],
data_parameters
[
'input_data_train'
]),
"target"
:
os
.
path
.
join
(
data_parameters
[
'data_
folder_name
'
],
data_parameters
[
'target_data_train'
]),
},
'validation'
:
{
"input"
:
os
.
path
.
join
(
data_parameters
[
'data_
directory
'
],
data_parameters
[
'input_data_validation'
]),
"target"
:
os
.
path
.
join
(
data_parameters
[
'data_
directory
'
],
data_parameters
[
'target_data_validation'
]),
'validation'
:
{
"input"
:
os
.
path
.
join
(
data_parameters
[
'data_
folder_name
'
],
data_parameters
[
'input_data_validation'
]),
"target"
:
os
.
path
.
join
(
data_parameters
[
'data_
folder_name
'
],
data_parameters
[
'target_data_validation'
]),
}
}
...
...
utils/preprocessor.py
View file @
2d2cd6eb
...
...
@@ -20,7 +20,7 @@ import pandas as pd
from
fsl.data.image
import
Image
from
fsl.utils.image.resample
import
resampleToPixdims
from
sklearn.model_selection
import
train_test_split
from
utils.
common_utils
import
create_folder
from
common_utils
import
create_folder
def
directory_reader
(
folder_location
,
subject_number
=
None
,
write_txt
=
False
):
...
...
@@ -307,7 +307,7 @@ def load_datasets(subjects, data_directory, input_file, output_target, mean_regr
for
index
,
subject
in
enumerate
(
subjects
):
print
(
'-->Subject: {}/{}'
.
format
(
index
,
len
(
subjects
)))
print
(
'-->Subject: {}/{}'
.
format
(
index
+
1
,
len
(
subjects
)))
input_volume
,
target_volume
=
load_and_preprocess
(
subject
,
data_directory
,
input_file
,
output_target
,
mean_regression_flag
,
mean_regression_all_flag
,
regression_weights_path
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
negative_flag
,
...
...
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