Ejemplo n.º 1
0
 def selected_row_data_with_index(self):
     return [[index, self.get_row(index)]
             for index in get_selected_listctrl_items(self.layout)]
Ejemplo n.º 2
0
 def selected_indices(self):
     return get_selected_listctrl_items(self.list_ctrl)
Ejemplo n.º 3
0
    def apply_parameters(self, evt):
        """
        Calculate rad bio values based on parameters supplied by user, pass information on to other tabs in GUI
        """

        # Convert user supplied parameters from text to floats
        eud_a = float_or_none(self.text_input_eud_a.GetValue())
        gamma_50 = float_or_none(self.text_input_gamma_50.GetValue())
        td_50 = float_or_none(self.text_input_td_50.GetValue())

        groups = [[1], [2], [1, 2]][self.radio_box_query_group.GetSelection()]

        for grp in groups:
            data = self.group_data[grp]
            if data['dvh']:
                # Get the indices of the selected rows, or assume all should be updated
                selected_indices = get_selected_listctrl_items(
                    self.table_rad_bio[grp])
                if not selected_indices:
                    selected_indices = range(
                        self.data_table_rad_bio[grp].row_count)

                # set the data in the datatable for the selected indices
                for i in selected_indices:
                    current_row = self.data_table_rad_bio[grp].get_row(i)
                    for j in [7, 9]:
                        current_row[j] = convert_value_to_str(current_row[j])
                    new_row = deepcopy(current_row)
                    new_row[2] = eud_a
                    new_row[3] = gamma_50
                    new_row[4] = td_50
                    try:
                        eud = calc_eud(data['dvh'].dvh[:, i],
                                       eud_a,
                                       dvh_bin_width=data['dvh'].dvh_bin_width)
                        new_row[5] = "%0.2f" % round(eud, 2)
                    except Exception:
                        new_row[5] = 'None'
                    try:
                        new_row[6] = "%0.2f" % round(
                            calc_tcp(gamma_50, td_50, float(new_row[5])), 3)
                    except Exception:
                        new_row[6] = 'None'
                    self.data_table_rad_bio[grp].edit_row(new_row, i)

                # Update data in in dvh object
                data['dvh'].eud = []
                data['dvh'].ntcp_or_tcp = []
                for i, eud in enumerate(
                        self.data_table_rad_bio[grp].data['EUD']):
                    data['dvh'].eud.append(float_or_none(eud))
                    data['dvh'].ntcp_or_tcp.append(
                        float_or_none(
                            self.data_table_rad_bio[grp].data['NTCP or TCP']
                            [i]))

                data['stats_data'].update_endpoints_and_radbio()
                if grp == 2:
                    sync_variables_in_stats_data_objects(
                        self.group_data[1]['stats_data'],
                        self.group_data[2]['stats_data'])

                # update data in time series
                self.time_series.update_y_axis_options()
                if self.time_series.combo_box_y_axis.GetValue() in [
                        'EUD', 'NTCP or TCP'
                ]:
                    self.time_series.update_plot()

                # update data in regression
                self.regression.update_combo_box_choices()

                # update data in control chart
                self.control_chart.update_combo_box_y_choices()
                if self.control_chart.combo_box_y_axis.GetValue() in [
                        'EUD', 'NTCP or TCP'
                ]:
                    self.control_chart.update_plot()