Tutorial: Introduction to the CPM

This tutorial walks through the Cellular Potts Model (CPM) in its basic form. It requires no upfront knowledge on the CPM and contains interactive components to illustrate how the algorithm works.

1. Framework Basics

1.1 The CPM in Space: The Grid

The Cellular Potts Model (CPM) is what we call discrete in space: it essentially describes space like a low-resolution image, zoomed in far enough that you can see the individual pixels. Each pixel \(p\) belongs to either the empty "background" or to a "cell" on that surface:

$$ \text{cell}(p) = \begin{cases} 0 & \text{background} \\ 1 & \text{cell with ID = 1} \\ 2 & \text{cell with ID = 2} \\ ... & etc \end{cases}$$
The entire space described by our model is then called the CPM "grid" or "lattice". For example, a grid with two square cells could look like this:
These pixel identities vary in both space (different pixels have different identities) and time (pixels can switch their cell identity over time): $$\text{cell} = f(p,t)$$ For example :
Now, let's explore where these identity changes come from.

1.2 Physical Laws in the CPM World: Energies and the Hamiltonian

CPM cells move because they continuously try to "conquer" pixels from other cells (or from the background). This is why the grid state \(\text{cell} (p,t)\) changes over time. These changes are stochastic but not completely random: in their competition for pixels, cells try to minimize the global energy of the system, defined by the Hamiltonian \(H\). (Mostly, this minimization does not actually "work" in the sense that the model never reaches a steady state, but it does guide behaviour in the model).

How these energies are computed depends on the exact model and will be discussed in more detail below; but the idea is that this general mechanism allows us to define a set of "rules" or "physical laws" that the CPM cells tend to follow in their dynamic game of conquering pixels.

The question remains: how does this energy minimization work?

1.3 The CPM in Time: Dynamics and the Metropolis Algorithm

The CPM controls its global energy \(H\) through the so-called Metropolis algorithm:

  1. Pick a random pixel on the grid as the "source" pixel \(p_s\);
  2. Pick a random neighbor of \(s\) as the "target" pixel \(p_t\);
  3. If \(\text{cell}(p_s,t) \neq \text{cell}(p_t, t)\) (i.e., the pixels do not belong to the same cell), then let \(p_s\) try to "copy" itself into \(p_t\) such that
    $$\text{cell}(p_t,t+1) \stackrel{?}{=} \text{cell}(p_s,t)$$
    Note the "try" in the previous sentence; this so-called "copy attempt" only succeeds with chance
    $$P_\text{copy} = \begin{cases} e^{-\Delta H/T} & \Delta H \gt 0\\ 1 & \Delta H \leq 0 \end{cases}$$
    Here, \(\Delta H\) is the energetic effect the copy attempt, if successful, would have: \(\Delta H \leq 0\) indicates an "energetically favourable" change, while \(\Delta H \gt 0\) indicates an unfavourable change. The temperature \(T\) is a model parameter that controls noise: the higher the temperature, the more likely that energetically unfavourable copy attempts will succeed.
  4. Repeat steps 1-3 \(N\) times, where \(N\) equals the total number of pixels on the grid. After those \(N\) copy attempts (whether they succeed or not), the model time progresses with one Monte Carlo Step (MCS), the time unit of the CPM)

