def apply_preprocessing_sim(batch): X, Y, xyzs = batch pp.add_norm(X) np.random.seed(0) pp.add_noise(X, c=0.05) # Add background gradient c = 0.3 angle = -np.pi / 2 x, y = np.meshgrid(np.arange(0, X[0].shape[1]), np.arange(0, X[0].shape[2]), indexing='ij') n = [np.cos(angle), np.sin(angle), 1] z = -(n[0] * x + n[1] * y) z -= z.mean() z /= np.ptp(z) for x in X: x += z[None, :, :, None] * c * np.ptp(x) X = list(reversed(X)) Y = [Y[-1][..., i] for i in range(2)] return X, Y, xyzs
def apply_preprocessing(batch): X, Y, xyzs = batch pp.add_norm(X) np.random.seed(0) pp.add_noise(X, c=0.05) Y = [Y[-1][..., i] for i in range(2)] return X, Y, xyzs
def apply_preprocessing_sim(batch): X, Y, xyzs = batch pp.add_norm(X) np.random.seed(0) pp.add_noise(X, c=0.05) X = list(reversed(X)) # Pick slices X[0] = X[0][..., 10:20] # CO X[1] = X[1][..., 8:18] # Xe Y = [Y[-1][...,i] for i in range(2)] return X, Y, xyzs
def apply_preprocessing(self, batch): Xs, Ys, xyz = batch pp.add_norm(Xs, per_layer=True) pp.add_gradient(Xs, c=0.3) pp.add_noise(Xs, c=0.1, randomize_amplitude=False) pp.rand_shift_xy(Xs, c=0.02) pp.add_cutout(Xs, n_holes=5) Ys = Ys[0] Ys = [Ys[:,:,:,i] for i in range(Ys.shape[-1])] Xs, Ys = pp.add_rotation_reflection(Xs, Ys, rotations=True, reflections=True, multiple=2, crop=(128, 128)) Xs = list(reversed(Xs)) # Only for CO-Xe tip combination return Xs, Ys