Example #1
0
    def adjacency_complex_optimization(
        self, n_iterations=1, omega_energies={"image": 10.0, "geometry": 0.1, "adjacency": 0.01}
    ):
        """Optimize the adjacency complex to match better the actual cell adjacencies in the tissue.

        The optimization is performed as an iterative energy minimization process of local topological transformations 
        (edge flips and triangle swaps) following a simulated annealing heuristic.

        Args:
            n_iterations (int): number of iterations (cycles of simulated annealing) to perform
            omega_energies (dict): weights of the different terms of the energy functional :
                • 'image' : energy measuring the difference between the adjacency complex simplices and the ones extracted from the image
                • 'geometry' : energy penalizing irregular tetrahedra in the adjacency complex
                • 'adjacency' : energy pulling the number of neighbors of each cell to an empirical optimal value according to its layer

        Updates:
            triangulation_topomesh (PropertyTopomesh) : the DracoMesh adjacency complex is set to this optimized complex.

        Returns:
            None
        """

        self.optimized_delaunay_topomesh = deepcopy(self.delaunay_topomesh)
        compute_tetrahedrization_geometrical_properties(self.optimized_delaunay_topomesh)
        tetrahedrization_topomesh_add_exterior(self.optimized_delaunay_topomesh)
        self.optimized_delaunay_topomesh = tetrahedrization_topomesh_topological_optimization(
            self.optimized_delaunay_topomesh,
            image_cell_vertex=self.image_cell_vertex,
            omega_energies=omega_energies,
            image_graph=self.image_graph,
            n_iterations=n_iterations,
        )
        tetrahedrization_topomesh_remove_exterior(self.optimized_delaunay_topomesh)
        clean_tetrahedrization(self.optimized_delaunay_topomesh, min_cell_neighbors=2)
        self.triangulation_topomesh = deepcopy(self.optimized_delaunay_topomesh)
Example #2
0
    def delaunay_adjacency_complex(self, surface_cleaning_criteria = ['surface','exterior','distance','sliver']):
        """Estimate the adjacency complex by the Delaunay tetrahedrization of the cell barycenters.

        Since Delaunay applied on the cell barycenters would produce a convex simplicial complex, it is necessary 
        to carve out the complex to keep only the actual relevant simplices.

        Args:
            surface_cleaning_criteria (list): the criteria used during the surface carving phase of the Delaunay complex :
                • 'exterior' : remove surface simplices that lie entirely outside the tissue
                • 'surface' : remove surface simplices that intersect the surface of the tissue
                • 'distance' : remove surface simplices that link cells too far apart
                • 'sliver' : remove surface simplices that create flat tetrahedra (slivers)

        Updates:
            triangulation_topomesh (PropertyTopomesh) : the DracoMesh adjacency complex is set to this Delaunay complex.

        Returns:
            None
        """     

        clean_surface = len(surface_cleaning_criteria)>0
        self.delaunay_topomesh = delaunay_tetrahedrization_topomesh(self.positions, image_cell_vertex=self.image_cell_vertex, segmented_image=self.segmented_image, clean_surface=clean_surface, surface_cleaning_criteria=surface_cleaning_criteria)
        clean_tetrahedrization(self.delaunay_topomesh, clean_vertices=False)
        discarded_cells = np.array(list(self.delaunay_topomesh.wisps(0)))[np.where(np.array(map(len,[list(self.delaunay_topomesh.regions(0,v,2)) for v in self.delaunay_topomesh.wisps(0)]))==0)[0]]
        for v in discarded_cells:
            self.delaunay_topomesh.remove_wisp(0,v)  
        self.triangulation_topomesh = deepcopy(self.delaunay_topomesh)