Exemple #1
0
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
Exemple #2
0
def apply_preprocessing_exp(X, real_dim):

    # Pick slices
    X[0] = X[0][..., 0:10] # CO
    X[1] = X[1][..., 4:14] # Xe

    X = pp.interpolate_and_crop(X, real_dim)
    pp.add_norm(X)
    
    return X
Exemple #3
0
def apply_preprocessing_bcb(X, real_dim):
    X[0] = X[0][..., 0:12]  # CO
    X[1] = X[1][..., 4:16]  # Xe
    X = pp.interpolate_and_crop(X, real_dim)
    X_ = []
    for z in range(X[0].shape[-1] - 10 + 1):
        X_.append([x[..., z:z + 10] for x in X])
    X = [np.concatenate([x[i] for x in X_], axis=0) for i in range(len(X))]
    pp.add_norm(X)
    return X
Exemple #4
0
def apply_preprocessing_exp(X, real_dim):

    # Pick slices
    X[0] = X[0][..., :10]  # CO
    X[1] = X[1][..., :10]  # Xe

    X = pp.interpolate_and_crop(X, real_dim)
    pp.add_norm(X)
    X = [x[:, :80, 8:80] for x in X]

    return X
Exemple #5
0
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
Exemple #6
0
def apply_preprocessing_exp(X, real_dim):

    # Pick slices
    X[0] = X[0][..., 0:10]  # CO
    X[1] = X[1][..., 4:14]  # Xe

    X = pp.interpolate_and_crop(X, real_dim)
    pp.add_norm(X)

    # Flip, rotate and shift Xe data
    X[1] = X[1][:, ::-1]
    X[1] = rotate(X[1], angle=-12, axes=(2, 1), reshape=False, mode='reflect')
    X[1] = shift(X[1], shift=(0, -5, 1, 0), mode='reflect')
    X = [x[:, 2:90] for x in X]

    return X
Exemple #7
0
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
Exemple #8
0
    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
Exemple #9
0
def apply_preprocessing_bcb(X, real_dim):
    X[0] = X[0][..., :10]  # Pick slices
    X = pp.interpolate_and_crop(X, real_dim)
    pp.add_norm(X)
    return X