예제 #1
0
def crop_cube(sample_name, shape_2d, center_2d, slice_numbers):
    n_slices = slice_numbers[1]-slice_numbers[0]
    data = dm.load_data_server(sample_name, slice_numbers)

    for img, shot_name in tqdm(data, total=n_slices):
        img = crop(img, shape_2d, center=center_2d)

        dm.save_tif(img, "crop_"+sample_name, shot_name)
예제 #2
0
def remove_small_clusters(sample, 
                          min_cluster_size = 7000,
                          save_folder_tag="labeled"):
    for ranges in chunks(range(0, 2119), 100):
        ranges = ranges if ranges[1]<2120 else [2000, 2120]
        print("processing: ", ranges)
        masks3d = dm.assemble_3d_database(sample, ranges)
        masks3d_filtered = ds.find_big_ones_clusters(masks3d,
                                                     min_cluster_length=min_cluster_size,
                                                     min_cluster_order=None)
        masks3d_filtered = masks3d_filtered.astype(np.uint8)

        for n, mask2d in zip(range(*ranges), masks3d_filtered):
            dm.save_tif(mask2d, sample+"_"+save_folder_tag, dm.generate_tif_file_name(n))
예제 #3
0
import numpy as np
from tqdm import tqdm

import configures
import data_manager as dm

if __name__ == "__main__":
    params = configures.InputParameters()
    sample = params.sample
    coords = params.coords_2d
    z_range = params.z_range

    masks3d = dm.assemble_3d_database(sample, z_range)
    image3d = dm.assemble_3d_server(sample, z_range)
    print(len(masks3d))
    print(len(image3d))

    new_folder = "gecko_123438_plus"
    for n, mask, image in zip(np.arange(*z_range), masks3d, image3d):
        mask_wide = np.zeros(image.shape, dtype=bool)
        mask_wide[coords] = mask
        dm.save_tif(mask_wide, new_folder, dm.generate_tif_file_name(n))
예제 #4
0
    start_time = time.time()
    shot_names = [dm.generate_tif_file_name(n) for n in range(*z_range)]

    image_3d = dm.assemble_3d_server(sample, z_range)
    print(image_3d.shape)

    image_3d = image_3d[coords]
    print(image_3d.shape)

    thrs1 = 0.000266  #np.percentile(image_3d.flat[::5], 95)
    thrs2 = -1.54e-05  # np.percentile(image_3d.flat[::5], 35)

    image_3d = median(image_3d, selem=ball(1))
    print(image_3d.shape)

    divs = np.array(image_3d.shape) // np.array([20, 40, 40])
    image_3d = chunked_func(func=binarize_img,
                            im=image_3d,
                            thrs1=thrs1,
                            thrs2=thrs2,
                            max_iter=divs[0] * divs[1] * divs[2],
                            divs=divs,
                            overlap=(3, 5, 5),
                            cores=2)

    for img2d, shot_name in tqdm(zip(image_3d, shot_names),
                                 total=len(image_3d)):
        dm.save_tif(img2d, sample, shot_name)
    end_time = time.time()
    print("cumulative time (min): ", (end_time - start_time) / 60)