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
db5226f5
Commit
db5226f5
authored
Aug 14, 2020
by
Andrei Roibu
Browse files
added minus one flag
parent
507756d2
Changes
6
Hide whitespace changes
Inline
Side-by-side
settings.ini
View file @
db5226f5
...
...
@@ -9,8 +9,8 @@ crop_flag = True
[TRAINING]
experiment_name
=
"VA2-1"
pre_trained_path
=
"saved_models/VA2-1.pth.tar"
training_batch_size
=
5
validation_batch_size
=
5
training_batch_size
=
3
validation_batch_size
=
3
use_pre_trained
=
False
learning_rate
=
1e-5
optimizer_beta
=
(0.9, 0.999)
...
...
@@ -18,9 +18,10 @@ optimizer_epsilon = 1e-8
optimizer_weigth_decay
=
1e-5
number_of_epochs
=
10
loss_log_period
=
50
learning_rate_scheduler_step_size
=
5
learning_rate_scheduler_step_size
=
6
learning_rate_scheduler_gamma
=
1e-1
use_last_checkpoint
=
False
adam_w_flag
=
False
[NETWORK]
kernel_heigth
=
3
...
...
@@ -34,6 +35,7 @@ dropout = 0
pool_kernel_size
=
3
pool_stride
=
2
up_mode
=
"upconv"
final_activation
=
'tanh'
number_of_classes
=
1
number_of_transformer_blocks
=
6
custom_weight_reset_flag
=
False
...
...
settings_evaluation.ini
View file @
db5226f5
...
...
@@ -9,15 +9,16 @@ rsfmri_mean_mask_path = "utils/mean_dr_stage2.nii.gz"
dmri_mean_mask_path
=
"utils/mean_tractsNormSummed_downsampled.nii.gz"
mean_mask_path
=
"utils/mean_dr_stage2.nii.gz"
regression_factors
=
"datasets/regression_weights.pkl"
mean_regression_flag
=
Fals
e
mean_regression_all_flag
=
Fals
e
mean_subtraction_flag
=
Tru
e
mean_regression_flag
=
Tru
e
mean_regression_all_flag
=
Tru
e
mean_subtraction_flag
=
Fals
e
scale_volumes_flag
=
True
normalize_flag
=
True
negative_flag
=
True
normalize_flag
=
False
minus_one_scaling_flag
=
True
negative_flag
=
False
outlier_flag
=
True
shrinkage_flag
=
False
hard_shrinkage_flag
=
False
crop_flag
=
Fals
e
crop_flag
=
Tru
e
device
=
0
exit_on_error
=
True
\ No newline at end of file
utils/data_evaluation_utils.py
View file @
db5226f5
...
...
@@ -43,6 +43,7 @@ def evaluate_mapping(trained_model_path,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
...
...
@@ -70,6 +71,7 @@ def evaluate_mapping(trained_model_path,
mean_subtraction_flag (bool): Flag indicating if the targets should be de-meaned by subtraction using the mean_mask_path
scale_volumes_flag (bool): Flag indicating if the volumes should be scaled.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag (bool): Flag signaling if the volume should be scaled to [-1,1] if True
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -142,6 +144,7 @@ def evaluate_mapping(trained_model_path,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
...
...
@@ -212,6 +215,7 @@ def _generate_volume_map(file_path,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
...
...
@@ -237,6 +241,7 @@ def _generate_volume_map(file_path,
mean_subtraction_flag (bool): Flag indicating if the targets should be de-meaned by subtraction using the mean_mask_path
scale_volumes_flag (bool): Flag indicating if the volumes should be scaled.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag (bool): Flag signaling if the volume should be scaled to [-1,1] if True
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -253,16 +258,16 @@ def _generate_volume_map(file_path,
if
mean_regression_flag
==
True
:
if
mean_regression_all_flag
==
True
:
volume
=
_regress_input
(
volume
,
subject
,
dmri_mean_mask_path
,
regression_factors
,
crop_flag
)
scaling_parameters
=
[
-
0.0
539
,
0.
0969
,
-
12.094
,
14.6319
]
scaling_parameters
=
[
-
0.0
626
,
0.
1146
,
-
14.18
,
16.9475
]
else
:
scaling_parameters
=
[
0.0
,
0.2
,
-
1
2.094
,
14.6319
]
scaling_parameters
=
[
0.0
,
0.2
,
-
1
4.18
,
16.9475
]
elif
mean_subtraction_flag
==
True
:
scaling_parameters
=
[
0.0
,
0.2
,
0.0
,
10.0
]
print
(
'volume range:'
,
np
.
min
(
volume
),
np
.
max
(
volume
))
if
scale_volumes_flag
==
True
:
volume
=
_scale_input
(
volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
)
volume
=
_scale_input
(
volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
)
if
len
(
volume
.
shape
)
==
5
:
volume
=
volume
...
...
@@ -280,7 +285,7 @@ def _generate_volume_map(file_path,
print
(
'output range:'
,
np
.
min
(
output
),
np
.
max
(
output
))
output
=
_rescale_output
(
output
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
shrinkage_flag
,
hard_shrinkage_flag
)
output
=
_rescale_output
(
output
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
shrinkage_flag
,
hard_shrinkage_flag
)
print
(
'output rescaled:'
,
np
.
min
(
output
),
np
.
max
(
output
))
...
...
@@ -323,7 +328,7 @@ def _generate_volume_map(file_path,
return
predicted_complete_volume
,
predicted_volume
,
header
,
xform
def
_scale_input
(
volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
):
def
_scale_input
(
volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
):
"""Input Scaling
This function reads the scaling factors from the saved file and then scales the data.
...
...
@@ -332,6 +337,7 @@ def _scale_input(volume, scaling_parameters, normalize_flag, negative_flag, outl
volume (np.array): Numpy array representing the un-scalled volume.
scaling_parameters (list): List of scaling parameters.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag (bool): Flag signaling if the volume should be scaled to [-1,1] if True
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -364,10 +370,11 @@ def _scale_input(volume, scaling_parameters, normalize_flag, negative_flag, outl
if
normalize_flag
==
True
:
# Normalization to [0, 1]
scaled_volume
=
np
.
divide
(
np
.
subtract
(
volume
,
min_value
),
np
.
subtract
(
max_value
,
min_value
))
el
s
e
:
el
if
minus_one_scaling_flag
==
Tru
e
:
# Scaling between [-1, 1]
scaled_volume
=
np
.
add
(
-
1.0
,
np
.
multiply
(
2.0
,
np
.
divide
(
np
.
subtract
(
volume
,
min_value
),
np
.
subtract
(
max_value
,
min_value
))))
# Else, no scaling occus, but the other flags can still hold true if the scaling flag is true!
return
scaled_volume
...
...
@@ -401,7 +408,7 @@ def _regress_input(volume, subject, dmri_mean_mask_path, regression_factors, cro
return
regressed_volume
def
_rescale_output
(
volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
shrinkage_flag
,
hard_shrinkage_flag
):
def
_rescale_output
(
volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
shrinkage_flag
,
hard_shrinkage_flag
):
"""Output Rescaling
This function reads the scaling factors from the saved file and then scales the data.
...
...
@@ -410,6 +417,7 @@ def _rescale_output(volume, scaling_parameters, normalize_flag, negative_flag, s
volume (np.array): Unscalled volume
scaling_parameters (list): List of scaling parameters.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag (bool): Flag signaling if the volume should be scaled to [-1,1] if True
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
hard_shrinkage_flag (bool): Flag indicating if hard shrinkage should be applied. If False, soft shrinkage is applied.
...
...
@@ -434,10 +442,11 @@ def _rescale_output(volume, scaling_parameters, normalize_flag, negative_flag, s
if
normalize_flag
==
True
:
# Normalization to [0, 1]
rescaled_volume
=
np
.
add
(
np
.
multiply
(
volume
,
np
.
subtract
(
max_value
,
min_value
)),
min_value
)
el
s
e
:
el
if
minus_one_scaling_flag
==
Tru
e
:
# Scaling between [-1, 1]
rescaled_volume
=
np
.
add
(
np
.
multiply
(
np
.
divide
(
np
.
add
(
volume
,
1
),
2
),
np
.
subtract
(
max_value
,
min_value
)),
min_value
)
# Else, no rescaling occus, but the other flags can still hold true if the scaling flag is true!
return
rescaled_volume
...
...
utils/hdf5_generator.py
View file @
db5226f5
...
...
@@ -79,7 +79,8 @@ def convert_hdf5(data_parameters, file_information):
rsfMRI_mean_mask_path
=
data_parameters
[
'rsfmri_mean_mask_path'
],
mean_subtraction_flag
=
data_parameters
[
'mean_subtraction_flag'
],
scale_volumes_flag
=
data_parameters
[
'scale_volumes_flag'
],
normalize_flag
=
data_parameters
[
'normalize_flag'
],
normalize_flag
=
data_parameters
[
'normalize_flag'
],
minus_one_scaling_flag
=
data_parameters
[
'minus_one_scaling_flag'
],
negative_flag
=
data_parameters
[
'negative_flag'
],
outlier_flag
=
data_parameters
[
'outlier_flag'
],
shrinkage_flag
=
data_parameters
[
'shrinkage_flag'
],
...
...
@@ -105,6 +106,7 @@ def convert_hdf5(data_parameters, file_information):
mean_subtraction_flag
=
data_parameters
[
'mean_subtraction_flag'
],
scale_volumes_flag
=
data_parameters
[
'scale_volumes_flag'
],
normalize_flag
=
data_parameters
[
'normalize_flag'
],
minus_one_scaling_flag
=
data_parameters
[
'minus_one_scaling_flag'
],
negative_flag
=
data_parameters
[
'negative_flag'
],
outlier_flag
=
data_parameters
[
'outlier_flag'
],
shrinkage_flag
=
data_parameters
[
'shrinkage_flag'
],
...
...
utils/hdf5_settings.ini
View file @
db5226f5
...
...
@@ -14,12 +14,13 @@ train_data_file = "dMRI/autoptx_preproc/tractsNormSummed.nii.gz"
train_output_targets
=
"fMRI/rfMRI_25.dr/dr_stage2.nii.gz"
rsfmri_mean_mask_path
=
"utils/mean_dr_stage2.nii.gz"
dmri_mean_mask_path
=
"utils/mean_tractsNormSummed_downsampled.nii.gz"
mean_regression_flag
=
Fals
e
mean_regression_all_flag
=
Fals
e
mean_subtraction_flag
=
Tru
e
mean_regression_flag
=
Tru
e
mean_regression_all_flag
=
Tru
e
mean_subtraction_flag
=
Fals
e
scale_volumes_flag
=
True
normalize_flag
=
True
negative_flag
=
True
normalize_flag
=
False
minus_one_scaling_flag
=
True
negative_flag
=
False
outlier_flag
=
True
shrinkage_flag
=
False
hard_shrinkage_flag
=
False
...
...
utils/preprocessor.py
View file @
db5226f5
...
...
@@ -273,7 +273,7 @@ def weight_calculator(data_directory, subject, train_inputs, train_targets, rsfM
def
load_datasets
(
subjects
,
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
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
crop_flag
):
""" Dataset loader and pre-processor
...
...
@@ -292,6 +292,7 @@ def load_datasets(subjects, data_directory, input_file, output_target, mean_regr
mean_subtraction_flag (bool): Flag indicating if the targets should be de-meaned by subtraction using the mean_mask_path
scale_volumes_flag (bool): Flag indicating if the volumes should be scaled.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -307,22 +308,23 @@ def load_datasets(subjects, data_directory, input_file, output_target, mean_regr
input_volumes
,
target_volumes
=
[],
[]
len_subjects
=
len
(
subjects
)
for
index
,
subject
in
enumerate
(
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
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
crop_flag
)
input_volumes
.
append
(
input_volume
)
target_volumes
.
append
(
target_volume
)
print
(
"#"
,
end
=
''
,
flush
=
True
)
print
(
"100%"
,
flush
=
True
)
print
(
"
\r
Processed {:.3f}%"
.
format
(
index
/
len_subjects
*
100.0
),
end
=
''
)
return
input_volumes
,
target_volume
s
return
input_volumes
,
target_volume
def
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
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
crop_flag
):
""" Subject loader and pre-processor
...
...
@@ -341,6 +343,7 @@ def load_and_preprocess(subject, data_directory, input_file, output_target, mean
mean_subtraction_flag (bool): Flag indicating if the targets should be de-meaned by subtraction using the mean_mask_path
scale_volumes_flag (bool): Flag indicating if the volumes should be scaled.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -353,7 +356,7 @@ def load_and_preprocess(subject, data_directory, input_file, output_target, mean
"""
input_volume
,
target_volume
=
load_data
(
subject
,
data_directory
,
input_file
,
output_target
,
crop_flag
)
input_volume
,
target_volume
=
preprocess
(
input_volume
,
target_volume
,
subject
,
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
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
crop_flag
)
return
input_volume
,
target_volume
...
...
@@ -391,7 +394,7 @@ def load_data(subject, data_directory, input_file, output_target, crop_flag=Fals
def
preprocess
(
input_volume
,
target_volume
,
subject
,
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
,
dMRI_mean_mask_path
,
rsfMRI_mean_mask_path
,
mean_subtraction_flag
,
scale_volumes_flag
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
crop_flag
):
"""Conducts pre-processing based on arguments
...
...
@@ -409,6 +412,7 @@ def preprocess(input_volume, target_volume, subject, mean_regression_flag, mean_
mean_subtraction_flag (bool): Flag indicating if the targets should be de-meaned by subtraction using the mean_mask_path
scale_volumes_flag (bool): Flag indicating if the volumes should be scaled.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
minus_one_scaling_flag
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -426,12 +430,12 @@ def preprocess(input_volume, target_volume, subject, mean_regression_flag, mean_
input_volume
=
linear_regress_mean
(
input_volume
,
subject
,
regression_weights_path
,
crop_flag
,
target_flag
=
False
,
dMRI_mean_mask_path
=
dMRI_mean_mask_path
)
target_volume
=
linear_regress_mean
(
target_volume
,
subject
,
regression_weights_path
,
crop_flag
,
target_flag
=
True
,
rsfMRI_mean_mask_path
=
rsfMRI_mean_mask_path
)
# Set scaling parameters to Andrei Scaling
scaling_parameters
=
[
-
0.0
539
,
0.
0969
,
-
12.094
,
14.6319
]
scaling_parameters
=
[
-
0.0
626
,
0.
1146
,
-
14.18
,
16.9475
]
else
:
# Regress only targets, leave inputs as they are
target_volume
=
linear_regress_mean
(
target_volume
,
subject
,
regression_weights_path
,
crop_flag
,
target_flag
=
True
,
rsfMRI_mean_mask_path
=
rsfMRI_mean_mask_path
)
# Set scaling parameters to Mixed Scaling
scaling_parameters
=
[
0.0
,
0.2
,
-
1
2.094
,
14.6319
]
scaling_parameters
=
[
0.0
,
0.2
,
-
1
4.18
,
16.9475
]
elif
mean_subtraction_flag
==
True
:
# Subtract the mean from targets, leave inputs as they are
target_volume
=
subtract_mean
(
target_volume
,
crop_flag
,
rsfMRI_mean_mask_path
)
...
...
@@ -441,8 +445,8 @@ def preprocess(input_volume, target_volume, subject, mean_regression_flag, mean_
pass
if
scale_volumes_flag
==
True
:
input_volume
=
volume_scaling
(
input_volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
=
False
)
target_volume
=
volume_scaling
(
target_volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
=
True
)
input_volume
=
volume_scaling
(
input_volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
=
False
)
target_volume
=
volume_scaling
(
target_volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
=
True
)
return
input_volume
,
target_volume
...
...
@@ -506,7 +510,7 @@ def subtract_mean(volume, crop_flag, rsfMRI_mean_mask_path):
return
volume
def
volume_scaling
(
volume
,
scaling_parameters
,
normalize_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
):
def
volume_scaling
(
volume
,
scaling_parameters
,
normalize_flag
,
minus_one_scaling_flag
,
negative_flag
,
outlier_flag
,
shrinkage_flag
,
hard_shrinkage_flag
,
target_flag
):
""" Volume Scaling Function
This function applies various scaling operations to the volumes, based on their nature and the employed scaling strategy.
...
...
@@ -515,7 +519,8 @@ def volume_scaling(volume, scaling_parameters, normalize_flag, negative_flag, ou
volume (np.array): Numpy array representing the un-scalled volume.
scaling_parameters (list): List of scaling parameters.
target_flag (bool): Flag signaling if the file is a target or an input.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True) or scaled to [-1,1] if False.
normalize_flag (bool): Flag signaling if the volume should be normalized ([0,1] if True).
minus_one_scaling_flag (bool): Flag signaling if the volume should be scaled to [-1,1] if True
negative_flag (bool): Flag indicating if all the negative values should be 0-ed.
outlier_flag (bool): Flag indicating if outliers should be set to the min/max values.
shrinkage_flag (bool): Flag indicating if shrinkage should be applied.
...
...
@@ -559,9 +564,10 @@ def volume_scaling(volume, scaling_parameters, normalize_flag, negative_flag, ou
if
normalize_flag
==
True
:
# Normalization to [0, 1]
volume
=
np
.
divide
(
np
.
subtract
(
volume
,
min_value
),
np
.
subtract
(
max_value
,
min_value
))
el
s
e
:
el
if
minus_one_scaling_flag
==
Tru
e
:
# Scaling between [-1, 1]
volume
=
np
.
add
(
-
1.0
,
np
.
multiply
(
2.0
,
np
.
divide
(
np
.
subtract
(
volume
,
min_value
),
np
.
subtract
(
max_value
,
min_value
))))
# Else, no scaling occus, but the other flags can still hold true if the scaling flag is true!
return
volume
...
...
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