Esempio n. 1
0
    def __init__(self, main_app_frame, model_file_path, group_data, group,
                 options):
        self.loaded_data = load_object_from_file(model_file_path)
        self.stats_data = group_data[group]['stats_data']
        try:
            if self.is_valid:
                y_variable = self.loaded_data['y_variable']
                x_variables = self.loaded_data['x_variables']
                stats_data = group_data[group]['stats_data']

                MultiVarResultsFrame.__init__(self,
                                              main_app_frame,
                                              y_variable,
                                              x_variables,
                                              group_data,
                                              group,
                                              options,
                                              auto_update_plot=False)
                X, y = stats_data.get_X_and_y(y_variable, x_variables)

                reg = MultiVariableRegression(
                    X, y, saved_reg=self.loaded_data['regression'])
                self.plot.update_plot(y_variable,
                                      x_variables,
                                      self.stats_data,
                                      reg=reg)

                self.Show()
            else:
                if self.stats_data is None:
                    msg = 'No data has been queried for Group %s.' % group
                elif not self.is_mvr:
                    msg = 'Selected file is not a valid multi-variable regression save file.'
                elif not self.stats_data_has_y:
                    msg = "The model's dependent variable is not found in your queried data:\n%s" % self.y_variable
                elif self.missing_x_variables:
                    msg = 'Your queried data is missing the following independent variables:\n%s' % \
                          ', '.join(self.missing_x_variables)
                else:
                    msg = 'Unknown error.'

                wx.MessageBox(msg, 'Model Loading Error',
                              wx.OK | wx.OK_DEFAULT | wx.ICON_WARNING)
        except Exception as e:
            msg = str(e)
            wx.MessageBox(msg, 'Model Loading Error',
                          wx.OK | wx.OK_DEFAULT | wx.ICON_WARNING)
Esempio n. 2
0
    def load_data_obj(self, abs_file_path):
        self.save_data = load_object_from_file(abs_file_path)
        self.group_data = self.save_data['group_data']

        # .load_save_data loses column widths?
        self.radio_button_query_group.SetSelection(0)
        self.data_table_categorical.load_save_data(self.save_data['main_categorical_1'])
        self.data_table_numerical.load_save_data(self.save_data['main_numerical_1'])

        self.control_chart.load_save_data(self.save_data['control_chart'])

        self.radio_button_query_group.SetSelection(0)
        self.exec_query(load_saved_dvh_data=True, group=1)

        if 'main_categorical_2' in self.save_data.keys():
            self.radio_button_query_group.SetSelection(1)
            self.on_group_select()
            self.data_table_categorical.load_save_data(self.save_data['main_categorical_2'])
            self.data_table_numerical.load_save_data(self.save_data['main_numerical_2'])
            self.update_all_query_buttons()

            self.exec_query(load_saved_dvh_data=True, group=2)

        self.update_all_query_buttons()

        self.endpoint.load_save_data(self.save_data['endpoint'])
        if self.endpoint.has_data:
            self.endpoint.enable_buttons()

        self.radbio.load_save_data(self.save_data['radbio'])

        self.endpoint.update_endpoints_in_dvh()

        self.group_data[1]['stats_data'].update_endpoints_and_radbio()
        if self.group_data[2]['stats_data']:
            self.group_data[2]['stats_data'].update_endpoints_and_radbio()

        self.time_series.load_save_data(self.save_data['time_series'])
        self.time_series.update_plot()

        self.regression.update_combo_box_choices()
        self.regression.load_save_data(self.save_data['regression'])

        self.control_chart.update_combo_box_y_choices()