How to know cell types

how can I loop through different cells created after using divide() and know the cell types (mother or daughter). For example, differentiate and count the mother and daughter cells after some simulation time step, so that at nth time of division, after reaching around 200 cells, I can stop the cell division.

1 Like

Hi, just to clarify: Swarnika is asking how one can loop through all cells at each simulation step, and check if the cell belongs to a certain cell type or not. If so, a counter is increased. Cheers

1 Like

well, if that’s the case then, Swarnika you can create a “new” Agent class (that inherits BiodynaMo’s corresponding class) which has as member object an integer variable - you could use it as an indicator of the cell phenotype.

wrt the division aspect, you could also add an extra integer counter (that increments every time a cell multiplies) - this would mean you’d need to create a virtual function (that employs DivisiionEvent class) so that it updates this counter :wink:


1 Like

Thank you VasVav. Please, if you could also share a sample code for the same.

Also, I would like to share a code snippet from the Demo in BioDynamo Tutorials (from soma_clustering->validation_criterion.h) which can be of use to loop through all cells and extract the cell types:

rm->ForEachAgent([&](Agent* agent) {
if (auto* cell = dynamic_cast<MyCell*>(agent)) {
const auto& pos = cell->GetPosition();
auto type = cell->GetCellType();

  if ((fabs(pos[0] - 0.5) < sub_vol_max) &&
      (fabs(pos[1] - 0.5) < sub_vol_max) &&
      (fabs(pos[2] - 0.5) < sub_vol_max)) {
    pos_sub_vol[num_cells_sub_vol][0] = pos[0];
    pos_sub_vol[num_cells_sub_vol][1] = pos[1];
    pos_sub_vol[num_cells_sub_vol][2] = pos[2];
    types_sub_vol[num_cells_sub_vol] = type;



1 Like