Skip to content

Using default cell definition to get structure size in place of the first cell (which might not exist) - #348

Open
vincent-noel wants to merge 1 commit into
MathCancer:developmentfrom
vincent-noel:fix/no_cells_case
Open

Using default cell definition to get structure size in place of the first cell (which might not exist)#348
vincent-noel wants to merge 1 commit into
MathCancer:developmentfrom
vincent-noel:fix/no_cells_case

Conversation

@vincent-noel

Copy link
Copy Markdown
Collaborator

Hi guys, I'm back and I found a bug !
When you try to run a simulation with 0 cells, we get a segmentation fault when writing the output files.
Here I'm just checking if there are cells before calling add_PhysiCell_cells_to_open_xml_pugi_v2. Maybe we should also print something ?

@heberlr

heberlr commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator

Just a heads-up: this change will impact all applications that read PhysiCell cell simulation outputs. If all cells are eliminated, some applications—such as PhysiCell Studio, pcdataloader, and potentially others we may not be tracking—expect the following files to be present, even if they are empty:

  • output*_cells.mat
  • output*_attached_cells_graph.txt
  • output*_attached_cell_neighbor_graph.txt
  • output*_spring_cells_attached_cells_graph.txt

@MathCancer

MathCancer commented Jan 16, 2025 via email

Copy link
Copy Markdown
Owner

@vincent-noel

Copy link
Copy Markdown
Collaborator Author

I updated the PR, and now it is creating all the files, just empty.
The main problem was that (*all_cells)[0] was used to get the custom data of any cells. So I just added a check that there were cells every time this was used.

@drbergman drbergman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good solution to having no cells when writing output! Still produces all the files. I think I would prefer a solution that keeps the same label structure, but that seems like it would require storing the Death models and custom data structures outside of cell definitions. Ok, as I'm writing this I'm realizing that the Cell_Definition's still have phenotype and custom_data fields that should match with (*all_cells)[0]. Could we use those instead? Then we could avoid the structure of these files depending on the number of cells?

Comment thread modules/PhysiCell_MultiCellDS.cpp Outdated
Comment thread modules/PhysiCell_settings.cpp Outdated
@drbergman

Copy link
Copy Markdown
Collaborator

Ok, as I'm writing this I'm realizing that the Cell_Definition's still have phenotype and custom_data fields that should match with (*all_cells)[0].

And match in terms of the number of/names/units/etc of the parameters being saved

@vincent-noel

Copy link
Copy Markdown
Collaborator Author

Hummm, you're right. We should use the cell definition there. I'll have a look...

@drbergman drbergman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! cell_defaults is clearly the right struct for this.

@vincent-noel
vincent-noel force-pushed the fix/no_cells_case branch 3 times, most recently from f06e018 to b521628 Compare December 10, 2025 23:41
@vincent-noel

Copy link
Copy Markdown
Collaborator Author

Renaming this from "Only saving cells data when there are cells" to "Using default cell definition to get structure size in place of the first cell (which might not exist)"

@vincent-noel vincent-noel changed the title Only saving cells data when there are cells Using default cell definition to get structure size in place of the first cell (which might not exist) Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants