Exemple #1
0
def test_spike():
    """ Test if a convolution with a delta spike is equal to the kernel
    saved in the lookup table."""

    # create kernel
    D33 = 1.0
    D44 = 0.04
    t = 1
    num_orientations = 5
    k = EnhancementKernel(D33,
                          D44,
                          t,
                          orientations=num_orientations,
                          force_recompute=True)

    # create a delta spike
    numorientations = k.get_orientations().shape[0]
    spike = np.zeros((7, 7, 7, numorientations), dtype=np.float64)
    spike[3, 3, 3, 0] = 1

    # convolve kernel with delta spike
    csd_enh = convolve_sf(spike, k, test_mode=True, normalize=False)

    # check if kernel matches with the convolved delta spike
    totalsum = 0.0
    for i in range(0, numorientations):
        totalsum += np.sum(np.array(k.get_lookup_table())[i, 0, :, :, :] - \
                    np.array(csd_enh)[:, :, :, i])
    npt.assert_equal(totalsum, 0.0)
Exemple #2
0
def test_spike():
    """ Test if a convolution with a delta spike is equal to the kernel
    saved in the lookup table."""
    
    # create kernel
    D33 = 1.0
    D44 = 0.04
    t = 1
    num_orientations = 5
    k = EnhancementKernel(D33, D44, t, orientations=num_orientations, force_recompute=True)

    # create a delta spike
    numorientations = k.get_orientations().shape[0]
    spike = np.zeros((7, 7, 7, numorientations), dtype=np.float64)
    spike[3, 3, 3, 0] = 1

    # convolve kernel with delta spike
    csd_enh = convolve_sf(spike, k, test_mode=True, normalize=False)

    # check if kernel matches with the convolved delta spike
    totalsum = 0.0
    for i in range(0, numorientations):
        totalsum += np.sum(np.array(k.get_lookup_table())[i, 0, :, :, :] - \
                    np.array(csd_enh)[:, :, :, i])    
    npt.assert_equal(totalsum, 0.0)
Exemple #3
0
def test_kernel_input():
    """ Test the kernel for inputs of type Sphere, type int and for input None"""

    sph = Sphere(1, 0, 0)
    D33 = 1.0
    D44 = 0.04
    t = 1
    k = EnhancementKernel(D33, D44, t, orientations=sph, force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (1, 1, 7, 7, 7))

    num_orientations = 2
    k = EnhancementKernel(D33, D44, t, orientations=num_orientations, force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (2, 2, 7, 7, 7))

    k = EnhancementKernel(D33, D44, t, orientations=0, force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (0, 0, 7, 7, 7))
Exemple #4
0
def test_kernel_input():
    """ Test the kernel for inputs of type Sphere, type int and for input None"""

    sph = Sphere(1, 0, 0)
    D33 = 1.0
    D44 = 0.04
    t = 1
    k = EnhancementKernel(D33, D44, t, orientations=sph, force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (1, 1, 7, 7, 7))

    num_orientations = 2
    k = EnhancementKernel(D33,
                          D44,
                          t,
                          orientations=num_orientations,
                          force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (2, 2, 7, 7, 7))

    k = EnhancementKernel(D33, D44, t, orientations=0, force_recompute=True)
    npt.assert_equal(k.get_lookup_table().shape, (0, 0, 7, 7, 7))