PhysiCell icon indicating copy to clipboard operation
PhysiCell copied to clipboard

Fix bug related to maximum/minimum saturation values and uniqueness test for rules

Open heberlr opened this issue 1 year ago • 5 comments

In the previous implementation, the last rule determined the maximum or minimum response of the behavior. In the current update, the behavior now checks for the maximum and minimum response in all rules. In cases where the minimum or maximum values do not exist, the system defaults to using the base value.

heberlr avatar Feb 21 '24 15:02 heberlr

I think this is something we want to address. It never feels right to assign a parameter value that is used only when the stars align. So, this seems like a good step in that direction. It looks like changes were not made for v0? I can't say I'm well-versed in that version, so not sure if that's an issue. It looks like v0 will use the last signal to set the min/max behaviors as well as the base_value?

On a similar note, I think a more longterm solution is to move to an XML-based rules specification. I have a branch with this implemented: https://github.com/drbergman/PhysiCell/tree/feature-xml-rules Happy to make a PR on this to MathCancer:development if others agree.

drbergman avatar Feb 21 '24 15:02 drbergman

Thanks for pointing that out. I've incorporated tests into the v0 rules as well. During testing, I experimented with the rules listed below within the template project, making order changes, and selectively including or removing rules. I also checked the behavior by printing the values of min, base, and max in the evaluate() method of the Hypothesis_rules class, using an old-school debugging style.

rules v0: default,cycle entry,0.00333333333333333333333333,0.00333333333333333333333333,0.033,pO2,increases,21.5,4,0 default,cycle entry,0.00333333333333333333333333,0.00333333333333333333333333,0.022,estrogen,increases,0.5,3,0 default,cycle entry,0,0.00333333333333333333333333,0.00333333333333333333333333,pressure,decreases,0.25,3,0

rules v1: default,pO2,increases,cycle entry,0.00333333333333333333333333,0.033,21.5,4,0 default,estrogen,increases,cycle entry,0.00333333333333333333333333,0.022,0.5,3,0 default,pressure,decreases,cycle entry,0.00333333333333333333333333,0,0.25,3,0

rules v2: default,pO2,increases,cycle entry,0.033,21.5,4,0 default,estrogen,increases,cycle entry,0.022,0.5,3,0 default,pressure,decreases,cycle entry,0,0.25,3,0

print code:

std::cout << "Min: " << min_value << "  Base: " << base_value << "  Max: " << max_value << std::endl;
	for( int j=0; j < signal_values.size(); j++ ){
		std::cout << "\tSignal: " << signal_values[j] << "  Response: " << responses[j] << std::endl;

P.S.: I believe that having the option to include rules in the XML could be very interesting.

heberlr avatar Feb 21 '24 17:02 heberlr

As discussed, the rule is defined as unique if the cell, behavior, signal, and response are equal. Previously, the test only included the signal; in this pull request, we have added the response test. I test it with these rules:

default,substrate,increases,cycle entry,0.003333,0.2,10,0 default,substrate,decreases,cycle entry,0,0.5,10,0

This figure show that the rules is working (xml attached). snapshot

heberlr avatar Apr 26 '24 16:04 heberlr

Can you confirm that these cells are using the Live Cell model?

drbergman avatar Apr 26 '24 17:04 drbergman

Yes, they are using live cell model. I will send you the xml and IC by slack.

heberlr avatar Apr 26 '24 17:04 heberlr