Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhysiBoSS 2.2.3 update #217

Merged
merged 9 commits into from
Jun 3, 2024
Prev Previous commit
Next Next commit
Mapping rules now have a flag to define if they work during death
  • Loading branch information
vincent-noel committed Mar 4, 2024
commit 9e9999d1d6560e314e77fdde15441bbb83035725
49 changes: 30 additions & 19 deletions addons/PhysiBoSS/src/maboss_intracellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,38 @@ void MaBoSSIntracellular::update_inputs(PhysiCell::Cell* cell, PhysiCell::Phenot
int i=0;
for (auto& input: listOfInputs)
{
if (input.second.isNode()) {
maboss.set_node_value(
input.first,
input.second.updateNode(maboss.get_node_value(input.second.intracellular_name), signals[i])
);
} else if (input.second.isParameter()) {
maboss.set_parameter_value(
input.first,
input.second.updateParameter(signals[i])
);
if (cell->phenotype.death.dead == false || input.second.use_for_dead == true) {

if (input.second.isNode()) {
maboss.set_node_value(
input.first,
input.second.updateNode(maboss.get_node_value(input.second.intracellular_name), signals[i])
);
} else if (input.second.isParameter()) {
maboss.set_parameter_value(
input.first,
input.second.updateParameter(signals[i])
);
}
}
i++;
}
}

void MaBoSSIntracellular::update_outputs(PhysiCell::Cell* cell, PhysiCell::Phenotype& phenotype, double dt)
{
std::vector<double> signals = std::vector<double>(listOfOutputs.size(), 0.0);

int i=0;

for (auto& output: listOfOutputs)
{
signals[i] = output.second.update(maboss.get_node_value(output.second.intracellular_name));
if (cell->phenotype.death.dead == false || output.second.use_for_dead == true) {
PhysiCell::set_single_behavior(
cell, indicesOfOutputs[i],
output.second.update(maboss.get_node_value(output.second.intracellular_name))
);
}
i++;
}
PhysiCell::set_selected_behaviors(cell, indicesOfOutputs, signals);
}


Expand Down Expand Up @@ -366,7 +372,8 @@ void MaBoSSIntracellular::initialize_intracellular_from_pugixml(pugi::xml_node&
node_input.attribute( "physicell_name" ).value(),
intracellular_name,
(settings && settings.child( "scaling" ) ? PhysiCell::xml_get_my_double_value( settings.child( "scaling" )) : 1.0),
(settings && settings.child( "smoothing" ) ? PhysiCell::xml_get_my_int_value( settings.child( "smoothing" )) : 0)
(settings && settings.child( "smoothing" ) ? PhysiCell::xml_get_my_int_value( settings.child( "smoothing" )) : 0),
(settings && settings.child( "use_for_dead" ) ? PhysiCell::xml_get_my_bool_value( settings.child( "use_for_dead" )) : false)
);

// This construct is a trick to avoid making inputs and outputs constructible and assignable, or using c++17 insert_or_assign
Expand All @@ -382,7 +389,8 @@ void MaBoSSIntracellular::initialize_intracellular_from_pugixml(pugi::xml_node&
PhysiCell::xml_get_my_string_value(settings.child("action")),
PhysiCell::xml_get_my_double_value(settings.child("threshold")),
(settings && settings.child( "inact_threshold" ) ? PhysiCell::xml_get_my_double_value( settings.child( "inact_threshold" )) : PhysiCell::xml_get_my_double_value(settings.child("threshold"))),
(settings && settings.child( "smoothing" ) ? PhysiCell::xml_get_my_int_value( settings.child( "smoothing" )) : 0)
(settings && settings.child( "smoothing" ) ? PhysiCell::xml_get_my_int_value( settings.child( "smoothing" )) : 0),
(settings && settings.child( "use_for_dead" ) ? PhysiCell::xml_get_my_bool_value( settings.child( "use_for_dead" )) : false)
);

auto const res = listOfInputs.insert(std::pair<std::string, MaBoSSInput>(intracellular_name, input));
Expand All @@ -404,7 +412,8 @@ void MaBoSSIntracellular::initialize_intracellular_from_pugixml(pugi::xml_node&
PhysiCell::xml_get_my_double_value(settings.child("value")),
(settings && settings.child( "base_value" ) ? PhysiCell::xml_get_my_double_value( settings.child( "base_value" )) : PhysiCell::xml_get_my_double_value(settings.child("value"))),
(settings && settings.child( "smoothing" ) ? PhysiCell::xml_get_my_int_value( settings.child( "smoothing" )) : 0),
(settings && settings.child( "steepness" ) ? PhysiCell::xml_get_my_int_value( settings.child( "steepness" )) : 10)
(settings && settings.child( "steepness" ) ? PhysiCell::xml_get_my_int_value( settings.child( "steepness" )) : 10),
(settings && settings.child( "use_for_dead" ) ? PhysiCell::xml_get_my_bool_value( settings.child( "use_for_dead" )) : false)
);

auto const res = listOfOutputs.insert(std::pair<std::string, MaBoSSOutput>(physicell_name, output));
Expand Down Expand Up @@ -443,14 +452,16 @@ void MaBoSSIntracellular::display(std::ostream& os)
os << "\t\t " << listOfInputs.size() << " input mapping defined" << std::endl;
for (const auto& input : listOfInputs)
os << "\t\t\t" << input.second.physicell_name << " = " << input.first
<< "(" << input.second.threshold << ", " << input.second.inact_threshold << ", " << input.second.smoothing << ")"
<< "(" << input.second.threshold << ", " << input.second.inact_threshold
<< ", " << input.second.smoothing << ", " << input.second.use_for_dead << ")"
<< std::endl;

os << "\t\t " << listOfOutputs.size() << " output mapping defined" << std::endl;
for (const auto& output : listOfOutputs)
os << "\t\t\t" << output.first << " = " << output.second.intracellular_name
<< "(" << output.second.value << ", " << output.second.base_value
<< ", " << output.second.smoothing << ", " << output.second.steepness << ")"
<< ", " << output.second.smoothing << ", " << output.second.steepness
<< ", " << output.second.use_for_dead << ")"
<< std::endl;

os << "\t\t global inheritance = " << inherit_state << std::endl;
Expand Down
10 changes: 4 additions & 6 deletions addons/PhysiBoSS/src/maboss_intracellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ class MaBoSSIntracellular : public PhysiCell::Intracellular {
}

void update(PhysiCell::Cell * cell, PhysiCell::Phenotype& phenotype, double dt) {
if (!cell->phenotype.death.dead) {
this->update_inputs(cell, phenotype, dt);
this->maboss.run_simulation();
this->update_outputs(cell, phenotype, dt);
this->next_physiboss_run += this->maboss.get_time_to_update();
}
this->update_inputs(cell, phenotype, dt);
this->maboss.run_simulation();
this->update_outputs(cell, phenotype, dt);
this->next_physiboss_run += this->maboss.get_time_to_update();
}

bool need_update() {
Expand Down
11 changes: 7 additions & 4 deletions addons/PhysiBoSS/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class MaBoSSInput
double scaling;
int smoothing;
double smoothed_value;
MaBoSSInput(std::string physicell_name, std::string intracellular_name, std::string action, double threshold, double inact_threshold, int smoothing) : physicell_name(physicell_name), intracellular_name(intracellular_name), action(action), threshold(threshold), inact_threshold(inact_threshold), smoothing(smoothing) {
bool use_for_dead;

MaBoSSInput(std::string physicell_name, std::string intracellular_name, std::string action, double threshold, double inact_threshold, int smoothing, bool use_for_dead) : physicell_name(physicell_name), intracellular_name(intracellular_name), action(action), threshold(threshold), inact_threshold(inact_threshold), smoothing(smoothing), use_for_dead(use_for_dead){
type = NODE;
smoothed_value = 0;
}

MaBoSSInput(std::string physicell_name, std::string intracellular_parameter, double scaling, int smoothing) : physicell_name(physicell_name), intracellular_parameter(intracellular_parameter), scaling(scaling), smoothing(smoothing) {
MaBoSSInput(std::string physicell_name, std::string intracellular_parameter, double scaling, int smoothing, bool use_for_dead) : physicell_name(physicell_name), intracellular_parameter(intracellular_parameter), scaling(scaling), smoothing(smoothing), use_for_dead(use_for_dead) {
type = PARAMETER;
smoothed_value = 0;
}
Expand Down Expand Up @@ -84,13 +86,14 @@ class MaBoSSOutput
double probability;
bool initialized = false;
int steepness;
bool use_for_dead;

MaBoSSOutput(std::string physicell_name, std::string intracellular_name,
std::string action, double value, double base_value,
int smoothing, int steepness)
int smoothing, int steepness, bool use_for_dead)
: physicell_name(physicell_name), intracellular_name(intracellular_name),
action(action), value(value), base_value(base_value),
smoothing(smoothing), steepness(steepness) {
smoothing(smoothing), steepness(steepness), use_for_dead(use_for_dead) {
probability = 0.5;
}

Expand Down