Skip to content

Commit 7902fb5

Browse files
authored
BUG: Same bias field across modalities. (#831)
1 parent 0ed0653 commit 7902fb5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ants/deeplearn/data_augmentation.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def data_augmentation(input_image_list,
193193

194194

195195
simulated_local_image_list = list()
196+
bias_field_array = None
196197
for j in range(number_of_modalities):
197198

198199
if verbose:
@@ -262,14 +263,17 @@ def data_augmentation(input_image_list,
262263
if verbose:
263264
print(" Adding simulated bias field.")
264265

265-
log_field = ants.simulate_bias_field(image,
266-
number_of_points=10,
267-
sd_bias_field=sd_simulated_bias_field,
268-
number_of_fitting_levels=2,
269-
mesh_size=10)
270-
log_field = log_field.iMath("Normalize")
271-
field_array = np.power(np.exp(log_field.numpy()), random.sample((2, 3, 4), 1)[0])
272-
image = image * ants.from_numpy_like(field_array, image)
266+
267+
# Keep the bias field the same across modalities
268+
if j == 0:
269+
log_field = ants.simulate_bias_field(image,
270+
number_of_points=10,
271+
sd_bias_field=sd_simulated_bias_field,
272+
number_of_fitting_levels=2,
273+
mesh_size=10)
274+
log_field = log_field.iMath("Normalize")
275+
bias_field_array = np.power(np.exp(log_field.numpy()), random.sample((2, 3, 4), 1)[0])
276+
image = image * ants.from_numpy_like(bias_field_array, image)
273277

274278
# Histogram intensity warping
275279

0 commit comments

Comments
 (0)