Commit 3447ca2a authored by Andrei Roibu's avatar Andrei Roibu
Browse files

added new scaling based on uk biobank stats

parent e37a0fe0
......@@ -90,8 +90,6 @@ class Solver():
self.loss_function = loss_function
self.MSE = MSELoss()
# self.loss_function = loss_function
self.model_name = model_name
self.labels = labels
self.number_epochs = number_epochs
......
......@@ -406,11 +406,14 @@ def _scale_input(volume, scaling_factors):
scaled_volume (np.array): Scaled volume
"""
with open(scaling_factors, 'rb') as input_file:
min_value, max_value, _, _ = pickle.load(input_file)
# with open(scaling_factors, 'rb') as input_file:
# min_value, max_value, _, _ = pickle.load(input_file)
# Steve Scaling
min_value, max_value, _, _ = [0.0, 0.2, 0.0, 10.0]
# min_value, max_value, _, _ = [0.0, 0.2, 0.0, 10.0]
# Andrei Scaling
min_value, max_value, _, _ = [-0.0539, 0.0969, -12.094, 14.6319]
# Eliminating outliers
volume[volume > max_value] = max_value
......@@ -419,8 +422,7 @@ def _scale_input(volume, scaling_factors):
# Normalization to [0, 1]
# scaled_volume = np.divide(np.subtract(volume, min_value), np.subtract(max_value, min_value))
# 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))))
scaled_volume = np.add(-1.0, np.multiply(2.0, np.divide(np.subtract(volume, min_value), np.subtract(max_value, min_value))))
return scaled_volume
......@@ -463,17 +465,19 @@ def _rescale_output(volume, scaling_factors):
rescaled_volume (np.array): Rescaled volume
"""
with open(scaling_factors, 'rb') as input_file:
_, _, min_value, max_value = pickle.load(input_file)
# with open(scaling_factors, 'rb') as input_file:
# _, _, min_value, max_value = pickle.load(input_file)
# Steve Scaling
_, _, min_value, max_value = [0.0, 0.2, 0.0, 10.0]
# _, _, min_value, max_value = [0.0, 0.2, 0.0, 10.0]
# Andrei Scaling
_, _, min_value, max_value = [-0.0539, 0.0969, -12.094, 14.6319]
# Normalization to [0, 1]
# rescaled_volume = np.add(np.multiply(volume, np.subtract(max_value, min_value)), min_value)
# 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)
rescaled_volume = np.add(np.multiply(np.divide(np.add(volume, 1), 2), np.subtract(max_value, min_value)), min_value)
return rescaled_volume
......
......@@ -486,12 +486,14 @@ class DataMapper(data.Dataset):
scaled_volume (np.array): Scaled volume
"""
with open(self.scaling_factors, 'rb') as input_file:
min_input, max_input, min_target, max_target = pickle.load(
input_file)
# with open(self.scaling_factors, 'rb') as input_file:
# min_input, max_input, min_target, max_target = pickle.load(input_file)
# Steve Scaling
min_input, max_input, min_target, max_target = [0.0, 0.2, 0.0, 10.0]
# # Steve Scaling
# min_input, max_input, min_target, max_target = [0.0, 0.2, 0.0, 10.0]
# Andrei Scaling
min_input, max_input, min_target, max_target = [-0.0539, 0.0969, -12.094, 14.6319]
if target_flag == False:
min_value = min_input
......@@ -501,15 +503,14 @@ class DataMapper(data.Dataset):
max_value = max_target
# Set all negative elements to 0
volume[volume < 0] = 0.0
# volume[volume < 0] = 0.0
# Eliminating outliers
volume[volume > max_value] = max_value
volume[volume < min_value] = min_value
# Normalization to [0, 1]
scaled_volume = np.divide(np.subtract(
volume, min_value), np.subtract(max_value, min_value))
scaled_volume = np.divide(np.subtract(volume, min_value), np.subtract(max_value, min_value))
# 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))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment