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
12ed746d
Commit
12ed746d
authored
Apr 06, 2020
by
Andrei-Claudiu Roibu
🖥
Browse files
added function to stop shuffling data once done
parent
6f01a19e
Changes
2
Hide whitespace changes
Inline
Side-by-side
run.py
View file @
12ed746d
...
...
@@ -39,7 +39,7 @@ import torch.utils.data as data
from
solver
import
Solver
from
BrainMapperUNet
import
BrainMapperUNet
from
utils.data_utils
import
get_datasets
,
data_test_train_validation_split
from
utils.data_utils
import
get_datasets
,
data_test_train_validation_split
,
update_shuffling_flag
import
utils.data_evaluation_utils
as
evaluations
from
utils.data_logging_utils
import
LogWriter
...
...
@@ -133,7 +133,7 @@ def train(data_parameters, training_parameters, network_parameters, misc_paramet
)
if
training_parameters
[
'use_pre_trained'
]:
BrainMapperModel
=
torch
.
load
(
training_parameters
[
'pre_trained_path'
])
BrainMapperModel
=
torch
.
load
(
trai
k
ning_parameters
[
'pre_trained_path'
])
else
:
BrainMapperModel
=
BrainMapperUNet
(
network_parameters
)
...
...
@@ -355,7 +355,7 @@ if __name__ == '__main__':
if
data_shuffling_flag
==
True
:
# Here we shuffle the data!
data_test_train_validation_split
(
data_parameters
[
'data_directory'
],
data_parameters
[
'train_percentage'
],
data_parameters
[
'validation_percentage'
])
update_shuffling_flag
(
'settings.ini'
)
# TODO: This might also be a very good point to add cross-validation later
else
:
...
...
utils/data_utils.py
View file @
12ed746d
...
...
@@ -21,6 +21,7 @@ import torch
import
torch.utils.data
as
data
import
nibabel
as
nb
import
random
import
configparser
def
directory_reader
(
folder_location
,
write_txt
=
False
):
"""Produces a list of of data-tags which are accessible
...
...
@@ -75,7 +76,19 @@ def data_test_train_validation_split(folder_location, train_percentage, validati
np
.
savetxt
(
'validation.txt'
,
validation
)
def
update_shuffling_flag
(
file_name
):
pass
""" Update shuffling flag
Changes shuffling flag in settings to False once data has been shuffled
Args:
file_name (str): The settings file name
"""
config
=
configparser
.
ConfigParser
()
config
.
read
(
file_name
)
config
.
set
(
'DATA'
,
'data_split_flag'
,
'False'
)
with
open
(
file_name
,
'w'
)
as
configfile
:
config
.
write
(
configfile
)
def
tract_sum_generator
(
folder_path
):
"""Sums the tracts of different dMRI files
...
...
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