예제 #1
0
                    }
                    detected_topomesh = vertex_topomesh(seed_positions)
                    # -- Detect L1 using 'nuclei_layer':
                    oriented_seeds = {
                        k: np.array([1., 1., -1.]) * v
                        for k, v in seed_positions.items()
                    }
                    cell_layer = img_graph.vertex_property('L1')
                    # -- Update the topomesh with the 'layer' property:
                    detected_topomesh.update_wisp_property(
                        'layer', 0, cell_layer)
                    # -- Save the detected topomesh:
                    ppty2ply = dict([(0, ['layer']), (1, []), (2, []),
                                     (3, [])])
                    save_ply_property_topomesh(detected_topomesh,
                                               topomesh_file,
                                               properties_to_save=ppty2ply,
                                               color_faces=False)

                # - Create a 'detected_topomesh' out of L1 cells only:
                L1_detected_topomesh = filter_topomesh_vertices(
                    detected_topomesh, "L1")
                # world.add(L1_detected_topomesh, L1_detected_seed"+suffix)
                # world[L1_detected_seed"+suffix]["property_name_0"] = 'layer'
                # world["L1_detected_seed{}_vertices".format(suffix)]["polydata_colormap"] = load_colormaps()['Reds']

                # - Performs evaluation of detected seeds agains expert:
                print "\n# Evaluation: comparison to EXPERT seeds..."
                evaluation = evaluate_positions_detection(
                    detected_topomesh,
                    expert_topomesh,
                    max_distance=np.linalg.norm(size * vxs))
예제 #2
0
            filename] + "_nuclei_detection_topomesh{}.ply".format(suffix)
    if not os.path.exists(topomesh_file):
        # topomesh, surface_topomesh = nuclei_image_topomesh(image_dict,threshold=1000,reference_name=reference_name,microscope_orientation=microscope_orientation,signal_names=signal_names,compute_ratios=compute_ratios,subsampling=4,return_surface=True)
        topomesh = nuclei_image_topomesh(
            image_dict,
            threshold=1000,
            reference_name=reference_name,
            microscope_orientation=microscope_orientation,
            signal_names=signal_names,
            compute_ratios=compute_ratios,
            subsampling=4,
            surface_subsampling=6)
        save_ply_property_topomesh(topomesh,
                                   topomesh_file,
                                   properties_to_save=dict([
                                       (0, signal_names + ['layer']), (1, []),
                                       (2, []), (3, [])
                                   ]),
                                   color_faces=False)

        df = topomesh_to_dataframe(topomesh, 0)
        df.to_csv(image_dirname + "/" + nomenclature_names[filename] + "/" +
                  nomenclature_names[filename] +
                  "_signal_data{}.csv".format(suffix))

# Correction step:
for rescaling in [False, True]:
    reference_img = image_dict[reference_name]
    try:
        vxs = reference_img.voxelsize
    except:
예제 #3
0
center = np.array([size/2,size/2,size/2],float)*np.array(img.resolution)
    
positions = L1_topomesh.wisp_property('barycenter',0)
for p in L1_topomesh.wisps(0):
    positions[p] = center + (size/3.)*np.array(img.resolution)*(positions[p]-center)/np.linalg.norm(positions[p]-center)
    
L1_topomesh.update_wisp_property('barycenter',0,positions)
world.add(L1_topomesh ,'dual_reconstuction')


triangular_string = ""
for t in triangular:
    triangular_string += t+"_"
topomesh_filename = dirname+"/output_meshes/"+filename+"/"+filename+"_voronoi_L1_"+triangular_string+"topomesh.ply"

save_ply_property_topomesh(L1_topomesh,topomesh_filename,color_faces=True)



triangulation_topomesh = deepcopy(draco.triangulation_topomesh)

from openalea.cellcomplex.property_topomesh.property_topomesh_extraction import epidermis_topomesh, clean_topomesh

triangulation_topomesh = epidermis_topomesh(triangulation_topomesh)

triangulation_triangles = np.array([list(triangulation_topomesh.borders(2,t,2)) for t in triangulation_topomesh.wisps(2)])
not_L1_triangles = np.array(list(triangulation_topomesh.wisps(2)))[np.sum(draco.cell_layer.values(triangulation_triangles) == 1,axis=1)<2]
for t in not_L1_triangles:
    triangulation_topomesh.remove_wisp(2,t)

