AnalysisUtils

Compactness

AnalysisUtils.getCompactness(sigma, minval=0)[source]

Calculate compactness of a morphology: \(\frac{A_{\text{area}}}{A_{\text{convex hull}}}\) .

Parameters:
  • sigma – numpy array with cell id’s
  • minval (int) – minimum cell id for non medium pixels
Returns:

compactness

AnalysisUtils.getLCC(sigma)[source]

Find largest connected component of an image

Parameters:sigma – numpy array with cell id’s
Returns:image with largest connected component

Order parameter

The order parameter describes the orientational order of a liquid crystal : \(s = \left \langle \text{cos}(2 \theta)\right \rangle\); \(s = 0\;\) for a random sample and \(s = 1\;\) for an isotropic sample. \(\theta\;\) is the angle between the cell direction and the director. The director is a dimensionless unit vector. It represents the direction of preferred orientation of cells in the neighborhood of any point. Because there is no physical polarity along the director axis, n and -n are fully equivalent. Here the neighborhood is defined as a circle with center com and radius r.

AnalysisUtils.getDirector(com, r, sigma, angles)[source]

Find the director of the center of mass of a cell.

Parameters:
  • com – center of mass of the cell (x,y)
  • r (number) – radius of neighborhood
  • sigma – numpy array with cell id’s
  • angles – numpy array with cell angles (radians)
Returns:

director (radians)

AnalysisUtils.getOrderParameter(sigma, angles, r)

Calculate order parameter for a morphology using the cpm grid data. When the requested radius is larger than the maximum radius of the grid, the global order parameter is calculated with getGlobalOrderParameter(); otherwise the local order parameter is calculated with getLocalOrderParameter().

Parameters:
  • sigma – numpy array with cell id’s
  • angles – numpy array with cell angles (radians)
  • r (int) – radius of neighborhood
AnalysisUtils.getLocalOrderParameter(sigma, angles, r)

Calculate local order parameter.

Parameters:
  • sigma – numpy array with cell id’s
  • angles – numpy array with cell angles (radians)
  • r (int) – radius of neighborhood
Returns:

local order parameter

See also

getDirector()

AnalysisUtils.getGlobalOrderParameter(sigma, angles)

Calculate global order parameter.

Parameters:
  • sigma – numpy array with cell id’s
  • angles – numpy array with cell angles (radians)
Returns:

global order parameter

AnalysisUtils.getRelativeDirField(sigma, r)[source]

Calculate field with relative director for each pixel. The relative director is the difference to the angle of the cell at that pixel and the relative director on the pixel. Pixels with high values represent unordered areas, such as branchpoints.

Parameters:
  • sigma – numpy array with cell id’s
  • r (int) – radius of neighborhood
Returns:

field with relative director values

Cell clusters

Clusters of aligned cells are automatically detected using the relative director field, with the following steps:

  1. Remove all pixels that have a value in the relative director field higher than a given threshold.

  2. Detect blobs in remaining image with a labeling algorith:
    1. an opening operation may be performed before labeling.
    2. areas smaller than a given size are ignored;
  3. Map each blob on the CPM grid:
    1. at least a given fraction of the cell must be on the labeled area.
  4. Check for cells in multiple clusters:
    1. remove cell from all but biggest cluster;
    2. remove cluster if it is empty after (a).
AnalysisUtils.getCellClusters(field, sigma, th=15, minlabsize=50, opendisk=1, mincellsize=0.25)[source]

Get clusters for a single morphology.

Parameters:
  • field – numpy array with values on which data is seperated
  • cells – dict with cell identifiers as keys and ClusterCell instances as values
  • sigma – CPM grid
  • th (number) – threshold value for step 1
  • minlabsize (int) – labelled areas smaller than this value are ignored (2b)
  • opendisk (int) – disk size for opening operation (2a)
  • mincellsize (number) – minimal fraction of the cell that must be on the labelled area to be added to the cluster
Returns:

dictionary with cluster id as key and Cluster instances

See also

Cluster

class AnalysisUtils.Cluster(id)[source]

Container for a cell cluster

Parameters:id – cluster id
Variables:cells – list of ids of the cells in the clusters
addCell(cellid)[source]

Add cell to cluster

Parameters:cellid – id of cell
getClusterSize()[source]

Calculate number of cell in cluster

Returns:number of cells in cluster
removeCell(cellid)[source]

Remove cell from cluster

Parameters:cellid – id of cell
class AnalysisUtils.ClusterCellTC(id)[source]

A class that holds properties related to a cell at each measured time step. These properties are:

  • cluster id and size at each time step
  • long axis at each time step
  • center of mass at each time step
Parameters:

id – cell id

Variables:
  • id – cell id
  • clusterId – list of cluster id’s
  • clusterSize – list of cluster sizes
  • time – list of time steps
  • laxis – 2D array with long axes of the cell
  • com – 2D array with centers of mass of the cell
addTimeStep(t, pix, cid, csz)[source]

Add time step

Parameters:
  • t (int) – time step
  • pix – cell coordinates ([x1,...,xn],[y1,...,yn])
  • cid (int) – cluster id
  • csz (int) – cluster size

Cell angles

The angle of a cell is calculated from the inertia tensor of a cell. From the intertia tensor we calucate the eigenvalues and eigenvectors; the eigenvector that corresponds with the largest eigenvalue represents the direction of the long axis of a cell. The angle between the long axis and the x-axis is the cell angle.

AnalysisUtils.getCellInertiaTensor(pix)

Get inertia tensor for a cell

Parameters:pix – cell coordinates ([x1,...,xn],[y1,...,yn])
Returns:inertia tensor [[Ixx,Ixy],[Ixy,Iyy]]
AnalysisUtils.getCellOrientation(pix)

Calculate orientation of a cell. The orientation is the eigenvector corresponding to the largest eigenvalue of the cells’ inertia tensor.

Parameters:pix – cell coordinates ([x1,...,xn],[y1,...,yn])
Returns:unit vector of the cell orientation
AnalysisUtils.getCellAngle(pix)[source]

Calculate angle of a cell on interval \([0,\pi]\)

Parameters:pix – cell coordinates ([x1,...,xn],[y1,...,yn])
Returns:angle in radians on interval \([0,\pi]\)
AnalysisUtils.getAngleField(sigma)[source]

Get field with the cell angles

Parameters:sigma – numpy array with cell id’s
Returns:numpy array with cell angles in radians

Mean squared displacement

The mean squared displacement describes the displacement of a cell over time with respect to the initial position : \(MSD = \left \langle (x(t) - x(0))^2 \right \rangle\;\). In a similar manner the mean squared angular displacement can be calculated : \(MSD = \left \langle (\theta(t) - \theta(0))^2 \right \rangle\;\)

AnalysisUtils.calcMSDTransForCellTC(com)[source]

Calculate the translational MSD for a single object.

Parameters:com – list of centers of mass at each time step
Returns:list with MSD for each time step
AnalysisUtils.calcMSDRotForCellTC(vecset)[source]

Calculate the rotational MSD for a single object.

Parameters:vecset – list of orientation vectors for each time step
Returns:list with MSD for each time step

Table Of Contents

Previous topic

Prerequisites

Next topic

ImageUtils

This Page