Skip to content

Validate custom data (and a bit more) - #447

Open
rheiland wants to merge 14 commits into
MathCancer:developmentfrom
rheiland:validate-custom-data
Open

rheiland wants to merge 14 commits into
MathCancer:developmentfrom
rheiland:validate-custom-data

Conversation

@rheiland

@rheiland rheiland commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

This addresses a long-standing issue related to having mismatched custom_data variables in different cell_definition blocks of a .xml config file. Recall (or convince yourself) that each cell_definition must have defined the very same custom_data. It also touches on the related issue of using hierarchical cell_definitions with the parent_type attribute. For example, if a cell_definition is defined with a parent_type, PhysiCell will automatically create its custom_data to match the parent. Confusion (and errors) can arise when a user tries to add another variable to the custom_data block of just one cell_definition, but not all of them.

The parent_type attribute may be considered legacy, but it is still very much in use, in spite of PhysiCell Studio basically eliminating it when it saves the .xml model. Also, we still have users editing the .xml by hand and not using the Studio at all.

The primary contribution of this PR is to add a validation check for having the very same custom_data in all cell_definitions, regardless of whether they are hierarchical or not. If they fail this validation, the simulation prints an error message and exits. (For anyone asking why the Studio doesn't allow reading in and saving a hierarchical config file, one key reason is that a hierarchical model is not unique. There are pros and cons for both hierarchical and "flat", but for now I still prefer that the Studio save a flat config file. It may increase its size considerably, but it will be very explicit).

To help facilitate the custom_data validation, we added some relevant scripts to /beta, e.g., check_custom_data*.py. Going a bit further, we also added a script, xml_hier2flat.py, which attempts to convert a hierarchical config file to a flatttened one (and thereby usable for the Studio).

Related to model validation, we also added a schema.xsd file and check_schema_samples.py script. This should be considered a future-looking option of validating a model's definition. This captures a lot of work that we've done with undergrad students over the past year.

To help make sense of these new additions to /beta, the PR adds a README.md there to help explain all the scripts (and related files) and organize them, functionally.

During testing, it was discovered that some of the physimess config files fail the custom_data validation. I have not fixed those but if @vincent-noel or @marcorusc agree that they need fixed, I could offer to do that as part of this PR. As it stands, they will fail when running the github actions tests with this PR. And related to physimess, I would like to propose that the "default" config file, sample_projects/physimess/config/PhysiCell_settings.xml be made a duplicate of one of the (fixed) existing submodels. Currently, it too is invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant