Esempio n. 1
0
def generate_bead_test_volume(name: str,
                              size: Tuple[int, int, int] = (32, 32, 32),
                              num_beads: int = 32,
                              sigmas: Tuple[float, float, float] = (0, 0, 2)):
    data = np.zeros(size)
    mask = np.array([True] * num_beads + [False] *
                    (np.prod(data.size) - num_beads))
    np.random.shuffle(mask)
    mask = mask.reshape(data.shape)
    data[mask] = 1

    blurred = gaussian_filter(data, sigmas, mode='constant')
    blurred_vol = Volume(blurred, (1, 1, 1))
    blurred_vol.save_tiff('test_' + name)
    blurred_vol.save_tiff_single('test_single_' + name)
Esempio n. 2
0
def generate_spheres_test_volume(name: str,
                                 size: int = 32,
                                 num_beads: int = 32,
                                 sigmas: Tuple[float, float,
                                               float] = (0, 0, 2)):
    data = np.zeros((size, size, size))
    for i in range(num_beads):
        p = np.random.randint(8, size - 8, 3)
        data[p[0] - 8:p[0] + 8, p[1] - 8:p[1] + 8,
             p[1] - 8:p[1] + 8] = pymrt.geometry.sphere(16, 0.5, 8)

    vol = Volume(data, (1, 1, 1))
    vol.save_tiff('test_' + name)
    vol.save_tiff_single('test_single_' + name)

    blurred = gaussian_filter(data, sigmas, mode='constant')
    blurred_vol = Volume(blurred, (1, 1, 1))
    blurred_vol.save_tiff('btest_' + name)
    blurred_vol.save_tiff_single('btest_single_' + name)
    return data