vivarium.processes.derive_colony_shape module

Colony Shape Deriver

class vivarium.processes.derive_colony_shape.ColonyShapeDeriver(parameters=None)[source]

Bases: vivarium.core.process.Deriver

Derives colony shape metrics from cell locations

defaults = {'alpha': 1.0, 'bounds': [1, 1]}
name = 'colony_shape_deriver'
next_update(timestep, states)[source]
ports_schema()[source]
class vivarium.processes.derive_colony_shape.TestDeriveColonyShape[source]

Bases: object

calc_shape_metrics(points, alpha=None)[source]
flatten(lst)[source]
test_colony_too_diffuse()[source]
test_concave()[source]
test_convex()[source]
test_find_multiple_colonies()[source]
test_ignore_outliers_and_nan()[source]
test_no_cells()[source]
test_single_cell()[source]
test_two_cells()[source]
class vivarium.processes.derive_colony_shape.Variables[source]

Bases: object

AREA = 'surface_area'
CIRCUMFERENCE = 'circumference'
MAJOR_AXIS = 'major_axis'
MASS = 'mass'
MINOR_AXIS = 'minor_axis'
vivarium.processes.derive_colony_shape.gen_agent_colony_map(agents, colony_shapes)[source]

Create a map from agent to the colony to which the agent belongs

An agent is considered within a colony if its location variable intersects with the colony’s interior or border. If an agent intersects with multiple colonies, we choose arbitrarily which colony the agent belongs to.

Points containing any nan coordinate are considered to be outside of all shapes.

Note

An agent may be part of no colony at all, in which case it will not be included in the returned map.

Parameters
  • agents (dict) – Dictionary of agents port state whose keys are agent IDs and whose values are agent state dictionaries.

  • colony_shapes (list) – List of polygons that define the colonies.

Returns

Map from agent ID to index of colony in colony_shapes.

Return type

dict

vivarium.processes.derive_colony_shape.major_minor_axes(shape)[source]

Calculate the lengths of the major and minor axes of a shape

We assume that the major and minor axes are the dimensions of the minimum bounding rectangle of the shape. Note that this is different from using PCA to find the axes, especially for highly asymmetrical and concave shapes.

Parameters

shape (shapely.polygon.Polygon) – The shape to compute axes for.

Returns

A tuple with the major axis first and the minor axis second.

Return type

tuple