add_centroids_to_rag_with_pbc

compute.add_centroids_to_rag_with_pbc(rag, props, pbc_groups, ase_atoms, shape)

Add PBC-aware centroid_pbc coordinates to RAG nodes for each periodic image group.

The function takes in a graph, a list of properties, a list of groups of nodes that are connected by periodic boundary conditions, an ASE atoms object, and the shape of the image.

The function first makes a copy of the graph. Then, it loops through each group of nodes that are connected by periodic boundary conditions. For each group, it finds the indices of the properties that correspond to the nodes in the group. If there is more than one node in the group, it finds the centroid of the group by taking the circular mean of the coordinates of the nodes in the group. If there is only one node in the group, it finds the centroid of the node by taking the mean of the coordinates of the node. Finally, it adds the centroid of the group

Parameters

Name Type Description Default
rag the Region Adjacency Graph object from skimage (skimage.future.graph.rag class) required
props a list of dictionaries, each dictionary contains the label and the coordinates of the centroid of the cluster required
pbc_groups a list of lists, where each list contains the labels of the atoms that are connected by periodic boundary conditions required
ase_atoms the atoms object from ASE required
shape shape of the image required

Returns

Name Type Description
The rag is being returned with the centroid_pbc added to the nodes.