From 6438e919d077cbc879f095affd77c7df34b3e38e Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sat, 13 Jul 2024 16:54:16 -0400 Subject: [PATCH 01/12] custom division, lineage --- core/PhysiCell_cell.cpp | 22 ++ core/PhysiCell_cell.h | 2 + modules/PhysiCell_MultiCellDS.cpp | 15 + sample_projects/custom_division/Makefile | 314 ++++++++++++++++ .../config/PhysiCell_settings.xml | 349 ++++++++++++++++++ .../custom_division/config/cell_rules.csv | 0 .../custom_division/config/cells.csv | 5 + .../custom_division/custom_modules/custom.cpp | 232 ++++++++++++ .../custom_division/custom_modules/custom.h | 93 +++++ sample_projects/custom_division/main.cpp | 254 +++++++++++++ 10 files changed, 1286 insertions(+) create mode 100644 sample_projects/custom_division/Makefile create mode 100644 sample_projects/custom_division/config/PhysiCell_settings.xml create mode 100644 sample_projects/custom_division/config/cell_rules.csv create mode 100644 sample_projects/custom_division/config/cells.csv create mode 100644 sample_projects/custom_division/custom_modules/custom.cpp create mode 100644 sample_projects/custom_division/custom_modules/custom.h create mode 100644 sample_projects/custom_division/main.cpp diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 32270263c..2496ddf90 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -418,6 +418,7 @@ Cell::Cell() is_movable = true; is_out_of_domain = false; + generation = 0; displacement.resize(3,0.0); // state? assign_orientation(); @@ -563,6 +564,9 @@ Cell* Cell::divide( ) Cell* child = create_cell(functions.instantiate_cell); child->copy_data( this ); + // lineage tracking + generation = generation + 1; // this (parent) cell has its generation incremented + child->generation = generation; // its daughter cell has the same generation child->copy_function_pointers(this); child->parameters = parameters; @@ -649,6 +653,11 @@ Cell* Cell::divide( ) child->state.damage = 0.0; child->state.total_attack_time = 0.0; + //rwh + // if( this->functions.cell_division_function && pC->is_out_of_domain == false ) + if( this->functions.cell_division_function ) + { this->functions.cell_division_function( this, child); } + return child; } @@ -1306,6 +1315,7 @@ void Cell::ingest_cell( Cell* pCell_to_eat ) pCell_to_eat->functions.custom_cell_rule = NULL; pCell_to_eat->functions.update_phenotype = NULL; pCell_to_eat->functions.contact_function = NULL; + pCell_to_eat->functions.cell_division_function = NULL; // should set volume fuction to NULL too! pCell_to_eat->functions.volume_update_function = NULL; @@ -1531,6 +1541,7 @@ void Cell::fuse_cell( Cell* pCell_to_fuse ) pCell_to_fuse->functions.custom_cell_rule = NULL; pCell_to_fuse->functions.update_phenotype = NULL; pCell_to_fuse->functions.contact_function = NULL; + pCell_to_fuse->functions.cell_division_function = NULL; pCell_to_fuse->functions.volume_update_function = NULL; // remove all adhesions @@ -1570,6 +1581,7 @@ void Cell::lyse_cell( void ) functions.custom_cell_rule = NULL; functions.update_phenotype = NULL; functions.contact_function = NULL; + functions.cell_division_function = NULL; // remove all adhesions @@ -1660,6 +1672,14 @@ void display_ptr_as_bool( void (*ptr)(Cell*,Phenotype&,Cell*,Phenotype&,double), return; } +void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os ) //rwh +{ + if( ptr ) + { os << "true"; return; } + os << "false"; + return; +} + void display_cell_definitions( std::ostream& os ) { for( int n=0; n < cell_definitions_by_index.size() ; n++ ) @@ -1743,6 +1763,8 @@ void display_cell_definitions( std::ostream& os ) os << std::endl; os << "\t\t contact function: "; display_ptr_as_bool( pCF->contact_function , std::cout ); os << std::endl; + os << "\t\t cell division function: "; display_ptr_as_bool( pCF->cell_division_function , std::cout ); + os << std::endl; // summarize motility diff --git a/core/PhysiCell_cell.h b/core/PhysiCell_cell.h index 5919e3fac..27f4906eb 100644 --- a/core/PhysiCell_cell.h +++ b/core/PhysiCell_cell.h @@ -188,6 +188,8 @@ class Cell : public Basic_Agent bool is_out_of_domain; bool is_movable; + + int generation; // for lineage tracking void flag_for_division( void ); // done void flag_for_removal( void ); // done diff --git a/modules/PhysiCell_MultiCellDS.cpp b/modules/PhysiCell_MultiCellDS.cpp index f65369e1e..6d9a6afba 100644 --- a/modules/PhysiCell_MultiCellDS.cpp +++ b/modules/PhysiCell_MultiCellDS.cpp @@ -890,6 +890,18 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std:: data_start_indices.push_back( index ); cell_data_size += size; index += size; + + // generation + name = "generation"; + size = 1; + units="none"; + data_names.push_back( name ); + data_units.push_back(units); + data_sizes.push_back( size ); + data_start_indices.push_back( index ); + cell_data_size += size; + index += size; + // name = "position"; size = 3; @@ -1754,6 +1766,9 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std:: // name = "ID"; dTemp = (double) pCell->ID; std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp ); + // name = "generation"; + dTemp = (double) pCell->generation; + std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp ); // name = "position"; NOTE very different syntax for writing vectors! std::fwrite( pCell->position.data() , sizeof(double) , 3 , fp ); // name = "total_volume"; diff --git a/sample_projects/custom_division/Makefile b/sample_projects/custom_division/Makefile new file mode 100644 index 000000000..e90a9966f --- /dev/null +++ b/sample_projects/custom_division/Makefile @@ -0,0 +1,314 @@ +VERSION := $(shell grep . VERSION.txt | cut -f1 -d:) +PROGRAM_NAME := project + +CC := g++ +# CC := g++-mp-7 # typical macports compiler name +# CC := g++-7 # typical homebrew compiler name + +# Check for environment definitions of compiler +# e.g., on CC = g++-7 on OSX +ifdef PHYSICELL_CPP + CC := $(PHYSICELL_CPP) +endif + +ARCH := native # best auto-tuning +# ARCH := core2 # a reasonably safe default for most CPUs since 2007 +# ARCH := corei7 +# ARCH := corei7-avx # earlier i7 +# ARCH := core-avx-i # i7 ivy bridge or newer +# ARCH := core-avx2 # i7 with Haswell or newer +# ARCH := nehalem +# ARCH := westmere +# ARCH := sandybridge # circa 2011 +# ARCH := ivybridge # circa 2012 +# ARCH := haswell # circa 2013 +# ARCH := broadwell # circa 2014 +# ARCH := skylake # circa 2015 +# ARCH := bonnell +# ARCH := silvermont +# ARCH := skylake-avx512 +# ARCH := nocona #64-bit pentium 4 or later + +# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 +CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 + +ifeq ($(OS),Windows_NT) +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + UNAME_P := $(shell uname -p) + var := $(shell which $(CC) | xargs file) + ifeq ($(lastword $(var)),arm64) + CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11 + endif + endif +endif + +COMPILE_COMMAND := $(CC) $(CFLAGS) + +BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \ +BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o + +PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \ +PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \ +PhysiCell_signal_behavior.o PhysiCell_rules.o + +PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \ +PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o + +# put your custom objects here (they should be in the custom_modules directory) + +PhysiCell_custom_module_OBJECTS := custom.o + +pugixml_OBJECTS := pugixml.o + +PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) +ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) + +# compile the project + +all: main.cpp $(ALL_OBJECTS) + $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp + make name + +name: + @echo "" + @echo "Executable name is" $(PROGRAM_NAME) + @echo "" + +# PhysiCell core components + +PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp + +PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp + +PhysiCell_cell.o: ./core/PhysiCell_cell.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp + +PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp + +PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp + +PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp + +PhysiCell_custom.o: ./core/PhysiCell_custom.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp + +PhysiCell_constants.o: ./core/PhysiCell_constants.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp + +PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp + +PhysiCell_rules.o: ./core/PhysiCell_rules.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_rules.cpp + +# BioFVM core components (needed by PhysiCell) + +BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp + +BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp + +BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp + +BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp + +BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp + +BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp + +BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp + +BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp + +BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp + +pugixml.o: ./BioFVM/pugixml.cpp + $(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp + +# standard PhysiCell modules + +PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp + +PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp + +PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp + +PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp + +PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp + +PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp + +PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp + +PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp + +# user-defined PhysiCell modules + +custom.o: ./custom_modules/custom.cpp + $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp + +# cleanup + +reset: + rm -f *.cpp + cp ./sample_projects/Makefile-default Makefile + rm -f ./custom_modules/* + touch ./custom_modules/empty.txt + touch ALL_CITATIONS.txt + touch ./core/PhysiCell_cell.cpp + rm ALL_CITATIONS.txt + cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml + touch ./config/empty.csv + rm -f ./config/*.csv + +clean: + rm -f *.o + rm -f $(PROGRAM_NAME)* + +data-cleanup: + rm -rf ./output + mkdir ./output + touch ./output/empty.txt + +# archival + +checkpoint: + zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* + +zip: + zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.zip $$(date +%b_%d_%Y_%H%M).zip + cp latest.zip VERSION_$(VERSION).zip + mv *.zip archives/ + +tar: + tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.tar $$(date +%b_%d_%Y_%H%M).tar + cp latest.tar VERSION_$(VERSION).tar + mv *.tar archives/ + +unzip: + cp ./archives/latest.zip . + unzip latest.zip + +untar: + cp ./archives/latest.tar . + tar -xzf latest.tar + +# easier animation + +FRAMERATE := 24 +OUTPUT := output + +jpeg: + @magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt + @magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt + @expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt + @expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt + @echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt + @magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg + rm -f __H*.txt __W*.txt __resize.txt + +gif: + magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif + +movie: + ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4 + +# upgrade rules + +SOURCE := PhysiCell_upgrade.zip +get-upgrade: + @echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt + @echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt + rm -f VER.txt + $$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip) + rm -f DL_FILE.txt + +PhysiCell_upgrade.zip: + make get-upgrade + +upgrade: $(SOURCE) + unzip $(SOURCE) PhysiCell/VERSION.txt + mv -f PhysiCell/VERSION.txt . + unzip $(SOURCE) PhysiCell/core/* + cp -r PhysiCell/core/* core + unzip $(SOURCE) PhysiCell/modules/* + cp -r PhysiCell/modules/* modules + unzip $(SOURCE) PhysiCell/sample_projects/* + cp -r PhysiCell/sample_projects/* sample_projects + unzip $(SOURCE) PhysiCell/BioFVM/* + cp -r PhysiCell/BioFVM/* BioFVM + unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf + mv -f PhysiCell/documentation/User_Guide.pdf documentation + rm -f -r PhysiCell + rm -f $(SOURCE) + +# use: make save PROJ=your_project_name +PROJ := my_project + +save: + echo "Saving project as $(PROJ) ... " + mkdir -p ./user_projects + mkdir -p ./user_projects/$(PROJ) + mkdir -p ./user_projects/$(PROJ)/custom_modules + mkdir -p ./user_projects/$(PROJ)/config + cp main.cpp ./user_projects/$(PROJ) + cp Makefile ./user_projects/$(PROJ) + cp VERSION.txt ./user_projects/$(PROJ) + cp ./config/* ./user_projects/$(PROJ)/config + cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules + +load: + echo "Loading project from $(PROJ) ... " + cp ./user_projects/$(PROJ)/main.cpp . + cp ./user_projects/$(PROJ)/Makefile . + cp ./user_projects/$(PROJ)/config/* ./config/ + cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/ + +pack: + @echo " " + @echo "Preparing project $(PROJ) for sharing ... " + @echo " " + cd ./user_projects && zip -r $(PROJ).zip $(PROJ) + @echo " " + @echo "Share ./user_projects/$(PROJ).zip ... " + @echo "Other users can unzip $(PROJ).zip in their ./user_projects, compile, and run." + @echo " " + +unpack: + @echo " " + @echo "Preparing shared project $(PROJ).zip for use ... " + @echo " " + cd ./user_projects && unzip $(PROJ).zip + @echo " " + @echo "Load this project via make load PROJ=$(PROJ) ... " + @echo " " + +list-user-projects: + @echo "user projects::" + @cd ./user_projects && ls -dt1 * | grep . | sed 's!empty.txt!!' diff --git a/sample_projects/custom_division/config/PhysiCell_settings.xml b/sample_projects/custom_division/config/PhysiCell_settings.xml new file mode 100644 index 000000000..8987e89b6 --- /dev/null +++ b/sample_projects/custom_division/config/PhysiCell_settings.xml @@ -0,0 +1,349 @@ + + + + -200 + 200 + -200 + 200 + -10 + 10 + 20 + 20 + 20 + true + + + + 5760.0 + min + micron + 0.01 + 0.1 + 6 + + + + 1 + + + + output + + 30 + true + + + 30 + true + + oxygen + + + + + + false + + + + + false + true + false + + + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + true + true + + ./config/initial.mat + + + ./config/dirichlet.mat + + + + + + + + + + 0.001 + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 1.11667e-2 + 8.33333e-4 + 5.33333e-5 + 2.16667e-3 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0.4 + 10.0 + 1.25 + + 1 + 1 + + + 1.8 + 15.12 + + 0.01 + 0.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + + + + + + + 0 + 1 + 10 + 0 + + + + 0 + + 0.0 + 0 + + + 0.0 + 0 + + 1 + + 0.0 + 0 + + + + + 0.0 + 0 + + + + + 1.0 + + + + + + + 0.00072 + + + + + 0 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 1.11667e-2 + 8.33333e-4 + 5.33333e-5 + 2.16667e-3 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0.4 + 10.0 + 1.25 + + 1 + 1 + + + 1.8 + 15.12 + + 0.01 + 0.0 + 0.0 + + + 0.05 + 0 + .5 + + true + true + + true + oxygen + 1 + + + false + false + + 0.0 + + + + + + + 0 + 1 + 10 + 0 + + + + 0 + + 0 + 0 + + + 0 + 0 + + 1 + + 0 + 0 + + + + + 0 + 0 + + + + + 1.0 + + + + + + + ./config + cells.csv + + + + + + + config + rules.csv + + + + + + 0 + 0 + + diff --git a/sample_projects/custom_division/config/cell_rules.csv b/sample_projects/custom_division/config/cell_rules.csv new file mode 100644 index 000000000..e69de29bb diff --git a/sample_projects/custom_division/config/cells.csv b/sample_projects/custom_division/config/cells.csv new file mode 100644 index 000000000..88d88f63f --- /dev/null +++ b/sample_projects/custom_division/config/cells.csv @@ -0,0 +1,5 @@ +x,y,z,type,volume,cycle entry,custom:GFP,custom:sample +-80.,80.,0.0,default +80.,80.,0.0,default +-80.,-80.,0.0,default +80.,-80.,0.0,default diff --git a/sample_projects/custom_division/custom_modules/custom.cpp b/sample_projects/custom_division/custom_modules/custom.cpp new file mode 100644 index 000000000..fbeab09ca --- /dev/null +++ b/sample_projects/custom_division/custom_modules/custom.cpp @@ -0,0 +1,232 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include "./custom.h" + +void create_cell_types( void ) +{ + // set the random seed + SeedRandom( parameters.ints("random_seed") ); + + /* + Put any modifications to default cell definition here if you + want to have "inherited" by other cell types. + + This is a good place to set default functions. + */ + + initialize_default_cell_definition(); + cell_defaults.phenotype.secretion.sync_to_microenvironment( µenvironment ); + + cell_defaults.functions.volume_update_function = standard_volume_update_function; + cell_defaults.functions.update_velocity = standard_update_cell_velocity; + + cell_defaults.functions.update_migration_bias = NULL; + cell_defaults.functions.update_phenotype = NULL; // update_cell_and_death_parameters_O2_based; + cell_defaults.functions.custom_cell_rule = NULL; + cell_defaults.functions.contact_function = NULL; + cell_defaults.functions.cell_division_function = NULL; + + cell_defaults.functions.add_cell_basement_membrane_interactions = NULL; + cell_defaults.functions.calculate_distance_to_membrane = NULL; + + /* + This parses the cell definitions in the XML config file. + */ + + initialize_cell_definitions_from_pugixml(); + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + build_cell_definitions_maps(); + + /* + This intializes cell signal and response dictionaries + */ + + setup_signal_behavior_dictionaries(); + + /* + Cell rule definitions + */ + + setup_cell_rules(); + + /* + Put any modifications to individual cell definitions here. + + This is a good place to set custom functions. + */ + + cell_defaults.functions.update_phenotype = phenotype_function; + cell_defaults.functions.custom_cell_rule = custom_function; + cell_defaults.functions.contact_function = contact_function; + cell_defaults.functions.cell_division_function = custom_division_function; + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + display_cell_definitions( std::cout ); + + return; +} + +void setup_microenvironment( void ) +{ + // set domain parameters + + // put any custom code to set non-homogeneous initial conditions or + // extra Dirichlet nodes here. + + // initialize BioFVM + + initialize_microenvironment(); + + return; +} + +void setup_tissue( void ) +{ + double Xmin = microenvironment.mesh.bounding_box[0]; + double Ymin = microenvironment.mesh.bounding_box[1]; + double Zmin = microenvironment.mesh.bounding_box[2]; + + double Xmax = microenvironment.mesh.bounding_box[3]; + double Ymax = microenvironment.mesh.bounding_box[4]; + double Zmax = microenvironment.mesh.bounding_box[5]; + + if( default_microenvironment_options.simulate_2D == true ) + { + Zmin = 0.0; + Zmax = 0.0; + } + + double Xrange = Xmax - Xmin; + double Yrange = Ymax - Ymin; + double Zrange = Zmax - Zmin; + + // create some of each type of cell + + Cell* pC; + + for( int k=0; k < cell_definitions_by_index.size() ; k++ ) + { + Cell_Definition* pCD = cell_definitions_by_index[k]; + std::cout << "Placing cells of type " << pCD->name << " ... " << std::endl; + for( int n = 0 ; n < parameters.ints("number_of_cells") ; n++ ) + { + std::vector position = {0,0,0}; + position[0] = Xmin + UniformRandom()*Xrange; + position[1] = Ymin + UniformRandom()*Yrange; + position[2] = Zmin + UniformRandom()*Zrange; + + pC = create_cell( *pCD ); + pC->assign_position( position ); + } + } + std::cout << std::endl; + + // load cells from your CSV file (if enabled) + load_cells_from_pugixml(); + set_parameters_from_distributions(); + + return; +} + +std::vector my_coloring_function( Cell* pCell ) +{ return paint_by_number_cell_coloring(pCell); } + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ) +{ return; } + +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ) +{ return; } + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ) +{ return; } + +void custom_division_function( Cell* pCell1, Cell* pCell2 ) +{ + static int idx_default = find_cell_definition_index("default"); + static int idx_ctype1 = find_cell_definition_index("ctype1"); + std::cout << __FUNCTION__ << ": " << PhysiCell_globals.current_time << ": cell IDs= " << pCell1->ID << ", " << pCell2->ID << std::endl; + + // Asymmetric division + if (UniformRandom() < 0.5) + { + pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_default] ); + } + else + { + pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_ctype1] ); + } + + return; +} \ No newline at end of file diff --git a/sample_projects/custom_division/custom_modules/custom.h b/sample_projects/custom_division/custom_modules/custom.h new file mode 100644 index 000000000..7e6b0f044 --- /dev/null +++ b/sample_projects/custom_division/custom_modules/custom.h @@ -0,0 +1,93 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include "../core/PhysiCell.h" +#include "../modules/PhysiCell_standard_modules.h" + +using namespace BioFVM; +using namespace PhysiCell; + +// setup functions to help us along + +void create_cell_types( void ); +void setup_tissue( void ); + +// set up the BioFVM microenvironment +void setup_microenvironment( void ); + +// custom pathology coloring function + +std::vector my_coloring_function( Cell* ); + +// custom functions can go here + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ); +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ); + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ); + +void custom_division_function( Cell* pCell1, Cell* pCell2 ); diff --git a/sample_projects/custom_division/main.cpp b/sample_projects/custom_division/main.cpp new file mode 100644 index 000000000..2f7e98c75 --- /dev/null +++ b/sample_projects/custom_division/main.cpp @@ -0,0 +1,254 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2022, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "./core/PhysiCell.h" +#include "./modules/PhysiCell_standard_modules.h" + +// put custom code modules here! + +#include "./custom_modules/custom.h" + +using namespace BioFVM; +using namespace PhysiCell; + +int main( int argc, char* argv[] ) +{ + // load and parse settings file(s) + + bool XML_status = false; + char copy_command [1024]; + if( argc > 1 ) + { + XML_status = load_PhysiCell_config_file( argv[1] ); + sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() ); + } + else + { + XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" ); + sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() ); + } + if( !XML_status ) + { exit(-1); } + + // copy config file to output directry + system( copy_command ); + + // OpenMP setup + omp_set_num_threads(PhysiCell_settings.omp_num_threads); + + // time setup + std::string time_units = "min"; + + /* Microenvironment setup */ + + setup_microenvironment(); // modify this in the custom code + + /* PhysiCell setup */ + + // set mechanics voxel size, and match the data structure to BioFVM + double mechanics_voxel_size = 30; + Cell_Container* cell_container = create_cell_container_for_microenvironment( microenvironment, mechanics_voxel_size ); + + /* Users typically start modifying here. START USERMODS */ + + create_cell_types(); + + setup_tissue(); + + /* Users typically stop modifying here. END USERMODS */ + + // set MultiCellDS save options + + set_save_biofvm_mesh_as_matlab( true ); + set_save_biofvm_data_as_matlab( true ); + set_save_biofvm_cell_data( true ); + set_save_biofvm_cell_data_as_custom_matlab( true ); + + // save a simulation snapshot + + char filename[1024]; + sprintf( filename , "%s/initial" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + // save a quick SVG cross section through z = 0, after setting its + // length bar to 200 microns + + PhysiCell_SVG_options.length_bar = 200; + + // for simplicity, set a pathology coloring function + + std::vector (*cell_coloring_function)(Cell*) = my_coloring_function; + std::string (*substrate_coloring_function)(double, double, double) = paint_by_density_percentage; + + sprintf( filename , "%s/initial.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function ); + + sprintf( filename , "%s/legend.svg" , PhysiCell_settings.folder.c_str() ); + create_plot_legend( filename , cell_coloring_function ); + + display_citations(); + + // set the performance timers + + BioFVM::RUNTIME_TIC(); + BioFVM::TIC(); + + std::ofstream report_file; + if( PhysiCell_settings.enable_legacy_saves == true ) + { + sprintf( filename , "%s/simulation_report.txt" , PhysiCell_settings.folder.c_str() ); + + report_file.open(filename); // create the data log file + report_file<<"simulated time\tnum cells\tnum division\tnum death\twall time"<update_all_cells( PhysiCell_globals.current_time ); + + /* + Custom add-ons could potentially go here. + */ + + PhysiCell_globals.current_time += diffusion_dt; + } + + if( PhysiCell_settings.enable_legacy_saves == true ) + { + log_output(PhysiCell_globals.current_time, PhysiCell_globals.full_output_index, microenvironment, report_file); + report_file.close(); + } + } + catch( const std::exception& e ) + { // reference to the base of a polymorphic object + std::cout << e.what(); // information from length_error printed + } + + // save a final simulation snapshot + + sprintf( filename , "%s/final" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + sprintf( filename , "%s/final.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot(filename, microenvironment, 0.0, PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function); + + // timer + + std::cout << std::endl << "Total simulation runtime: " << std::endl; + BioFVM::display_stopwatch_value( std::cout , BioFVM::runtime_stopwatch_value() ); + + return 0; +} From 6caac3ce4c00c8214ffdaf57ecd2da7febf74da8 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sun, 14 Jul 2024 09:23:12 -0400 Subject: [PATCH 02/12] add cell_division_function --- core/PhysiCell_phenotype.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/PhysiCell_phenotype.h b/core/PhysiCell_phenotype.h index 106b567a6..1b4ea59c2 100644 --- a/core/PhysiCell_phenotype.h +++ b/core/PhysiCell_phenotype.h @@ -496,6 +496,8 @@ class Cell_Functions void (*contact_function)(Cell* pMyself, Phenotype& my_phenotype, Cell* pOther, Phenotype& other_phenotype, double dt ); + + void (*cell_division_function)(Cell* pCell1, Cell* pCell2 ); /* prototyping / beta in 1.5.0 */ /* From 5077aad6a66a4ab7d20e287180ddfa405b797fa9 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sun, 14 Jul 2024 17:15:21 -0400 Subject: [PATCH 03/12] update --- .../sample_division_lineage/Makefile | 314 ++++++++++++++++ .../config/PhysiCell_settings.xml | 349 ++++++++++++++++++ .../config/cell_rules.csv | 0 .../sample_division_lineage/config/cells.csv | 3 + .../custom_modules/custom.cpp | 236 ++++++++++++ .../custom_modules/custom.h | 93 +++++ .../sample_division_lineage/main.cpp | 254 +++++++++++++ 7 files changed, 1249 insertions(+) create mode 100644 user_projects/sample_division_lineage/Makefile create mode 100644 user_projects/sample_division_lineage/config/PhysiCell_settings.xml create mode 100644 user_projects/sample_division_lineage/config/cell_rules.csv create mode 100644 user_projects/sample_division_lineage/config/cells.csv create mode 100644 user_projects/sample_division_lineage/custom_modules/custom.cpp create mode 100644 user_projects/sample_division_lineage/custom_modules/custom.h create mode 100644 user_projects/sample_division_lineage/main.cpp diff --git a/user_projects/sample_division_lineage/Makefile b/user_projects/sample_division_lineage/Makefile new file mode 100644 index 000000000..e90a9966f --- /dev/null +++ b/user_projects/sample_division_lineage/Makefile @@ -0,0 +1,314 @@ +VERSION := $(shell grep . VERSION.txt | cut -f1 -d:) +PROGRAM_NAME := project + +CC := g++ +# CC := g++-mp-7 # typical macports compiler name +# CC := g++-7 # typical homebrew compiler name + +# Check for environment definitions of compiler +# e.g., on CC = g++-7 on OSX +ifdef PHYSICELL_CPP + CC := $(PHYSICELL_CPP) +endif + +ARCH := native # best auto-tuning +# ARCH := core2 # a reasonably safe default for most CPUs since 2007 +# ARCH := corei7 +# ARCH := corei7-avx # earlier i7 +# ARCH := core-avx-i # i7 ivy bridge or newer +# ARCH := core-avx2 # i7 with Haswell or newer +# ARCH := nehalem +# ARCH := westmere +# ARCH := sandybridge # circa 2011 +# ARCH := ivybridge # circa 2012 +# ARCH := haswell # circa 2013 +# ARCH := broadwell # circa 2014 +# ARCH := skylake # circa 2015 +# ARCH := bonnell +# ARCH := silvermont +# ARCH := skylake-avx512 +# ARCH := nocona #64-bit pentium 4 or later + +# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 +CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 + +ifeq ($(OS),Windows_NT) +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + UNAME_P := $(shell uname -p) + var := $(shell which $(CC) | xargs file) + ifeq ($(lastword $(var)),arm64) + CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11 + endif + endif +endif + +COMPILE_COMMAND := $(CC) $(CFLAGS) + +BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \ +BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o + +PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \ +PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \ +PhysiCell_signal_behavior.o PhysiCell_rules.o + +PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \ +PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o + +# put your custom objects here (they should be in the custom_modules directory) + +PhysiCell_custom_module_OBJECTS := custom.o + +pugixml_OBJECTS := pugixml.o + +PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) +ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) + +# compile the project + +all: main.cpp $(ALL_OBJECTS) + $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp + make name + +name: + @echo "" + @echo "Executable name is" $(PROGRAM_NAME) + @echo "" + +# PhysiCell core components + +PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp + +PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp + +PhysiCell_cell.o: ./core/PhysiCell_cell.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp + +PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp + +PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp + +PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp + +PhysiCell_custom.o: ./core/PhysiCell_custom.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp + +PhysiCell_constants.o: ./core/PhysiCell_constants.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp + +PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp + +PhysiCell_rules.o: ./core/PhysiCell_rules.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_rules.cpp + +# BioFVM core components (needed by PhysiCell) + +BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp + +BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp + +BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp + +BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp + +BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp + +BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp + +BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp + +BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp + +BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp + +pugixml.o: ./BioFVM/pugixml.cpp + $(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp + +# standard PhysiCell modules + +PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp + +PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp + +PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp + +PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp + +PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp + +PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp + +PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp + +PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp + +# user-defined PhysiCell modules + +custom.o: ./custom_modules/custom.cpp + $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp + +# cleanup + +reset: + rm -f *.cpp + cp ./sample_projects/Makefile-default Makefile + rm -f ./custom_modules/* + touch ./custom_modules/empty.txt + touch ALL_CITATIONS.txt + touch ./core/PhysiCell_cell.cpp + rm ALL_CITATIONS.txt + cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml + touch ./config/empty.csv + rm -f ./config/*.csv + +clean: + rm -f *.o + rm -f $(PROGRAM_NAME)* + +data-cleanup: + rm -rf ./output + mkdir ./output + touch ./output/empty.txt + +# archival + +checkpoint: + zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* + +zip: + zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.zip $$(date +%b_%d_%Y_%H%M).zip + cp latest.zip VERSION_$(VERSION).zip + mv *.zip archives/ + +tar: + tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.tar $$(date +%b_%d_%Y_%H%M).tar + cp latest.tar VERSION_$(VERSION).tar + mv *.tar archives/ + +unzip: + cp ./archives/latest.zip . + unzip latest.zip + +untar: + cp ./archives/latest.tar . + tar -xzf latest.tar + +# easier animation + +FRAMERATE := 24 +OUTPUT := output + +jpeg: + @magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt + @magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt + @expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt + @expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt + @echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt + @magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg + rm -f __H*.txt __W*.txt __resize.txt + +gif: + magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif + +movie: + ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4 + +# upgrade rules + +SOURCE := PhysiCell_upgrade.zip +get-upgrade: + @echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt + @echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt + rm -f VER.txt + $$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip) + rm -f DL_FILE.txt + +PhysiCell_upgrade.zip: + make get-upgrade + +upgrade: $(SOURCE) + unzip $(SOURCE) PhysiCell/VERSION.txt + mv -f PhysiCell/VERSION.txt . + unzip $(SOURCE) PhysiCell/core/* + cp -r PhysiCell/core/* core + unzip $(SOURCE) PhysiCell/modules/* + cp -r PhysiCell/modules/* modules + unzip $(SOURCE) PhysiCell/sample_projects/* + cp -r PhysiCell/sample_projects/* sample_projects + unzip $(SOURCE) PhysiCell/BioFVM/* + cp -r PhysiCell/BioFVM/* BioFVM + unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf + mv -f PhysiCell/documentation/User_Guide.pdf documentation + rm -f -r PhysiCell + rm -f $(SOURCE) + +# use: make save PROJ=your_project_name +PROJ := my_project + +save: + echo "Saving project as $(PROJ) ... " + mkdir -p ./user_projects + mkdir -p ./user_projects/$(PROJ) + mkdir -p ./user_projects/$(PROJ)/custom_modules + mkdir -p ./user_projects/$(PROJ)/config + cp main.cpp ./user_projects/$(PROJ) + cp Makefile ./user_projects/$(PROJ) + cp VERSION.txt ./user_projects/$(PROJ) + cp ./config/* ./user_projects/$(PROJ)/config + cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules + +load: + echo "Loading project from $(PROJ) ... " + cp ./user_projects/$(PROJ)/main.cpp . + cp ./user_projects/$(PROJ)/Makefile . + cp ./user_projects/$(PROJ)/config/* ./config/ + cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/ + +pack: + @echo " " + @echo "Preparing project $(PROJ) for sharing ... " + @echo " " + cd ./user_projects && zip -r $(PROJ).zip $(PROJ) + @echo " " + @echo "Share ./user_projects/$(PROJ).zip ... " + @echo "Other users can unzip $(PROJ).zip in their ./user_projects, compile, and run." + @echo " " + +unpack: + @echo " " + @echo "Preparing shared project $(PROJ).zip for use ... " + @echo " " + cd ./user_projects && unzip $(PROJ).zip + @echo " " + @echo "Load this project via make load PROJ=$(PROJ) ... " + @echo " " + +list-user-projects: + @echo "user projects::" + @cd ./user_projects && ls -dt1 * | grep . | sed 's!empty.txt!!' diff --git a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml new file mode 100644 index 000000000..43b85b8d3 --- /dev/null +++ b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml @@ -0,0 +1,349 @@ + + + + -200 + 200 + -200 + 200 + -10 + 10 + 20 + 20 + 20 + true + + + + 5760.0 + min + micron + 0.01 + 0.1 + 6 + + + + 1 + + + + output + + 30 + true + + + 30 + true + + oxygen + + + + + + false + + + + + false + true + false + + + + + + 1000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + true + true + + ./config/initial.mat + + + ./config/dirichlet.mat + + + + + + + + + + 660 + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 1.11667e-2 + 8.33333e-4 + 5.33333e-5 + 2.16667e-3 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0.4 + 10.0 + 1.25 + + 1 + 1 + + + 1.8 + 15.12 + + 0.01 + 0.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + + + + + + + 0 + 1 + 0 + 0 + + + + 0 + + 0.0 + 0 + + + 0.0 + 0 + + 1 + + 0.0 + 0 + + + + + 0.0 + 0 + + + + + 1.0 + + + + + + + 660 + + + + + 0 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 1.11667e-2 + 8.33333e-4 + 5.33333e-5 + 2.16667e-3 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0.4 + 10.0 + 1.25 + + 1 + 1 + + + 1.8 + 15.12 + + 0.01 + 0.0 + 0.0 + + + 0.05 + 0 + .5 + + true + true + + true + oxygen + 1 + + + false + false + + 0.0 + + + + + + + 0 + 1 + 0 + 0 + + + + 0 + + 0 + 0 + + + 0 + 0 + + 1 + + 0 + 0 + + + + + 0 + 0 + + + + + 1.0 + + + + + + + ./config + cells.csv + + + + + + + config + rules.csv + + + + + + 0 + 0 + + \ No newline at end of file diff --git a/user_projects/sample_division_lineage/config/cell_rules.csv b/user_projects/sample_division_lineage/config/cell_rules.csv new file mode 100644 index 000000000..e69de29bb diff --git a/user_projects/sample_division_lineage/config/cells.csv b/user_projects/sample_division_lineage/config/cells.csv new file mode 100644 index 000000000..f19c4d4f4 --- /dev/null +++ b/user_projects/sample_division_lineage/config/cells.csv @@ -0,0 +1,3 @@ +x,y,z,type,volume,cycle entry,custom:GFP,custom:sample +-80.,80.,0.0,default +80.,-80.,0.0,default diff --git a/user_projects/sample_division_lineage/custom_modules/custom.cpp b/user_projects/sample_division_lineage/custom_modules/custom.cpp new file mode 100644 index 000000000..acbb1a395 --- /dev/null +++ b/user_projects/sample_division_lineage/custom_modules/custom.cpp @@ -0,0 +1,236 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include "./custom.h" + +void create_cell_types( void ) +{ + // set the random seed + SeedRandom( parameters.ints("random_seed") ); + + /* + Put any modifications to default cell definition here if you + want to have "inherited" by other cell types. + + This is a good place to set default functions. + */ + + initialize_default_cell_definition(); + cell_defaults.phenotype.secretion.sync_to_microenvironment( µenvironment ); + + cell_defaults.functions.volume_update_function = standard_volume_update_function; + cell_defaults.functions.update_velocity = standard_update_cell_velocity; + + cell_defaults.functions.update_migration_bias = NULL; + cell_defaults.functions.update_phenotype = NULL; // update_cell_and_death_parameters_O2_based; + cell_defaults.functions.custom_cell_rule = NULL; + cell_defaults.functions.contact_function = NULL; + cell_defaults.functions.cell_division_function = NULL; + + cell_defaults.functions.add_cell_basement_membrane_interactions = NULL; + cell_defaults.functions.calculate_distance_to_membrane = NULL; + + /* + This parses the cell definitions in the XML config file. + */ + + initialize_cell_definitions_from_pugixml(); + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + build_cell_definitions_maps(); + + /* + This intializes cell signal and response dictionaries + */ + + setup_signal_behavior_dictionaries(); + + /* + Cell rule definitions + */ + + setup_cell_rules(); + + /* + Put any modifications to individual cell definitions here. + + This is a good place to set custom functions. + */ + + cell_defaults.functions.update_phenotype = phenotype_function; + cell_defaults.functions.custom_cell_rule = custom_function; + cell_defaults.functions.contact_function = contact_function; + cell_defaults.functions.cell_division_function = custom_division_function; + + int idx_ctype1 = find_cell_definition_index("ctype1"); + Cell_Definition* pCD = cell_definitions_by_index[idx_ctype1]; + pCD->functions.cell_division_function = custom_division_function; + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + display_cell_definitions( std::cout ); + + return; +} + +void setup_microenvironment( void ) +{ + // set domain parameters + + // put any custom code to set non-homogeneous initial conditions or + // extra Dirichlet nodes here. + + // initialize BioFVM + + initialize_microenvironment(); + + return; +} + +void setup_tissue( void ) +{ + double Xmin = microenvironment.mesh.bounding_box[0]; + double Ymin = microenvironment.mesh.bounding_box[1]; + double Zmin = microenvironment.mesh.bounding_box[2]; + + double Xmax = microenvironment.mesh.bounding_box[3]; + double Ymax = microenvironment.mesh.bounding_box[4]; + double Zmax = microenvironment.mesh.bounding_box[5]; + + if( default_microenvironment_options.simulate_2D == true ) + { + Zmin = 0.0; + Zmax = 0.0; + } + + double Xrange = Xmax - Xmin; + double Yrange = Ymax - Ymin; + double Zrange = Zmax - Zmin; + + // create some of each type of cell + + Cell* pC; + + for( int k=0; k < cell_definitions_by_index.size() ; k++ ) + { + Cell_Definition* pCD = cell_definitions_by_index[k]; + std::cout << "Placing cells of type " << pCD->name << " ... " << std::endl; + for( int n = 0 ; n < parameters.ints("number_of_cells") ; n++ ) + { + std::vector position = {0,0,0}; + position[0] = Xmin + UniformRandom()*Xrange; + position[1] = Ymin + UniformRandom()*Yrange; + position[2] = Zmin + UniformRandom()*Zrange; + + pC = create_cell( *pCD ); + pC->assign_position( position ); + } + } + std::cout << std::endl; + + // load cells from your CSV file (if enabled) + load_cells_from_pugixml(); + set_parameters_from_distributions(); + + return; +} + +std::vector my_coloring_function( Cell* pCell ) +{ return paint_by_number_cell_coloring(pCell); } + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ) +{ return; } + +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ) +{ return; } + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ) +{ return; } + +void custom_division_function( Cell* pCell1, Cell* pCell2 ) +{ + static int idx_default = find_cell_definition_index("default"); + static int idx_ctype1 = find_cell_definition_index("ctype1"); + std::cout << __FUNCTION__ << ": t=" << PhysiCell_globals.current_time << ": cell IDs= " << pCell1->ID << ", " << pCell2->ID << ", pCell1->type_name= " << pCell1->type_name << std::endl; + + // Asymmetric division + if (UniformRandom() < 0.5) + { + pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_default] ); + } + else + { + pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_ctype1] ); + } + + return; +} \ No newline at end of file diff --git a/user_projects/sample_division_lineage/custom_modules/custom.h b/user_projects/sample_division_lineage/custom_modules/custom.h new file mode 100644 index 000000000..7e6b0f044 --- /dev/null +++ b/user_projects/sample_division_lineage/custom_modules/custom.h @@ -0,0 +1,93 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include "../core/PhysiCell.h" +#include "../modules/PhysiCell_standard_modules.h" + +using namespace BioFVM; +using namespace PhysiCell; + +// setup functions to help us along + +void create_cell_types( void ); +void setup_tissue( void ); + +// set up the BioFVM microenvironment +void setup_microenvironment( void ); + +// custom pathology coloring function + +std::vector my_coloring_function( Cell* ); + +// custom functions can go here + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ); +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ); + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ); + +void custom_division_function( Cell* pCell1, Cell* pCell2 ); diff --git a/user_projects/sample_division_lineage/main.cpp b/user_projects/sample_division_lineage/main.cpp new file mode 100644 index 000000000..2f7e98c75 --- /dev/null +++ b/user_projects/sample_division_lineage/main.cpp @@ -0,0 +1,254 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2022, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "./core/PhysiCell.h" +#include "./modules/PhysiCell_standard_modules.h" + +// put custom code modules here! + +#include "./custom_modules/custom.h" + +using namespace BioFVM; +using namespace PhysiCell; + +int main( int argc, char* argv[] ) +{ + // load and parse settings file(s) + + bool XML_status = false; + char copy_command [1024]; + if( argc > 1 ) + { + XML_status = load_PhysiCell_config_file( argv[1] ); + sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() ); + } + else + { + XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" ); + sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() ); + } + if( !XML_status ) + { exit(-1); } + + // copy config file to output directry + system( copy_command ); + + // OpenMP setup + omp_set_num_threads(PhysiCell_settings.omp_num_threads); + + // time setup + std::string time_units = "min"; + + /* Microenvironment setup */ + + setup_microenvironment(); // modify this in the custom code + + /* PhysiCell setup */ + + // set mechanics voxel size, and match the data structure to BioFVM + double mechanics_voxel_size = 30; + Cell_Container* cell_container = create_cell_container_for_microenvironment( microenvironment, mechanics_voxel_size ); + + /* Users typically start modifying here. START USERMODS */ + + create_cell_types(); + + setup_tissue(); + + /* Users typically stop modifying here. END USERMODS */ + + // set MultiCellDS save options + + set_save_biofvm_mesh_as_matlab( true ); + set_save_biofvm_data_as_matlab( true ); + set_save_biofvm_cell_data( true ); + set_save_biofvm_cell_data_as_custom_matlab( true ); + + // save a simulation snapshot + + char filename[1024]; + sprintf( filename , "%s/initial" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + // save a quick SVG cross section through z = 0, after setting its + // length bar to 200 microns + + PhysiCell_SVG_options.length_bar = 200; + + // for simplicity, set a pathology coloring function + + std::vector (*cell_coloring_function)(Cell*) = my_coloring_function; + std::string (*substrate_coloring_function)(double, double, double) = paint_by_density_percentage; + + sprintf( filename , "%s/initial.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function ); + + sprintf( filename , "%s/legend.svg" , PhysiCell_settings.folder.c_str() ); + create_plot_legend( filename , cell_coloring_function ); + + display_citations(); + + // set the performance timers + + BioFVM::RUNTIME_TIC(); + BioFVM::TIC(); + + std::ofstream report_file; + if( PhysiCell_settings.enable_legacy_saves == true ) + { + sprintf( filename , "%s/simulation_report.txt" , PhysiCell_settings.folder.c_str() ); + + report_file.open(filename); // create the data log file + report_file<<"simulated time\tnum cells\tnum division\tnum death\twall time"<update_all_cells( PhysiCell_globals.current_time ); + + /* + Custom add-ons could potentially go here. + */ + + PhysiCell_globals.current_time += diffusion_dt; + } + + if( PhysiCell_settings.enable_legacy_saves == true ) + { + log_output(PhysiCell_globals.current_time, PhysiCell_globals.full_output_index, microenvironment, report_file); + report_file.close(); + } + } + catch( const std::exception& e ) + { // reference to the base of a polymorphic object + std::cout << e.what(); // information from length_error printed + } + + // save a final simulation snapshot + + sprintf( filename , "%s/final" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + sprintf( filename , "%s/final.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot(filename, microenvironment, 0.0, PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function); + + // timer + + std::cout << std::endl << "Total simulation runtime: " << std::endl; + BioFVM::display_stopwatch_value( std::cout , BioFVM::runtime_stopwatch_value() ); + + return 0; +} From 4b7ba7da8738eff16339d88dbc84aa70b3594fbe Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sun, 14 Jul 2024 17:18:49 -0400 Subject: [PATCH 04/12] update --- core/PhysiCell_cell.cpp | 10 ++++++++-- core/PhysiCell_cell.h | 1 + modules/PhysiCell_MultiCellDS.cpp | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 2496ddf90..5c53aa1be 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -419,6 +419,7 @@ Cell::Cell() is_movable = true; is_out_of_domain = false; generation = 0; + parentID = -1; // overridden in create_cell() and divide() displacement.resize(3,0.0); // state? assign_orientation(); @@ -565,8 +566,12 @@ Cell* Cell::divide( ) Cell* child = create_cell(functions.instantiate_cell); child->copy_data( this ); // lineage tracking - generation = generation + 1; // this (parent) cell has its generation incremented - child->generation = generation; // its daughter cell has the same generation + // generation = generation + 1; // this (parent) cell has its generation incremented + // child->generation = generation; // daughter cell has the same generation + child->generation = generation + 1; + // child->parentID = parentID; + parentID = ID; + child->parentID = ID; child->copy_function_pointers(this); child->parameters = parameters; @@ -1075,6 +1080,7 @@ Cell* create_cell( Cell* (*custom_instantiate)()) } else { pNew = standard_instantiate_cell(); } + pNew->parentID = pNew->ID; (*all_cells).push_back( pNew ); pNew->index=(*all_cells).size()-1; diff --git a/core/PhysiCell_cell.h b/core/PhysiCell_cell.h index 27f4906eb..59566d24d 100644 --- a/core/PhysiCell_cell.h +++ b/core/PhysiCell_cell.h @@ -190,6 +190,7 @@ class Cell : public Basic_Agent bool is_movable; int generation; // for lineage tracking + int parentID; // for lineage tracking void flag_for_division( void ); // done void flag_for_removal( void ); // done diff --git a/modules/PhysiCell_MultiCellDS.cpp b/modules/PhysiCell_MultiCellDS.cpp index 6d9a6afba..860e278a9 100644 --- a/modules/PhysiCell_MultiCellDS.cpp +++ b/modules/PhysiCell_MultiCellDS.cpp @@ -902,6 +902,17 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std:: cell_data_size += size; index += size; + // parentID + name = "parentID"; + size = 1; + units="none"; + data_names.push_back( name ); + data_units.push_back(units); + data_sizes.push_back( size ); + data_start_indices.push_back( index ); + cell_data_size += size; + index += size; + // name = "position"; size = 3; @@ -1769,6 +1780,9 @@ void add_PhysiCell_cells_to_open_xml_pugi_v2( pugi::xml_document& xml_dom, std:: // name = "generation"; dTemp = (double) pCell->generation; std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp ); + // name = "parentID"; + dTemp = (double) pCell->parentID; + std::fwrite( &( dTemp ) , sizeof(double) , 1 , fp ); // name = "position"; NOTE very different syntax for writing vectors! std::fwrite( pCell->position.data() , sizeof(double) , 3 , fp ); // name = "total_volume"; From c73c26e604d62c4274c099c88ce3e290468c6fa0 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sun, 14 Jul 2024 17:37:05 -0400 Subject: [PATCH 05/12] update --- core/PhysiCell_constants.cpp | 63 +++++++++++++++++++++++++++--- core/PhysiCell_constants.h | 74 ++++++++++++++++++------------------ 2 files changed, 94 insertions(+), 43 deletions(-) diff --git a/core/PhysiCell_constants.cpp b/core/PhysiCell_constants.cpp index 7727c40f2..8ade36f6b 100644 --- a/core/PhysiCell_constants.cpp +++ b/core/PhysiCell_constants.cpp @@ -76,12 +76,63 @@ double mechanics_dt = 0.1; double phenotype_dt = 6.0; double intracellular_dt = 0.01; -std::unordered_map cycle_model_codes = -{ - { "Ki67 (advanced)", PhysiCell_constants::advanced_Ki67_cycle_model}, - { "Ki67 (basic)" ,PhysiCell_constants::basic_Ki67_cycle_model}, - { "Flow cytometry model (basic)",PhysiCell_constants::flow_cytometry_cycle_model}, - // { ,PhysiCell_constants::live_apoptotic_cycle_model}, // not implemented + +// currently recognized cell cycle models +const int PhysiCell_constants::advanced_Ki67_cycle_model= 0; +const int PhysiCell_constants::basic_Ki67_cycle_model=1; +const int PhysiCell_constants::flow_cytometry_cycle_model=2; +const int PhysiCell_constants::live_apoptotic_cycle_model=3; +const int PhysiCell_constants::total_cells_cycle_model=4; +const int PhysiCell_constants::live_cells_cycle_model = 5; +const int PhysiCell_constants::flow_cytometry_separated_cycle_model = 6; +const int PhysiCell_constants::cycling_quiescent_model = 7; + +// currently recognized death models +const int PhysiCell_constants::apoptosis_death_model = 100; +const int PhysiCell_constants::necrosis_death_model = 101; +const int PhysiCell_constants::autophagy_death_model = 102; + +const int PhysiCell_constants::custom_cycle_model=9999; + +// currently recognized cell cycle and death phases +// cycle phases +const int PhysiCell_constants::Ki67_positive_premitotic=0; +const int PhysiCell_constants::Ki67_positive_postmitotic=1; +const int PhysiCell_constants::Ki67_positive=2; +const int PhysiCell_constants::Ki67_negative=3; +const int PhysiCell_constants::G0G1_phase=4; +const int PhysiCell_constants::G0_phase=5; +const int PhysiCell_constants::G1_phase=6; +const int PhysiCell_constants::G1a_phase=7; +const int PhysiCell_constants::G1b_phase=8; +const int PhysiCell_constants::G1c_phase=9; +const int PhysiCell_constants::S_phase=10; +const int PhysiCell_constants::G2M_phase=11; +const int PhysiCell_constants::G2_phase=12; +const int PhysiCell_constants::M_phase=13; +const int PhysiCell_constants::live=14; + +const int PhysiCell_constants::G1pm_phase = 15; +const int PhysiCell_constants::G1ps_phase = 16; + +const int PhysiCell_constants::cycling = 17; +const int PhysiCell_constants::quiescent = 18; + + +const int PhysiCell_constants::custom_phase = 9999; +// death phases +const int PhysiCell_constants::apoptotic=100; +const int PhysiCell_constants::necrotic_swelling=101; +const int PhysiCell_constants::necrotic_lysed=102; +const int PhysiCell_constants::necrotic=103; +const int PhysiCell_constants::debris=104; + +std::unordered_map cycle_model_codes = { + + { "Ki67 (advanced)", PhysiCell_constants::advanced_Ki67_cycle_model}, + { "Ki67 (basic)" ,PhysiCell_constants::basic_Ki67_cycle_model}, + { "Flow cytometry model (basic)",PhysiCell_constants::flow_cytometry_cycle_model}, +// { ,PhysiCell_constants::live_apoptotic_cycle_model}, // not implemented // { ,PhysiCell_constants::total_cells_cycle_model}, // not implemented { "Live",PhysiCell_constants::live_cells_cycle_model}, { "Flow cytometry model (separated)",PhysiCell_constants::flow_cytometry_separated_cycle_model}, diff --git a/core/PhysiCell_constants.h b/core/PhysiCell_constants.h index 476953148..58aef3c84 100644 --- a/core/PhysiCell_constants.h +++ b/core/PhysiCell_constants.h @@ -102,54 +102,54 @@ class PhysiCell_constants static const int mesh_uz_face_index=5; // currently recognized cell cycle models - static const int advanced_Ki67_cycle_model= 0; - static const int basic_Ki67_cycle_model=1; - static const int flow_cytometry_cycle_model=2; - static const int live_apoptotic_cycle_model=3; - static const int total_cells_cycle_model=4; - static const int live_cells_cycle_model = 5; - static const int flow_cytometry_separated_cycle_model = 6; - static const int cycling_quiescent_model = 7; + static const int advanced_Ki67_cycle_model; + static const int basic_Ki67_cycle_model; + static const int flow_cytometry_cycle_model; + static const int live_apoptotic_cycle_model; + static const int total_cells_cycle_model; + static const int live_cells_cycle_model ; + static const int flow_cytometry_separated_cycle_model ; + static const int cycling_quiescent_model ; // currently recognized death models - static const int apoptosis_death_model = 100; - static const int necrosis_death_model = 101; - static const int autophagy_death_model = 102; + static const int apoptosis_death_model ; + static const int necrosis_death_model ; + static const int autophagy_death_model ; - static const int custom_cycle_model=9999; + static const int custom_cycle_model; // currently recognized cell cycle and death phases // cycle phases - static const int Ki67_positive_premitotic=0; - static const int Ki67_positive_postmitotic=1; - static const int Ki67_positive=2; - static const int Ki67_negative=3; - static const int G0G1_phase=4; - static const int G0_phase=5; - static const int G1_phase=6; - static const int G1a_phase=7; - static const int G1b_phase=8; - static const int G1c_phase=9; - static const int S_phase=10; - static const int G2M_phase=11; - static const int G2_phase=12; - static const int M_phase=13; - static const int live=14; + static const int Ki67_positive_premitotic; + static const int Ki67_positive_postmitotic; + static const int Ki67_positive; + static const int Ki67_negative; + static const int G0G1_phase; + static const int G0_phase; + static const int G1_phase; + static const int G1a_phase; + static const int G1b_phase; + static const int G1c_phase; + static const int S_phase; + static const int G2M_phase; + static const int G2_phase; + static const int M_phase; + static const int live; - static const int G1pm_phase = 15; - static const int G1ps_phase = 16; + static const int G1pm_phase ; + static const int G1ps_phase ; - static const int cycling = 17; - static const int quiescent = 18; + static const int cycling ; + static const int quiescent ; - static const int custom_phase = 9999; + static const int custom_phase ; // death phases - static const int apoptotic=100; - static const int necrotic_swelling=101; - static const int necrotic_lysed=102; - static const int necrotic=103; - static const int debris=104; + static const int apoptotic; + static const int necrotic_swelling; + static const int necrotic_lysed; + static const int necrotic; + static const int debris; }; extern std::string time_units; extern std::string space_units; From 145d9d0603b5cf4af79b2dac381e8540ef15c055 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Sun, 14 Jul 2024 17:56:08 -0400 Subject: [PATCH 06/12] update --- .../sample_division_lineage/config/PhysiCell_settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml index 43b85b8d3..eb76470f2 100644 --- a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml +++ b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml @@ -14,7 +14,7 @@ - 5760.0 + 4320.0 min micron 0.01 From a4eccbe6ac3b2c6c20f109eed853a774b35685d2 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Mon, 15 Jul 2024 09:26:34 -0400 Subject: [PATCH 07/12] incr generation for both; stochastic cell cycle --- core/PhysiCell_cell.cpp | 6 +++--- .../sample_division_lineage/config/PhysiCell_settings.xml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 5c53aa1be..f5b559bd7 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -566,9 +566,9 @@ Cell* Cell::divide( ) Cell* child = create_cell(functions.instantiate_cell); child->copy_data( this ); // lineage tracking - // generation = generation + 1; // this (parent) cell has its generation incremented - // child->generation = generation; // daughter cell has the same generation - child->generation = generation + 1; + generation = generation + 1; // this (parent) cell has its generation incremented + child->generation = generation; // daughter cell has the same generation + // child->generation = generation + 1; // child->parentID = parentID; parentID = ID; child->parentID = ID; diff --git a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml index eb76470f2..abdea1ab9 100644 --- a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml +++ b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml @@ -86,7 +86,7 @@ - 660 + 660 @@ -207,7 +207,7 @@ - 660 + 660 From 672ddd2a441430e644f5a678a8ba7ee6fd66de86 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 15 Aug 2024 06:38:50 -0400 Subject: [PATCH 08/12] remove user proj --- .../sample_division_lineage/Makefile | 314 ---------------- .../config/PhysiCell_settings.xml | 349 ------------------ .../config/cell_rules.csv | 0 .../sample_division_lineage/config/cells.csv | 3 - .../custom_modules/custom.cpp | 236 ------------ .../custom_modules/custom.h | 93 ----- .../sample_division_lineage/main.cpp | 254 ------------- 7 files changed, 1249 deletions(-) delete mode 100644 user_projects/sample_division_lineage/Makefile delete mode 100644 user_projects/sample_division_lineage/config/PhysiCell_settings.xml delete mode 100644 user_projects/sample_division_lineage/config/cell_rules.csv delete mode 100644 user_projects/sample_division_lineage/config/cells.csv delete mode 100644 user_projects/sample_division_lineage/custom_modules/custom.cpp delete mode 100644 user_projects/sample_division_lineage/custom_modules/custom.h delete mode 100644 user_projects/sample_division_lineage/main.cpp diff --git a/user_projects/sample_division_lineage/Makefile b/user_projects/sample_division_lineage/Makefile deleted file mode 100644 index e90a9966f..000000000 --- a/user_projects/sample_division_lineage/Makefile +++ /dev/null @@ -1,314 +0,0 @@ -VERSION := $(shell grep . VERSION.txt | cut -f1 -d:) -PROGRAM_NAME := project - -CC := g++ -# CC := g++-mp-7 # typical macports compiler name -# CC := g++-7 # typical homebrew compiler name - -# Check for environment definitions of compiler -# e.g., on CC = g++-7 on OSX -ifdef PHYSICELL_CPP - CC := $(PHYSICELL_CPP) -endif - -ARCH := native # best auto-tuning -# ARCH := core2 # a reasonably safe default for most CPUs since 2007 -# ARCH := corei7 -# ARCH := corei7-avx # earlier i7 -# ARCH := core-avx-i # i7 ivy bridge or newer -# ARCH := core-avx2 # i7 with Haswell or newer -# ARCH := nehalem -# ARCH := westmere -# ARCH := sandybridge # circa 2011 -# ARCH := ivybridge # circa 2012 -# ARCH := haswell # circa 2013 -# ARCH := broadwell # circa 2014 -# ARCH := skylake # circa 2015 -# ARCH := bonnell -# ARCH := silvermont -# ARCH := skylake-avx512 -# ARCH := nocona #64-bit pentium 4 or later - -# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 -CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 - -ifeq ($(OS),Windows_NT) -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Darwin) - UNAME_P := $(shell uname -p) - var := $(shell which $(CC) | xargs file) - ifeq ($(lastword $(var)),arm64) - CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11 - endif - endif -endif - -COMPILE_COMMAND := $(CC) $(CFLAGS) - -BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \ -BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o - -PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \ -PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \ -PhysiCell_signal_behavior.o PhysiCell_rules.o - -PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \ -PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o - -# put your custom objects here (they should be in the custom_modules directory) - -PhysiCell_custom_module_OBJECTS := custom.o - -pugixml_OBJECTS := pugixml.o - -PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) -ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) - -# compile the project - -all: main.cpp $(ALL_OBJECTS) - $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp - make name - -name: - @echo "" - @echo "Executable name is" $(PROGRAM_NAME) - @echo "" - -# PhysiCell core components - -PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp - -PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp - -PhysiCell_cell.o: ./core/PhysiCell_cell.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp - -PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp - -PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp - -PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp - -PhysiCell_custom.o: ./core/PhysiCell_custom.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp - -PhysiCell_constants.o: ./core/PhysiCell_constants.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp - -PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp - -PhysiCell_rules.o: ./core/PhysiCell_rules.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_rules.cpp - -# BioFVM core components (needed by PhysiCell) - -BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp - -BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp - -BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp - -BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp - -BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp - -BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp - -BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp - -BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp - -BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp - $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp - -pugixml.o: ./BioFVM/pugixml.cpp - $(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp - -# standard PhysiCell modules - -PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp - -PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp - -PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp - -PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp - -PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp - -PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp - -PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp - -PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp - -# user-defined PhysiCell modules - -custom.o: ./custom_modules/custom.cpp - $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp - -# cleanup - -reset: - rm -f *.cpp - cp ./sample_projects/Makefile-default Makefile - rm -f ./custom_modules/* - touch ./custom_modules/empty.txt - touch ALL_CITATIONS.txt - touch ./core/PhysiCell_cell.cpp - rm ALL_CITATIONS.txt - cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml - touch ./config/empty.csv - rm -f ./config/*.csv - -clean: - rm -f *.o - rm -f $(PROGRAM_NAME)* - -data-cleanup: - rm -rf ./output - mkdir ./output - touch ./output/empty.txt - -# archival - -checkpoint: - zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* - -zip: - zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* - cp latest.zip $$(date +%b_%d_%Y_%H%M).zip - cp latest.zip VERSION_$(VERSION).zip - mv *.zip archives/ - -tar: - tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* - cp latest.tar $$(date +%b_%d_%Y_%H%M).tar - cp latest.tar VERSION_$(VERSION).tar - mv *.tar archives/ - -unzip: - cp ./archives/latest.zip . - unzip latest.zip - -untar: - cp ./archives/latest.tar . - tar -xzf latest.tar - -# easier animation - -FRAMERATE := 24 -OUTPUT := output - -jpeg: - @magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt - @magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt - @expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt - @expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt - @echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt - @magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg - rm -f __H*.txt __W*.txt __resize.txt - -gif: - magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif - -movie: - ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4 - -# upgrade rules - -SOURCE := PhysiCell_upgrade.zip -get-upgrade: - @echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt - @echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt - rm -f VER.txt - $$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip) - rm -f DL_FILE.txt - -PhysiCell_upgrade.zip: - make get-upgrade - -upgrade: $(SOURCE) - unzip $(SOURCE) PhysiCell/VERSION.txt - mv -f PhysiCell/VERSION.txt . - unzip $(SOURCE) PhysiCell/core/* - cp -r PhysiCell/core/* core - unzip $(SOURCE) PhysiCell/modules/* - cp -r PhysiCell/modules/* modules - unzip $(SOURCE) PhysiCell/sample_projects/* - cp -r PhysiCell/sample_projects/* sample_projects - unzip $(SOURCE) PhysiCell/BioFVM/* - cp -r PhysiCell/BioFVM/* BioFVM - unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf - mv -f PhysiCell/documentation/User_Guide.pdf documentation - rm -f -r PhysiCell - rm -f $(SOURCE) - -# use: make save PROJ=your_project_name -PROJ := my_project - -save: - echo "Saving project as $(PROJ) ... " - mkdir -p ./user_projects - mkdir -p ./user_projects/$(PROJ) - mkdir -p ./user_projects/$(PROJ)/custom_modules - mkdir -p ./user_projects/$(PROJ)/config - cp main.cpp ./user_projects/$(PROJ) - cp Makefile ./user_projects/$(PROJ) - cp VERSION.txt ./user_projects/$(PROJ) - cp ./config/* ./user_projects/$(PROJ)/config - cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules - -load: - echo "Loading project from $(PROJ) ... " - cp ./user_projects/$(PROJ)/main.cpp . - cp ./user_projects/$(PROJ)/Makefile . - cp ./user_projects/$(PROJ)/config/* ./config/ - cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/ - -pack: - @echo " " - @echo "Preparing project $(PROJ) for sharing ... " - @echo " " - cd ./user_projects && zip -r $(PROJ).zip $(PROJ) - @echo " " - @echo "Share ./user_projects/$(PROJ).zip ... " - @echo "Other users can unzip $(PROJ).zip in their ./user_projects, compile, and run." - @echo " " - -unpack: - @echo " " - @echo "Preparing shared project $(PROJ).zip for use ... " - @echo " " - cd ./user_projects && unzip $(PROJ).zip - @echo " " - @echo "Load this project via make load PROJ=$(PROJ) ... " - @echo " " - -list-user-projects: - @echo "user projects::" - @cd ./user_projects && ls -dt1 * | grep . | sed 's!empty.txt!!' diff --git a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml b/user_projects/sample_division_lineage/config/PhysiCell_settings.xml deleted file mode 100644 index abdea1ab9..000000000 --- a/user_projects/sample_division_lineage/config/PhysiCell_settings.xml +++ /dev/null @@ -1,349 +0,0 @@ - - - - -200 - 200 - -200 - 200 - -10 - 10 - 20 - 20 - 20 - true - - - - 4320.0 - min - micron - 0.01 - 0.1 - 6 - - - - 1 - - - - output - - 30 - true - - - 30 - true - - oxygen - - - - - - false - - - - - false - true - false - - - - - - 1000.0 - 0.1 - - 38 - 38 - - 38 - 38 - 38 - 38 - 38 - 38 - - - - true - true - - ./config/initial.mat - - - ./config/dirichlet.mat - - - - - - - - - - 660 - - - - - 5.31667e-05 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 1.11667e-2 - 8.33333e-4 - 5.33333e-5 - 2.16667e-3 - 0 - 2.0 - - - - - 2494 - 0.75 - 540 - 0.05 - 0.0045 - 0.0055 - 0 - 0 - 2.0 - - - 0.4 - 10.0 - 1.25 - - 1 - 1 - - - 1.8 - 15.12 - - 0.01 - 0.0 - 0.0 - - - 1 - 1 - .5 - - false - true - - false - oxygen - 1 - - - false - false - - 0.0 - - - - - - - 0 - 1 - 0 - 0 - - - - 0 - - 0.0 - 0 - - - 0.0 - 0 - - 1 - - 0.0 - 0 - - - - - 0.0 - 0 - - - - - 1.0 - - - - - - - 660 - - - - - 0 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 1.11667e-2 - 8.33333e-4 - 5.33333e-5 - 2.16667e-3 - 0 - 2.0 - - - - - 2494 - 0.75 - 540 - 0.05 - 0.0045 - 0.0055 - 0 - 0 - 2.0 - - - 0.4 - 10.0 - 1.25 - - 1 - 1 - - - 1.8 - 15.12 - - 0.01 - 0.0 - 0.0 - - - 0.05 - 0 - .5 - - true - true - - true - oxygen - 1 - - - false - false - - 0.0 - - - - - - - 0 - 1 - 0 - 0 - - - - 0 - - 0 - 0 - - - 0 - 0 - - 1 - - 0 - 0 - - - - - 0 - 0 - - - - - 1.0 - - - - - - - ./config - cells.csv - - - - - - - config - rules.csv - - - - - - 0 - 0 - - \ No newline at end of file diff --git a/user_projects/sample_division_lineage/config/cell_rules.csv b/user_projects/sample_division_lineage/config/cell_rules.csv deleted file mode 100644 index e69de29bb..000000000 diff --git a/user_projects/sample_division_lineage/config/cells.csv b/user_projects/sample_division_lineage/config/cells.csv deleted file mode 100644 index f19c4d4f4..000000000 --- a/user_projects/sample_division_lineage/config/cells.csv +++ /dev/null @@ -1,3 +0,0 @@ -x,y,z,type,volume,cycle entry,custom:GFP,custom:sample --80.,80.,0.0,default -80.,-80.,0.0,default diff --git a/user_projects/sample_division_lineage/custom_modules/custom.cpp b/user_projects/sample_division_lineage/custom_modules/custom.cpp deleted file mode 100644 index acbb1a395..000000000 --- a/user_projects/sample_division_lineage/custom_modules/custom.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -############################################################################### -# If you use PhysiCell in your project, please cite PhysiCell and the version # -# number, such as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# See VERSION.txt or call get_PhysiCell_version() to get the current version # -# x.y.z. Call display_citations() to get detailed information on all cite-# -# able software used in your PhysiCell application. # -# # -# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # -# as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # -# with BioFVM [2] to solve the transport equations. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # -# llelized diffusive transport solver for 3-D biological simulations, # -# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # -# # -############################################################################### -# # -# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # -# # -# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # -# All rights reserved. # -# # -# Redistribution and use in source and binary forms, with or without # -# modification, are permitted provided that the following conditions are met: # -# # -# 1. Redistributions of source code must retain the above copyright notice, # -# this list of conditions and the following disclaimer. # -# # -# 2. Redistributions in binary form must reproduce the above copyright # -# notice, this list of conditions and the following disclaimer in the # -# documentation and/or other materials provided with the distribution. # -# # -# 3. Neither the name of the copyright holder nor the names of its # -# contributors may be used to endorse or promote products derived from this # -# software without specific prior written permission. # -# # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # -# POSSIBILITY OF SUCH DAMAGE. # -# # -############################################################################### -*/ - -#include "./custom.h" - -void create_cell_types( void ) -{ - // set the random seed - SeedRandom( parameters.ints("random_seed") ); - - /* - Put any modifications to default cell definition here if you - want to have "inherited" by other cell types. - - This is a good place to set default functions. - */ - - initialize_default_cell_definition(); - cell_defaults.phenotype.secretion.sync_to_microenvironment( µenvironment ); - - cell_defaults.functions.volume_update_function = standard_volume_update_function; - cell_defaults.functions.update_velocity = standard_update_cell_velocity; - - cell_defaults.functions.update_migration_bias = NULL; - cell_defaults.functions.update_phenotype = NULL; // update_cell_and_death_parameters_O2_based; - cell_defaults.functions.custom_cell_rule = NULL; - cell_defaults.functions.contact_function = NULL; - cell_defaults.functions.cell_division_function = NULL; - - cell_defaults.functions.add_cell_basement_membrane_interactions = NULL; - cell_defaults.functions.calculate_distance_to_membrane = NULL; - - /* - This parses the cell definitions in the XML config file. - */ - - initialize_cell_definitions_from_pugixml(); - - /* - This builds the map of cell definitions and summarizes the setup. - */ - - build_cell_definitions_maps(); - - /* - This intializes cell signal and response dictionaries - */ - - setup_signal_behavior_dictionaries(); - - /* - Cell rule definitions - */ - - setup_cell_rules(); - - /* - Put any modifications to individual cell definitions here. - - This is a good place to set custom functions. - */ - - cell_defaults.functions.update_phenotype = phenotype_function; - cell_defaults.functions.custom_cell_rule = custom_function; - cell_defaults.functions.contact_function = contact_function; - cell_defaults.functions.cell_division_function = custom_division_function; - - int idx_ctype1 = find_cell_definition_index("ctype1"); - Cell_Definition* pCD = cell_definitions_by_index[idx_ctype1]; - pCD->functions.cell_division_function = custom_division_function; - - /* - This builds the map of cell definitions and summarizes the setup. - */ - - display_cell_definitions( std::cout ); - - return; -} - -void setup_microenvironment( void ) -{ - // set domain parameters - - // put any custom code to set non-homogeneous initial conditions or - // extra Dirichlet nodes here. - - // initialize BioFVM - - initialize_microenvironment(); - - return; -} - -void setup_tissue( void ) -{ - double Xmin = microenvironment.mesh.bounding_box[0]; - double Ymin = microenvironment.mesh.bounding_box[1]; - double Zmin = microenvironment.mesh.bounding_box[2]; - - double Xmax = microenvironment.mesh.bounding_box[3]; - double Ymax = microenvironment.mesh.bounding_box[4]; - double Zmax = microenvironment.mesh.bounding_box[5]; - - if( default_microenvironment_options.simulate_2D == true ) - { - Zmin = 0.0; - Zmax = 0.0; - } - - double Xrange = Xmax - Xmin; - double Yrange = Ymax - Ymin; - double Zrange = Zmax - Zmin; - - // create some of each type of cell - - Cell* pC; - - for( int k=0; k < cell_definitions_by_index.size() ; k++ ) - { - Cell_Definition* pCD = cell_definitions_by_index[k]; - std::cout << "Placing cells of type " << pCD->name << " ... " << std::endl; - for( int n = 0 ; n < parameters.ints("number_of_cells") ; n++ ) - { - std::vector position = {0,0,0}; - position[0] = Xmin + UniformRandom()*Xrange; - position[1] = Ymin + UniformRandom()*Yrange; - position[2] = Zmin + UniformRandom()*Zrange; - - pC = create_cell( *pCD ); - pC->assign_position( position ); - } - } - std::cout << std::endl; - - // load cells from your CSV file (if enabled) - load_cells_from_pugixml(); - set_parameters_from_distributions(); - - return; -} - -std::vector my_coloring_function( Cell* pCell ) -{ return paint_by_number_cell_coloring(pCell); } - -void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ) -{ return; } - -void custom_function( Cell* pCell, Phenotype& phenotype , double dt ) -{ return; } - -void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ) -{ return; } - -void custom_division_function( Cell* pCell1, Cell* pCell2 ) -{ - static int idx_default = find_cell_definition_index("default"); - static int idx_ctype1 = find_cell_definition_index("ctype1"); - std::cout << __FUNCTION__ << ": t=" << PhysiCell_globals.current_time << ": cell IDs= " << pCell1->ID << ", " << pCell2->ID << ", pCell1->type_name= " << pCell1->type_name << std::endl; - - // Asymmetric division - if (UniformRandom() < 0.5) - { - pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_default] ); - } - else - { - pCell2->convert_to_cell_definition( *cell_definitions_by_index[idx_ctype1] ); - } - - return; -} \ No newline at end of file diff --git a/user_projects/sample_division_lineage/custom_modules/custom.h b/user_projects/sample_division_lineage/custom_modules/custom.h deleted file mode 100644 index 7e6b0f044..000000000 --- a/user_projects/sample_division_lineage/custom_modules/custom.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -############################################################################### -# If you use PhysiCell in your project, please cite PhysiCell and the version # -# number, such as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# See VERSION.txt or call get_PhysiCell_version() to get the current version # -# x.y.z. Call display_citations() to get detailed information on all cite-# -# able software used in your PhysiCell application. # -# # -# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # -# as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # -# with BioFVM [2] to solve the transport equations. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # -# llelized diffusive transport solver for 3-D biological simulations, # -# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # -# # -############################################################################### -# # -# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # -# # -# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # -# All rights reserved. # -# # -# Redistribution and use in source and binary forms, with or without # -# modification, are permitted provided that the following conditions are met: # -# # -# 1. Redistributions of source code must retain the above copyright notice, # -# this list of conditions and the following disclaimer. # -# # -# 2. Redistributions in binary form must reproduce the above copyright # -# notice, this list of conditions and the following disclaimer in the # -# documentation and/or other materials provided with the distribution. # -# # -# 3. Neither the name of the copyright holder nor the names of its # -# contributors may be used to endorse or promote products derived from this # -# software without specific prior written permission. # -# # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # -# POSSIBILITY OF SUCH DAMAGE. # -# # -############################################################################### -*/ - -#include "../core/PhysiCell.h" -#include "../modules/PhysiCell_standard_modules.h" - -using namespace BioFVM; -using namespace PhysiCell; - -// setup functions to help us along - -void create_cell_types( void ); -void setup_tissue( void ); - -// set up the BioFVM microenvironment -void setup_microenvironment( void ); - -// custom pathology coloring function - -std::vector my_coloring_function( Cell* ); - -// custom functions can go here - -void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ); -void custom_function( Cell* pCell, Phenotype& phenotype , double dt ); - -void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ); - -void custom_division_function( Cell* pCell1, Cell* pCell2 ); diff --git a/user_projects/sample_division_lineage/main.cpp b/user_projects/sample_division_lineage/main.cpp deleted file mode 100644 index 2f7e98c75..000000000 --- a/user_projects/sample_division_lineage/main.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* -############################################################################### -# If you use PhysiCell in your project, please cite PhysiCell and the version # -# number, such as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# See VERSION.txt or call get_PhysiCell_version() to get the current version # -# x.y.z. Call display_citations() to get detailed information on all cite-# -# able software used in your PhysiCell application. # -# # -# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # -# as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # -# with BioFVM [2] to solve the transport equations. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # -# llelized diffusive transport solver for 3-D biological simulations, # -# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # -# # -############################################################################### -# # -# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # -# # -# Copyright (c) 2015-2022, Paul Macklin and the PhysiCell Project # -# All rights reserved. # -# # -# Redistribution and use in source and binary forms, with or without # -# modification, are permitted provided that the following conditions are met: # -# # -# 1. Redistributions of source code must retain the above copyright notice, # -# this list of conditions and the following disclaimer. # -# # -# 2. Redistributions in binary form must reproduce the above copyright # -# notice, this list of conditions and the following disclaimer in the # -# documentation and/or other materials provided with the distribution. # -# # -# 3. Neither the name of the copyright holder nor the names of its # -# contributors may be used to endorse or promote products derived from this # -# software without specific prior written permission. # -# # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # -# POSSIBILITY OF SUCH DAMAGE. # -# # -############################################################################### -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "./core/PhysiCell.h" -#include "./modules/PhysiCell_standard_modules.h" - -// put custom code modules here! - -#include "./custom_modules/custom.h" - -using namespace BioFVM; -using namespace PhysiCell; - -int main( int argc, char* argv[] ) -{ - // load and parse settings file(s) - - bool XML_status = false; - char copy_command [1024]; - if( argc > 1 ) - { - XML_status = load_PhysiCell_config_file( argv[1] ); - sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() ); - } - else - { - XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" ); - sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() ); - } - if( !XML_status ) - { exit(-1); } - - // copy config file to output directry - system( copy_command ); - - // OpenMP setup - omp_set_num_threads(PhysiCell_settings.omp_num_threads); - - // time setup - std::string time_units = "min"; - - /* Microenvironment setup */ - - setup_microenvironment(); // modify this in the custom code - - /* PhysiCell setup */ - - // set mechanics voxel size, and match the data structure to BioFVM - double mechanics_voxel_size = 30; - Cell_Container* cell_container = create_cell_container_for_microenvironment( microenvironment, mechanics_voxel_size ); - - /* Users typically start modifying here. START USERMODS */ - - create_cell_types(); - - setup_tissue(); - - /* Users typically stop modifying here. END USERMODS */ - - // set MultiCellDS save options - - set_save_biofvm_mesh_as_matlab( true ); - set_save_biofvm_data_as_matlab( true ); - set_save_biofvm_cell_data( true ); - set_save_biofvm_cell_data_as_custom_matlab( true ); - - // save a simulation snapshot - - char filename[1024]; - sprintf( filename , "%s/initial" , PhysiCell_settings.folder.c_str() ); - save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); - - // save a quick SVG cross section through z = 0, after setting its - // length bar to 200 microns - - PhysiCell_SVG_options.length_bar = 200; - - // for simplicity, set a pathology coloring function - - std::vector (*cell_coloring_function)(Cell*) = my_coloring_function; - std::string (*substrate_coloring_function)(double, double, double) = paint_by_density_percentage; - - sprintf( filename , "%s/initial.svg" , PhysiCell_settings.folder.c_str() ); - SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function ); - - sprintf( filename , "%s/legend.svg" , PhysiCell_settings.folder.c_str() ); - create_plot_legend( filename , cell_coloring_function ); - - display_citations(); - - // set the performance timers - - BioFVM::RUNTIME_TIC(); - BioFVM::TIC(); - - std::ofstream report_file; - if( PhysiCell_settings.enable_legacy_saves == true ) - { - sprintf( filename , "%s/simulation_report.txt" , PhysiCell_settings.folder.c_str() ); - - report_file.open(filename); // create the data log file - report_file<<"simulated time\tnum cells\tnum division\tnum death\twall time"<update_all_cells( PhysiCell_globals.current_time ); - - /* - Custom add-ons could potentially go here. - */ - - PhysiCell_globals.current_time += diffusion_dt; - } - - if( PhysiCell_settings.enable_legacy_saves == true ) - { - log_output(PhysiCell_globals.current_time, PhysiCell_globals.full_output_index, microenvironment, report_file); - report_file.close(); - } - } - catch( const std::exception& e ) - { // reference to the base of a polymorphic object - std::cout << e.what(); // information from length_error printed - } - - // save a final simulation snapshot - - sprintf( filename , "%s/final" , PhysiCell_settings.folder.c_str() ); - save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); - - sprintf( filename , "%s/final.svg" , PhysiCell_settings.folder.c_str() ); - SVG_plot(filename, microenvironment, 0.0, PhysiCell_globals.current_time, cell_coloring_function, substrate_coloring_function); - - // timer - - std::cout << std::endl << "Total simulation runtime: " << std::endl; - BioFVM::display_stopwatch_value( std::cout , BioFVM::runtime_stopwatch_value() ); - - return 0; -} From efc9e63e5ffc81573222c3b45186790bac91b683 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 15 Aug 2024 07:58:03 -0400 Subject: [PATCH 09/12] cleanup --- core/PhysiCell_cell.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index f5b559bd7..6e1725a24 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -658,8 +658,6 @@ Cell* Cell::divide( ) child->state.damage = 0.0; child->state.total_attack_time = 0.0; - //rwh - // if( this->functions.cell_division_function && pC->is_out_of_domain == false ) if( this->functions.cell_division_function ) { this->functions.cell_division_function( this, child); } From 3b8c248c0b164d632c5201fab51d49b2f57af218 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 15 Aug 2024 07:59:51 -0400 Subject: [PATCH 10/12] cleanup --- core/PhysiCell_cell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 6e1725a24..74bed8840 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -1676,7 +1676,7 @@ void display_ptr_as_bool( void (*ptr)(Cell*,Phenotype&,Cell*,Phenotype&,double), return; } -void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os ) //rwh +void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os ) { if( ptr ) { os << "true"; return; } From 6977a7aefd81d4d42100f722fbf9b92bb8ae94cd Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 15 Aug 2024 08:26:43 -0400 Subject: [PATCH 11/12] add custom-division-sample --- sample_projects/Makefile-default | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sample_projects/Makefile-default b/sample_projects/Makefile-default index 02b313890..7ca39d93d 100644 --- a/sample_projects/Makefile-default +++ b/sample_projects/Makefile-default @@ -73,7 +73,7 @@ name: list-projects: @echo "Sample projects: template biorobots-sample cancer-biorobots-sample cancer-immune-sample" @echo " celltypes3-sample heterogeneity-sample pred-prey-farmer virus-macrophage-sample" - @echo " worm-sample interaction-sample mechano-sample rules-sample physimess-sample" + @echo " worm-sample interaction-sample mechano-sample rules-sample physimess-sample custom-division-sample" @echo "" @echo "Sample intracellular projects: template_BM ode-energy-sample physiboss-cell-lines-sample" @echo " cancer-metabolism-sample physiboss-tutorial physiboss-tutorial-invasion" @@ -198,6 +198,15 @@ physimess-sample: cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml cp -r ./sample_projects/physimess/config/* ./config/ +custom-division-sample: + cp ./sample_projects/custom_division/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/custom_division/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/custom_division/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp -r ./sample_projects/custom_division/config/* ./config/ + # ---- intracellular projects ode-energy-sample: cp ./sample_projects_intracellular/ode/ode_energy/custom_modules/* ./custom_modules/ From 1c47042e42209fe472cbcedc9bd944c504255fc5 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 15 Aug 2024 08:50:32 -0400 Subject: [PATCH 12/12] revert to original constants code --- core/PhysiCell_constants.cpp | 63 +++--------------------------- core/PhysiCell_constants.h | 74 ++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 94 deletions(-) diff --git a/core/PhysiCell_constants.cpp b/core/PhysiCell_constants.cpp index 8ade36f6b..7727c40f2 100644 --- a/core/PhysiCell_constants.cpp +++ b/core/PhysiCell_constants.cpp @@ -76,63 +76,12 @@ double mechanics_dt = 0.1; double phenotype_dt = 6.0; double intracellular_dt = 0.01; - -// currently recognized cell cycle models -const int PhysiCell_constants::advanced_Ki67_cycle_model= 0; -const int PhysiCell_constants::basic_Ki67_cycle_model=1; -const int PhysiCell_constants::flow_cytometry_cycle_model=2; -const int PhysiCell_constants::live_apoptotic_cycle_model=3; -const int PhysiCell_constants::total_cells_cycle_model=4; -const int PhysiCell_constants::live_cells_cycle_model = 5; -const int PhysiCell_constants::flow_cytometry_separated_cycle_model = 6; -const int PhysiCell_constants::cycling_quiescent_model = 7; - -// currently recognized death models -const int PhysiCell_constants::apoptosis_death_model = 100; -const int PhysiCell_constants::necrosis_death_model = 101; -const int PhysiCell_constants::autophagy_death_model = 102; - -const int PhysiCell_constants::custom_cycle_model=9999; - -// currently recognized cell cycle and death phases -// cycle phases -const int PhysiCell_constants::Ki67_positive_premitotic=0; -const int PhysiCell_constants::Ki67_positive_postmitotic=1; -const int PhysiCell_constants::Ki67_positive=2; -const int PhysiCell_constants::Ki67_negative=3; -const int PhysiCell_constants::G0G1_phase=4; -const int PhysiCell_constants::G0_phase=5; -const int PhysiCell_constants::G1_phase=6; -const int PhysiCell_constants::G1a_phase=7; -const int PhysiCell_constants::G1b_phase=8; -const int PhysiCell_constants::G1c_phase=9; -const int PhysiCell_constants::S_phase=10; -const int PhysiCell_constants::G2M_phase=11; -const int PhysiCell_constants::G2_phase=12; -const int PhysiCell_constants::M_phase=13; -const int PhysiCell_constants::live=14; - -const int PhysiCell_constants::G1pm_phase = 15; -const int PhysiCell_constants::G1ps_phase = 16; - -const int PhysiCell_constants::cycling = 17; -const int PhysiCell_constants::quiescent = 18; - - -const int PhysiCell_constants::custom_phase = 9999; -// death phases -const int PhysiCell_constants::apoptotic=100; -const int PhysiCell_constants::necrotic_swelling=101; -const int PhysiCell_constants::necrotic_lysed=102; -const int PhysiCell_constants::necrotic=103; -const int PhysiCell_constants::debris=104; - -std::unordered_map cycle_model_codes = { - - { "Ki67 (advanced)", PhysiCell_constants::advanced_Ki67_cycle_model}, - { "Ki67 (basic)" ,PhysiCell_constants::basic_Ki67_cycle_model}, - { "Flow cytometry model (basic)",PhysiCell_constants::flow_cytometry_cycle_model}, -// { ,PhysiCell_constants::live_apoptotic_cycle_model}, // not implemented +std::unordered_map cycle_model_codes = +{ + { "Ki67 (advanced)", PhysiCell_constants::advanced_Ki67_cycle_model}, + { "Ki67 (basic)" ,PhysiCell_constants::basic_Ki67_cycle_model}, + { "Flow cytometry model (basic)",PhysiCell_constants::flow_cytometry_cycle_model}, + // { ,PhysiCell_constants::live_apoptotic_cycle_model}, // not implemented // { ,PhysiCell_constants::total_cells_cycle_model}, // not implemented { "Live",PhysiCell_constants::live_cells_cycle_model}, { "Flow cytometry model (separated)",PhysiCell_constants::flow_cytometry_separated_cycle_model}, diff --git a/core/PhysiCell_constants.h b/core/PhysiCell_constants.h index 58aef3c84..476953148 100644 --- a/core/PhysiCell_constants.h +++ b/core/PhysiCell_constants.h @@ -102,54 +102,54 @@ class PhysiCell_constants static const int mesh_uz_face_index=5; // currently recognized cell cycle models - static const int advanced_Ki67_cycle_model; - static const int basic_Ki67_cycle_model; - static const int flow_cytometry_cycle_model; - static const int live_apoptotic_cycle_model; - static const int total_cells_cycle_model; - static const int live_cells_cycle_model ; - static const int flow_cytometry_separated_cycle_model ; - static const int cycling_quiescent_model ; + static const int advanced_Ki67_cycle_model= 0; + static const int basic_Ki67_cycle_model=1; + static const int flow_cytometry_cycle_model=2; + static const int live_apoptotic_cycle_model=3; + static const int total_cells_cycle_model=4; + static const int live_cells_cycle_model = 5; + static const int flow_cytometry_separated_cycle_model = 6; + static const int cycling_quiescent_model = 7; // currently recognized death models - static const int apoptosis_death_model ; - static const int necrosis_death_model ; - static const int autophagy_death_model ; + static const int apoptosis_death_model = 100; + static const int necrosis_death_model = 101; + static const int autophagy_death_model = 102; - static const int custom_cycle_model; + static const int custom_cycle_model=9999; // currently recognized cell cycle and death phases // cycle phases - static const int Ki67_positive_premitotic; - static const int Ki67_positive_postmitotic; - static const int Ki67_positive; - static const int Ki67_negative; - static const int G0G1_phase; - static const int G0_phase; - static const int G1_phase; - static const int G1a_phase; - static const int G1b_phase; - static const int G1c_phase; - static const int S_phase; - static const int G2M_phase; - static const int G2_phase; - static const int M_phase; - static const int live; + static const int Ki67_positive_premitotic=0; + static const int Ki67_positive_postmitotic=1; + static const int Ki67_positive=2; + static const int Ki67_negative=3; + static const int G0G1_phase=4; + static const int G0_phase=5; + static const int G1_phase=6; + static const int G1a_phase=7; + static const int G1b_phase=8; + static const int G1c_phase=9; + static const int S_phase=10; + static const int G2M_phase=11; + static const int G2_phase=12; + static const int M_phase=13; + static const int live=14; - static const int G1pm_phase ; - static const int G1ps_phase ; + static const int G1pm_phase = 15; + static const int G1ps_phase = 16; - static const int cycling ; - static const int quiescent ; + static const int cycling = 17; + static const int quiescent = 18; - static const int custom_phase ; + static const int custom_phase = 9999; // death phases - static const int apoptotic; - static const int necrotic_swelling; - static const int necrotic_lysed; - static const int necrotic; - static const int debris; + static const int apoptotic=100; + static const int necrotic_swelling=101; + static const int necrotic_lysed=102; + static const int necrotic=103; + static const int debris=104; }; extern std::string time_units; extern std::string space_units;