clean_topomesh(triangulation_topomesh)
예제 #4
0
                except:
                    pass
                else:
                    print "Applied mask to nuclei signal...",
                if iso_resampling:
                    print "\nPerforming 'isometric_resampling'..."
                    img = isometric_resampling(img)
                if std_dev != 0:
                    print "\nPerforming 'gaussian_smoothing' with std_dev={}...".format(std_dev)
                    img = linear_filtering(img, 'gaussian_smoothing', std_dev=std_dev)

                # - Performs nuclei detection:
                detected_topomesh = nuclei_image_topomesh(dict([(nuclei_ch_name, img)]), reference_name=nuclei_ch_name, signal_names=[], compute_ratios=[], microscope_orientation=microscope_orientation, radius_range=(radius_min,radius_max), threshold=threshold, subsampling=10)
                # detected_positions = detected_topomesh.wisp_property('barycenter',0)
                print "Done"
                save_ply_property_topomesh(detected_topomesh, topomesh_file, properties_to_save=dict([(0,[nuclei_ch_name]+['layer']),(1,[]),(2,[]),(3,[])]), color_faces=False)

            # - Display detected_topomesh:
            # world.add(detected_topomesh, "detected_nuclei"+suffix)
            # world["detected_nuclei"+suffix]["property_name_0"] = 'layer'
            # world["detected_nuclei"+suffix+"_vertices"]["polydata_colormap"] = load_colormaps()['Reds']

            # - Filter L1-detected nuclei:
            L1_detected_topomesh = filter_topomesh_vertices(detected_topomesh, "L1")
            # - Display L1_detected_topomesh:
            # world.add(L1_detected_topomesh,"L1_detected_nuclei"+suffix)
            # world["L1_detected_nuclei"+suffix]["property_name_0"] = 'layer'
            # world["L1_detected_nuclei"+suffix+"_vertices"]["polydata_colormap"] = load_colormaps()['Reds']

            # - Evaluate nuclei detection for all cells:
            print "Evaluate nuclei detection for all cells:"
예제 #5
0
#triangular = ['star','remeshed','realistic','projected','flat']
triangular = ['star', 'remeshed']
image_dual_topomesh = draco.dual_reconstruction(
    reconstruction_triangulation=triangular,
    adjacency_complex_degree=3,
    maximal_edge_length=5.1)
#image_dual_topomesh = draco.draco_topomesh(reconstruction_triangulation = triangular)

from openalea.cellcomplex.property_topomesh.property_topomesh_optimization import property_topomesh_vertices_deformation
#property_topomesh_vertices_deformation(image_dual_topomesh,iterations=15)

world.add(image_dual_topomesh, 'dual_reconstuction')

draco_file = dirname + "/output_meshes/" + filename + "/" + filename + "_DRACO_mesh.ply"
save_ply_property_topomesh(image_dual_topomesh,
                           draco_file,
                           color_faces=True,
                           colormap=load_colormaps()['glasbey'])

optimized_dual_topomesh = optimize_topomesh(
    image_dual_topomesh,
    omega_forces={
        'regularization': 0.00,
        'neighborhood': 0.65,
        'taubin_smoothing': 0.65,
        'laplacian': 0.7,
        'planarization': 0.27,
        'epidermis_planarization': 0.05,
        'convexity': 0.06
    },
    omega_regularization_max=0.01,
    edge_flip=True,
예제 #6
0
                                 spatio_temporal_properties=['barycenter'],
                                 ignore_cells_at_stack_margins=False)
    print img_graph.nb_vertices(), " Seeds detected"
    seed_positions = dict([(v, img_graph.vertex_property('barycenter')[v])
                           for v in img_graph.vertices()])
    seed_topomesh = vertex_topomesh(seed_positions)
    #world.add(seed_topomesh,'seeds')

    cell_layer = nuclei_layer(seed_positions, size, voxelsize)
    seed_topomesh.update_wisp_property('layer', 0, cell_layer)

    topomesh_file = image_dirname + filename + "_eq_seeds_topomesh.ply"
    save_ply_property_topomesh(seed_topomesh,
                               topomesh_file,
                               properties_to_save=dict([
                                   (0, ['Lti6b'] + ['layer']), (1, []),
                                   (2, []), (3, [])
                               ]),
                               color_faces=False)
    df = topomesh_to_dataframe(seed_topomesh, 0)
    df.to_csv(image_dirname + filename + "_signal_data.csv")

# Correction :

seed_topomesh_filename = image_dirname + filename + "_eq_seeds_topomesh.ply"
seed_topomesh = read_ply_property_topomesh(seed_topomesh_filename)
## L1 cells only
L1_cells = np.array(list(seed_topomesh.wisps(0)))[seed_topomesh.wisp_property(
    'layer', 0).values() == 1]
non_L1_cells = np.array(list(seed_topomesh.wisps(0)))[
    seed_topomesh.wisp_property('layer', 0).values() != 1]