You can walk through these dynamics below; click "step" to perform the next step of the algorithm manually, or click the play symbol to automatically perform the steps at a faster pace. (Don't worry about the value of ΔH for now; that is discussed in the next section.)

2. Constructing the Hamiltonian

We have already talked briefly about the Hamiltonian \(H\), the global energy that the system tries to minimize. Typically, this Hamiltonian contains different terms to encourage different processes. For example:

  1. Adhesion: Pixels belonging to the same cell try to stick together; essentially, we put a penalty on every black pixel next to a gray pixel.
  2. Maintaining size and shape: Cells have a target volume and/or perimeter. They can deviate a little from that value by stretching or compressing, but they more or less maintain their size and membrane.

This would give the following Hamiltonian:

$$H_\text{tot} = H_\text{adhesion} + H_\text{volume} + H_\text{perimeter}$$
However, note that we never really use \(H\) itself; we only ever look at \(\Delta H\), the change in energy that would occur if the copy attempt were to succeed:
$$\Delta H_\text{tot} = \Delta H_\text{adhesion} + \Delta H_\text{volume} + \Delta H_\text{perimeter}$$

In the following, we'll see what these terms look like.

2.1 Adhesion

The adhesive energy is a contact energy that ensures that pixels from the same cell stay together. For a CPM with a single cell, where there are only two identities (0 for the background, 1 for the cell), this is defined as:

$$H_\text{adhesion} = \sum_{\substack{\text{neighbors } i,j \\ \text{cell}(i) \neq \text{cell}(j)}} J$$
where we sum over pairs of neighboring pixels \(i,j\) on the grid. In other words: we assign a positive energy (i.e. a penalty) to every pair of neighboring pixels that do not belong to the same cell. The parameter \(J\) controls the strength of this penalty.

To get \(\Delta H\) for a proposed copy attempt, we then compute:

$$\Delta H_\text{adhesion} = H_\text{adhesion,after copy} - H_\text{adhesion, now}$$

Below, these contacts are visualized; click "step()" to complete an MCS in the grid and to see the adhesion energy after the changes.

Note that the simulation start with random assignment of pixels to the "cell" or "background". Over time, pixels with the same identity tend to cluster together in space. This happens because the system tries to minimize its energy, and therefore its number of interfaces: the number of different cell contacts (and thus the energetic penalty) decreases when pixels of the same cell cluster together. Finally, as time progresses, the grid has only one identity left (it is then either empty, or completely filled with one cell)—after all, the best way to minimize contact energy is to have no interfaces at all!

The same principle applies when there is more than one cell, except now we have to define multiple contact energies \(J\): the interface between two different cells gets a different energy \((J_\text{cell,cell})\) than the interface between one of the cells and the background \((J_\text{cell,bg})\):

Again, after enough time passes, the grid ends up homogeneous because it is energetically beneficial to remove all the interfaces. With the tendency of the CPM to minimize the global energy, we eventually end up in this minimum energy, steady state scenario. If we wish to have real cells that don't just disappear, we need to expand our Hamiltonian.

2.2 Volume

To describe units that look more like cells, the Hamiltonian of a Cellular Potts Model (CPM) typically contains a volume term that ensures that cells roughly maintain their size (measured in number of pixels):

$$H_\text{volume} = \sum_{i \in \text{cells}} \lambda_\text{volume}(V_i - V_t)^2$$
For every cell, this terms assigns an energetic penalty that depends quadratically on how much its current volume \(V_i\) deviates from some target value \(V_t\) (which is a model parameter). A second parameter, \(\lambda_\text{volume}\), is used to further scale this energy.

Once again, what we actually use is the energy difference:

$$\Delta H_\text{volume} = H_\text{volume,after copy} - H_\text{volume, now}$$

This result in an elastic-like behavior. There is no complete conservation of mass because cells can deviate from their target volume by stretching or compressing a little, but these deviations remain small due to the quadratic penalty they carry with them. If a cell is already too large, it won't easily gain more pixels. And vice versa, if it is too small, it won't easily lose them.

The following example illustrates this for a simple cell with a target volume of 9 pixels and λvolume = 20:

2.3 Perimeter

To control the cell shape, we can add another term to the Hamiltonian that constrains the cells "perimeter" or circumference in a similar way as we did with the volume constraint:

$$H_\text{perimeter} = \sum_{i \in \text{cells}} \lambda_\text{perimeter}(P_i - P_t)^2$$
Again, this terms assigns an energetic penalty for each cell that depends quadratically on how much its current perimeter \(P_i\) deviates from some target value \(P_t\) (a model parameter). Here, the "perimeter" is measured in the same way as adhesion contacts earlier: for every one of the cell's border pixels, we count the number of neighbor pixels belonging to a different cell.

We then use the energy difference to bias copy attempts:

$$\Delta H_\text{perimeter} = H_\text{perimeter,after copy} - H_\text{perimeter, now}$$

This result in an elastic-like behavior of the cell's perimeter or "membrane". Cells with a small perimeter (compared to their volume) tend to stay round, while cells with a large perimeter have more flexible borders and a more dynamic cell shape.

The following example illustrates this for a simple cell with a target volume of 4 pixels, a target perimeter of 15 and λperimeter = 1:

2.4 Combining constraints

Combining the different constraints in one Hamiltonian, we get:

$$\Delta H_\text{tot} = \Delta H_\text{adhesion} + \Delta H_\text{volume} + \Delta H_\text{perimeter}$$

Note here that the different terms may oppose each other. For example, we have seen that for the adhesion term it is most favourable to let all but one cell disappear completely (thus eliminating all cell-cell contact interfaces). By contrast, the volume constraint actually prevents cells from disappearing. Thus, the final outcome is always the result of a balance between these different energies. We'll explore in the next part how these components interact.

3 Try It Yourself

Below, you can explore the basic CPM rules by toggling the different rules (adhesion, maintaining volume, and maintaining perimeter). You can also set the size of the volume or perimeter the cell tries to maintain.

Suggestions to try:

Summary

All in all, we have seen here how the CPM consists of a discrete grid combined with energy-based kinetics. The energy "rules" like adhesion, volume and perimeter interact to yield cell behaviour. The cell has dynamic borders and can kind of float around (especially if you give it a large perimeter), but there is no real "active" motion; that is the topic of a later tutorial.