DC initialization from file - #357
Open
drbergman wants to merge 5 commits into
Open
Conversation
provide a CSV file with similar structure to the substrate ICs csv header row: x,y,z,<substrate_01>,<substrate_02>,... where the list of substrates need not be all the substrates, only those with DCs being set each subsequent row is: <x_coord>,<y_coord>,<z_coord>,<val_01>,<val_02>,... where the coords must be specified and the vals can either be empty (<val_01>,,<val_03>,...) or a number If empty, then nothing chagnes for the substrate in that column at that voxel If a number, then the DC activation for that voxel-substrate pairing is set to the number
drbergman
force-pushed
the
feature-dc-init-file
branch
from
February 2, 2025 11:31
0cec57e to
c7860b4
Compare
There was a problem hiding this comment.
Copilot reviewed 9 out of 16 changed files in this pull request and generated no comments.
Files not reviewed (7)
- Makefile: Language not supported
- sample_projects/Makefile-default: Language not supported
- sample_projects/dirichlet_from_file/Makefile: Language not supported
- sample_projects/dirichlet_from_file/config/PhysiCell_settings.xml: Language not supported
- sample_projects/dirichlet_from_file/config/cell_rules.csv: Language not supported
- sample_projects/dirichlet_from_file/config/cells.csv: Language not supported
- sample_projects/dirichlet_from_file/config/dcs.csv: Language not supported
Comments suppressed due to low confidence (1)
BioFVM/BioFVM_microenvironment.cpp:1735
- The function update_dirichlet_node is invoked here but it is not declared or defined in the provided diffs. Consider replacing this call with a defined function such as set_substrate_dirichlet_activation (or implementing update_dirichlet_node) to ensure the dirichlet condition is updated correctly.
microenvironment.update_dirichlet_node(voxel_ind, substrate_indices[ci], data[ci + 3]);
drbergman
commented
May 22, 2025
drbergman
commented
May 22, 2025
drbergman
commented
May 22, 2025
drbergman
commented
May 22, 2025
drbergman
commented
May 22, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR introduces functionality for initializing Dirichlet conditions from a CSV file. Key changes include updates to the main simulation and configuration files, new parsing routines for CSV‐based Dirichlet conditions in the BioFVM module, and corresponding build system modifications.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sample_projects/dirichlet_from_file/main.cpp | Updates to main simulation code to invoke DC initialization |
| sample_projects/dirichlet_from_file/custom_modules/.h,.cpp | Custom module updates with minimal changes |
| config/*.csv, config/PhysiCell_settings.xml | New configuration files (CSV and XML) supporting DC initialization |
| Makefile, Makefile-default | Build files updated to support the new project configuration |
| modules/PhysiCell_settings.cpp | Added XML parsing logic for Dirichlet condition file settings |
| BioFVM/BioFVM_vector.{h,cpp} | New function (dirichlet_csv_to_vector) to parse CSV rows for DC data |
| BioFVM/BioFVM_microenvironment.{h,cpp} | Updates and new functions for setting and loading Dirichlet conditions |
#70) Merging development into feature-dc-init-file dropped both trim_cr calls from load_initial_conditions_from_csv. The two functions are near-identical copies, so the resolution landed development's additions on the dirichlet copy and kept the feature branch's untouched version of the substrate copy. A CRLF substrates.csv with a header therefore fails again with "Substrate <name> not found in the BioFVM microenvironment", since the final column name carries the trailing carriage return. Both csv row processors also indexed their parsed row without consulting its length, which is out of bounds for a malformed row: - a blank or whitespace-only line leaves csv_to_vector's output empty, so data[0..2] reads past the end (and the churn loop itself walks past the terminator looking for a digit). - substrate_indices is sized from the header, so a short row runs data[ci + 3] off the end. - dirichlet_csv_to_vector writes is_missing[ind] and data[ind] once per comma with no bound, so a row with more fields than the header established writes past the end of both vectors. Blank lines are now skipped in both, matching load_cells_csv_v1 and process_csv_v2_line, and a row whose column count disagrees with the header is a hard error rather than a silent partial write. Ordering the substrate guard ahead of the existing warning also stops data.size() - 3 from underflowing on a short row. dirichlet_csv_to_vector additionally treats a whitespace-only field as omitted rather than feeding it to std::stod, and reports a field that is not a complete number instead of letting std::stod throw uncaught or silently accepting "1.5abc" as 1.5. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
drbergman
commented
Aug 21, 2026
Collaborator
Author
|
After merging this and #386, there is some opportunity to reduce the codebase through DRY principles. Not worth stacking them here, so will just wait on that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
provide a CSV file with similar structure to the substrate ICs csv header row: x,y,z,<substrate_01>,<substrate_02>,... where the list of substrates need not be all the substrates, only those with DCs being set. Each subsequent row is:
where the coords must be specified and the vals can either be empty (<val_01>,,<val_03>,...) or a number
If the XML sets DCs, this will overwrite those values for which a number is supplied in the CSV. In other words, if a voxel on the boundary has a DC set to ON by the XML, parsing the CSV file can only change the value of the DC, not turn it OFF.
a sample project in
sample_projects/dirichlet_from_fileis provided. try it withmake dirichlet-from-file-sample