Example #1
0
loaded_infos = ImageHandler.load_image_infos()
infos = list()

# processing steps
processing_steps = [['DIL', 'y', 2], ['CONV_BIT', 16]]

for info in loaded_infos:
    info_ID = info['ID']
    if info_ID in selected_info_IDs:
        infos.append(info)

for info in infos:
    seg = Segmentation(info)
    seg.load()

    img_path = seg.get_results_dir().tmp + 'contact_surface.tif'

    print('LOAD', info['ID'])

    # go through nuclei and add to stack
    nIDs = seg.nuclei.get_nIDs(only_accepted=True)

    stack_contact_surface = np.zeros_like(seg.stacks.lamin)

    num_nIDs = len(nIDs)

    # go through nIDs
    for i, nID in enumerate(nIDs):
        print('PROCESS %i/%i' % (i, num_nIDs))

        stack_tmp_self = np.zeros_like(seg.stacks.lamin)
Example #2
0
img_maps = dict()
val_maps = dict()
tiling_count_map = dict()
tiling_maps = dict()
limits = dict()
limit_lists = dict()

for info in infos:
    seg = Segmentation(info)
    seg.load()

    # preparations for params
    if 'between_space' in params_to_get:
        # get binary stack without nuclei
        filled_minus_nuclei = ImageHandler.load_tiff_as_stack(
            seg.get_results_dir().tmp + 'filled_minus_nuclei.tif')

        if filled_minus_nuclei is None:
            filled_stack = np.full(
                (seg.stacks.lamin.shape[0], seg.stacks.lamin.shape[1],
                 seg.stacks.lamin.shape[2]),
                1,
                dtype=np.uint8)

            filled_minus_nuclei = seg.nuclei.add_nuclei_to_stack(
                filled_stack, nucleus_value=0, only_accepted=True)
            ImageHandler.save_stack_as_tiff(
                filled_minus_nuclei,
                seg.get_results_dir().tmp + 'filled_minus_nuclei.tif')

    count_lists = dict()
Example #3
0
processing_steps = [['DIL', 'y', 2],
                    ['CONV_BIT', 16]]

# calculate compactness?
calc_compactness = False

for info in loaded_infos:
    info_ID = info['ID']
    if info_ID in selected_info_IDs:
        infos.append(info)

for info in infos:
    seg = Segmentation(info)
    seg.load()

    img_path = seg.get_results_dir().tmp + 'compactness_examples.tif'

    voxel_size = float(info['voxel_size'])
    voxel_volume = voxel_size ** 3
    voxel_surface = voxel_size ** 2

    print('LOAD', info['ID'])

    # go through nuclei and add to stack
    nIDs = seg.nuclei.get_nIDs(only_accepted=True)

    example_counter = np.zeros((5 * 5)).astype(np.int8)
    stack_examples = list()
    examples_to_show = 5

    for x in range(0, len(example_counter)):
Example #4
0
for info in loaded_infos:
    info_ID = info['ID']
    if info_ID in selected_info_IDs:
        infos.append(info)

for info in infos:
    seg = Segmentation(info)
    seg.load()

    # go through nuclei and add them to a stack with
    # nuclei_in_direction as value
    nIDs = seg.nuclei.get_nIDs(only_accepted=True)

    layer_stack = np.zeros_like(seg.stacks.nuclei)

    for nID in nIDs:
        # get nuclei in direction
        apical = seg.nuclei.get_nucleus_apical_distance(nID)

        if np.isnan(apical):
            apical = 0

        # add to stack
        seg.nuclei.add_nucleus_to_stack(nID, layer_stack, nucleus_value=apical)

    # save stack as tif
    ImageHandler.save_stack_as_tiff(
        layer_stack,
        seg.get_results_dir().tmp + 'nuclei_layers.tif')
Example #5
0
          'xtick.labelsize': cfg.fontsdict_plot['fontsize'],
          'ytick.labelsize': cfg.fontsdict_plot['fontsize']}

plt.rcParams.update(params)

# open window to select nuclei criteria
infos = ImageHandler.load_image_infos()

# select a specific info
selected_info_IDs = ['N1-19-24']

for info in infos:
    if info['ID'] in selected_info_IDs:
        seg = Segmentation(info)
        seg.load()

processing_steps = [
    ['EQU'],
    ['THR', 'OTSU', 100, 'no3D'],
    ['CLS', 'bin', 2],
    ['FILL'],
    ['OPN', 'bin', 2],
    ['CONV_BIT', 16, '3D']
]

# apply processing steps
seg.stacks.membin = ImageProcessing.apply_filters(
    processing_steps, seg.stacks.membrane, verbose=cfg.general_verbose)

ImageHandler.save_stack_as_tiff(seg.stacks.membin, seg.get_results_dir().tmp + cfg.file_stack_membin)
Example #6
0
    nIDs = seg.nuclei.get_nIDs(only_accepted=True)

    stack_apical_dist = np.zeros_like(seg.stacks.lamin)
    stack_pseudo_layer = np.zeros_like(seg.stacks.lamin)

    # get average nuclei height
    all_depths = seg.nuclei.data_frames['data_params'].get_vals_from_col('depth', only_accepted=True)

    # get average
    avg_depth = np.mean(all_depths)

    print('MEAN DEPTH', avg_depth)

    for nID in nIDs:
        # get layer
        apical_dist = seg.nuclei.get_nucleus_apical_distance(nID)

        if not math.isnan(apical_dist):
            stack_apical_dist = seg.nuclei.add_nucleus_to_stack(nID, stack_apical_dist, nucleus_value=int(apical_dist))
            stack_pseudo_layer = seg.nuclei.add_nucleus_to_stack(nID, stack_pseudo_layer,
                                                                 nucleus_value=int(apical_dist/avg_depth))

    # save stack
    img_path_apical_dist = seg.get_results_dir().tmp + 'apical_dist.tif'
    img_path_pseudo_layer = seg.get_results_dir().tmp + 'pseudo_layer.tif'

    print('SAVE')

    ImageHandler.save_stack_as_tiff(stack_apical_dist, img_path_apical_dist)
    ImageHandler.save_stack_as_tiff(stack_pseudo_layer, img_path_pseudo_layer)
Example #7
0
    print('LOAD', info['ID'])

    # go through nuclei and add to stack
    nIDs = seg.nuclei.get_nIDs(only_accepted=True)

    stack_volume = np.zeros_like(seg.stacks.lamin).astype(np.int8)

    all_volumes = seg.nuclei.data_frames['data_params'].get_vals_from_col(
        'volume', only_accepted=True)

    min_val = float(max(all_volumes))
    max_val = float(min(all_volumes))

    for nID in nIDs:
        volume = seg.nuclei.get_nucleus_volume(nID)

        colour = int((volume - min_val) / (max_val - min_val) * 255)

        seg.nuclei.set_nucleus_colour(colour, nID)

    stack_volume = seg.nuclei.add_nuclei_to_stack(stack_volume,
                                                  only_accepted=True)

    # save stack
    img_path = seg.get_results_dir().tmp + 'volume.tif'

    print('SAVE')

    ImageHandler.save_stack_as_tiff(stack_volume, img_path)