3.4 Spatio-temporal detection and analysis
3.4.1 Spatial entity types
3.4.1.1 Regions
One of the main assumptions of the region detection mechanism is that subsets and not individual positions of the discretised space are considered. Secondly the value of each position in the discretised space records the number/density of entities of interest. Each position can hold 0 or more entities without pileup and the identity of the elements forming the region is not explicitly taken into account. It is assumed that the shape and size of the entities is constant throughout the entire space. Therefore the region detection mechanism operates in a homogeneous context with respect to the entities considered. If the system comprises multiple
types of entities each type should be represented by a different spatial state variable. Therefore different types of regions can be detected by repeatedly applying the region detection mechanism for each corresponding spatial state variable.
Given a model execution/simulation σ and a spatial state variable spsv, let us denote the i-th state of the model execution σ by σ[i], 0 ≤ i ≤ |σ|, where |σ| represents the length of σ.
Definition 6 Region
A region reg with respect to σ[i] and spsv is a subset of neighbouring positions in SpV (σ, σ[i], spsv) such that ∀x ∈ reg, value(x) ≥ value and |reg| > size, where value, size ∈ R are user-defined parameters.
Two positions in the discretised space are neighbouring if they share at least one corner/border.
The problem of finding regions is similar to the segmentation problem in the Computer Vision literature (Szeliski, 2010). 2D images can be represented as vectors or matrices where each position records the colour (multi-channel) or intensity (single channel) of the image. In order to apply Computer Vision methods for finding regions the matrix encoding the current state of the discretised spatial domain is translated to a greyscale image. The value of each position in the matrix is normalised and converted to the intensity value of the corresponding pixel in the resulting image. Examples of greyscale images in which sector-like patterns have been detected in bacterial colonies are depicted in Figure 3.4.
Figure 3.4: In silico generated greyscale images depicting bacterial colonies containing “wild type” (dark grey) and “mutant” (light grey) cells. Sector-like patterns corresponding to high-proportions of “mutant” cells are automatically detected, analysed and outlined in blue.
described in Algorithm 1. All mentioned subalgorithms are implemented in the open source Computer Vision library OpenCV (Bradski and Kaehler, 2008); see Appendix C.1 for a mapping between the subalgorithms described in Algorithm 1 and the OpenCV functions. Detailed descriptions of the OpenCV function parameters are provided in the official OpenCV documentation (Itseez, 2013) and will not be restated here.
Algorithm 1 Algorithm for region detection
Require: image is a greyscale image
Ensure: regions defines the set of regions detected in the image
1: ChangeBrightnessAndContrast(image, alpha, beta); . Adjust brightness
2: and contrast
3: MorphologicalCloseOperation(image, morphCloseNrOfIter ); . Connect
4: discontinued but
5: close regions and
6: remove noise
7: GaussianBlur(image, kernelSize, standardDev); . Remove remaining noise 8: Threshold(image, value); . Apply binary threshold method to 9: image considering threshold value value 10:
11: contours = DetectAndApproximateContours(image, approximationLevel); . Detect regions contours
12:
13: for all contour ∈ contours do 14: if size(contour) < size then
15: Mark the region defined by contour as noise; 16: end if
17: end for 18:
19: regions = {reg | reg ∈ contours, reg not marked as noise}; . The set of
20: regions is defined by
21: the subset of contours
22: not marked as noise
23: with size greater or
24: equal to size
25:
26: return regions;
3.4.1.2 Clusters
Given a collection of regions, the cluster detection mechanism constructs groups of sufficiently similar regions. During this procedure no assumption is made regarding the size and type of the regions. In contrast to the region detection
mechanism, the mechanism for detecting clusters operates in a heterogeneous context where both fixed and variable size subsets of the discretised space are considered.
Our assumption is that two regions are similar and should belong to the same cluster if the distance between them is below a certain threshold. A distance pseudometric dist is defined for this purpose:
dist : REG × REG → R, dist(A, B) =p(xB− xA)2+ (yB− yA)2,
where REG is the set of all regions, and dist(A, B) computes the Euclidean distance between the centroids of two regions A, B ∈ REG . The Euclidean distance measure is considered because we are interested in detecting and analysing how groups of entities that are sufficiently close to each other in space (i.e. the Euclidean distance between them is bounded above) change over time; see Section 4.3 for an illustrative case study describing how single cells chemotactically aggregate into groups, and how these groups change over time.
Definition 7 Cluster
A cluster clust with respect to a set of regions REG , and a pseudometric dist, is a subset of regions in REG such that ∀x, y ∈ clust, dist(x, y) ≤ ζdistance and |clust| > ζsize, where ζdistance ∈ R and ζsize∈ N are user-defined parameters.
The problem of grouping entities into clusters is addressed by the cluster analysis literature (Jain, 2010). A popular algorithm which considers distance (not necessarily Euclidean) as a criterion for grouping objects is DBSCAN (Ester et al., 1996). The original algorithm has a known issue because the assignment of border objects (i.e. objects between multiple clusters) to clusters depends on the order in which the set of objects is iterated. An improved version of the DBSCAN algorithm was introduced by Tran et al. (Tran et al., 2013) for addressing this issue and is employed by our cluster detection mechanism considering the pseudometric dist as the distance function. Illustrative examples of greyscale images in which clusters of cells are automatically detected and analysed are depicted in Figure 3.5.