|
def update_rules(self): |
|
# Remove the behavior widgets from layout |
|
while self.layout_behavior_sliders.count(): |
|
widget = self.layout_behavior_sliders.takeAt(0).widget() |
|
if widget is not None: |
|
widget.deleteLater() |
|
|
|
# Get the behavior values |
|
list_baseValue = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['direction'] == "decreases")]['base_behavior'].tolist() |
|
list_UpReg = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['direction'] == "increases")]['saturation'].tolist() |
|
list_DownReg = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['direction'] == "decreases")]['saturation'].tolist() |
|
# Using the max and min of saturation to define UP and Down regulation |
|
try: baseBehavior = list_baseValue[0] |
|
except IndexError: baseBehavior = 0.0 |
|
try: minBehavior = min(list_DownReg) |
|
except ValueError: minBehavior = 0.0 |
|
try: maxBehavior = max(list_UpReg) |
|
except ValueError: maxBehavior = 0.0 |
|
# print(self.combobox_behavior.currentText(), baseBehavior, maxBehavior, minBehavior) |
|
|
|
# Sliders of behavior |
|
self.sliders_behavior = BehaviorWidget( self.combobox_behavior.currentText(), baseBehavior, maxBehavior, minBehavior, 0.01*self.behavior_variation.value() ) |
|
self.layout_behavior_sliders.addWidget( self.sliders_behavior ) |
|
# Disable sliders |
|
if len(list_DownReg) == 0: |
|
self.sliders_behavior.slider_down_behavior.setEnabled(False) |
|
self.sliders_behavior.slider_down_behavior.label.setStyleSheet("color: gray;") # gray color on the label |
|
if len(list_UpReg) == 0: |
|
self.sliders_behavior.slider_up_behavior.setEnabled(False) |
|
self.sliders_behavior.slider_up_behavior.label.setStyleSheet("color: gray;") # gray color on the label |
|
|
|
# Get the signals list |
|
list_signals = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText())]['signal'].unique().tolist() |
|
|
|
# Clear the combo box of signals to plot |
|
self.combobox_signal_plot.clear() |
|
self.combobox_signal_plot.addItems(list_signals) |
|
|
|
# Remove the signals widgets from layout |
|
while self.layout_signals.count(): |
|
widget = self.layout_signals.takeAt(0).widget() |
|
if widget is not None: |
|
widget.deleteLater() |
|
|
|
# Label and Sliders of signals |
|
halfmax_max = -np.inf |
|
# Signal variation input |
|
frac_var = 0.01*self.signal_variation.value() |
|
for signal in list_signals: |
|
signal_direction = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['signal'] == signal)]['direction'].to_numpy() |
|
signal_halfmax = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['signal'] == signal)]['half_max'].to_numpy() |
|
signal_hillpower = self.dataframe.loc[(self.dataframe["cell"] == self.combobox_cell.currentText()) & |
|
(self.dataframe['behavior'] == self.combobox_behavior.currentText()) & |
|
(self.dataframe['signal'] == signal)]['hill_power'].to_numpy() |
|
|
|
if ( len(signal_direction) > 1): # two rules with same signal and different directions |
|
# Add the signal sliders |
|
self.layout_signals.addWidget( SignalWidget( signal, signal_direction[0], signal_halfmax[0], signal_hillpower[0], frac_var= frac_var) ) |
|
self.layout_signals.addWidget( SignalWidget( signal, signal_direction[1], signal_halfmax[1], signal_hillpower[1], frac_var= frac_var) ) |
|
# Check maximum half max of signal |
|
halfmax_max_temp = max([signal_halfmax[0], signal_halfmax[1]]) # the signal discretization based on the max halfmax |
|
if (halfmax_max < halfmax_max_temp): halfmax_max = halfmax_max_temp |
|
|
|
else: |
|
# Add the signal sliders |
|
self.layout_signals.addWidget( SignalWidget( signal, signal_direction[0], signal_halfmax[0], signal_hillpower[0], frac_var= frac_var) ) |
|
# Check maximum half max of signal |
|
if (halfmax_max < signal_halfmax[0]): halfmax_max = signal_halfmax[0] |
|
|
|
# Set initial value of plot signal (customizable) |
|
self.float_min_signal.setValue(halfmax_max*(1-frac_var)) |
|
self.float_max_signal.setValue(halfmax_max*(1+frac_var)) |
Observed behavior
Updating the
Signal range scale +/- (%)QSpinBoxsets the signal inPlot the signal:QComboBoxback to the first item in that list. This is from the callback toupdate_rules.Expected behavior
Signal remains unchanged when the range scale is updated.
Suggested fix
Not sure. I'm unclear what the scope of
update_rulesis and how to refactor it.Relevant lines
PhysiCell-Studio/bin/multivariate_rules.py
Line 295 in 19597b7
update_rulesdefinition:PhysiCell-Studio/bin/multivariate_rules.py
Lines 357 to 439 in 19597b7
PhysiCell-Studio/bin/multivariate_rules.py
Lines 398 to 400 in 19597b7
Note on
update_ruleupdate_rulesis also issued in two other places:+/- Behavior range sacle +/- (%)QSpinBoxBehavior:QComboBox