Ejemplo n.º 1
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))
Ejemplo n.º 2
0
def preview(sample_name, n, contrast=True, server=True):
    if server:
        img = dm.get_img2d_from_server(sample_name, n)
    else:
        file_name = dm.generate_tif_file_name(n, True)
        img = dm.get_img2d_from_database(file_name,
                                         folder_name="crop_"+sample_name)

    if contrast:
        clip_limit = 0.1
    
        img = exposure.equalize_adapthist(img, clip_limit=clip_limit)

    fig, ax = plt.subplots(figsize=(7, 7))
    ax.imshow(img, cmap="gray")
    dm.save_plot(fig, "sections", sample_name+"_"+str(n))
Ejemplo 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))
Ejemplo n.º 4
0
    print("count", count, " of ", max_iter, f" %: {count/max_iter:.2f}",
          "| time (min): ", (time.time() - start_time) / 60)
    count += 1

    return t < 2


if __name__ == "__main__":
    sample = "gecko_123438"

    params = configures.InputParameters()
    z_range = params.z_range
    coords = params.coords_3d

    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,