morphogen.analysis.connectivity

Connected components and percolation.

class morphogen.analysis.connectivity.Components(n_components: int, sizes: ndarray, percolating: dict[str, bool], spanning_fraction: float, labels: ndarray | None = None)[source]

Bases: object

Connected components of one phase.

percolating[axis] tells whether a component joins the two faces normal to axis (inside the box, i.e. without using periodicity); spanning_fraction is the fraction of the phase volume in components joining at least one pair of faces. For periodic images, components touching across faces are merged before counting.

morphogen.analysis.connectivity.connected_components(image, phase: int = 1, *, connectivity: int = 6, periodic=None, return_labels=False) → Components[source]

The connected components of a phase of an image (connectivity: 6, 18 or 26 neighbours) and whether they percolate along each axis, through the faces of a periodic image (periodic, by default that of the image); their labels with return_labels.

morphogen.analysis.connectivity.wrapping(image, phase: int = 1, *, connectivity: int = 6) → dict[str, bool][source]

Whether a component of a phase of an image wraps around the periodic box along each axis (connectivity: 6, 18 or 26 neighbours): a cycle of neighbours through the faces winds around the axis, so that the tiled component is a cluster unbounded along it, the percolation of a periodic medium. Joining the two faces normal to the axis inside the box (the flags percolating of connected_components()) neither implies it (a staircase from face to face closes into no cycle) nor follows from it (a helix through the faces normal to y wraps along x and y and joins no pair of faces).