示例#1
0
    def UpdateContribution(self):
        if not self.checkContributionShow.isChecked():
            return

        if self.radioContributionFeatureSelector.isChecked():
            file_name = self.comboContributionFeatureSelector.currentText() + '_sort.csv'
            file_path = self._SearchSpecificFile(file_name, int(self._fae.GetFeatureNumberList()[0]))
            if file_path:
                df = pd.read_csv(file_path, index_col=0)

                feature_name = list(df.index)
                value = list(np.abs(df.iloc[:, 0]))

                GeneralFeatureSort(feature_name, value, max_num=self.spinFeatureSelectorFeatureNumber.value(),
                                   is_show=False, fig=self.canvasFeature.getFigure())
        elif self.radioContributionClassifier.isChecked():
            specific_name = self.comboContributionClassifier.currentText() + '_coef.csv'
            file_path = self._SearchSpecificFile(specific_name, self.spinClassifierFeatureNumber.value())
            if file_path:
                df = pd.read_csv(file_path, index_col=0)
                feature_name = list(df.index)
                value = list(np.abs(df.iloc[:, 0]))
                try:
                    SortRadiomicsFeature(feature_name, value, is_show=False, fig=self.canvasFeature.getFigure())
                except:
                    GeneralFeatureSort(feature_name, value,
                                       is_show=False, fig=self.canvasFeature.getFigure())


        self.canvasFeature.draw()
示例#2
0
    def UpdateContribution(self):
        if not self.checkContributionShow.isChecked():
            return

        if self.radioContributionFeatureSelector.isChecked():
            file_name = self.comboContributionFeatureSelector.currentText() + '_sort.csv'
            file_path = self._SearchSpecificFile(int(self._fae.GetFeatureNumberList()[0]), file_name)
            if file_path:
                df = pd.read_csv(file_path, index_col=0)

                feature_name = list(df.index)
                value = list(np.abs(df.iloc[:, 0]))

                #add positive and negatiove info for coef
                processed_feature_name = list(df.index)
                original_value = list(df.iloc[:, 0])
                for index in range(len(original_value)):
                    if original_value[index] > 0:
                        processed_feature_name[index] = processed_feature_name[index] + 'P'
                    else:
                        processed_feature_name[index] = processed_feature_name[index] + 'N'


                GeneralFeatureSort(processed_feature_name, value, max_num=self.spinFeatureSelectorFeatureNumber.value(),
                                   is_show=False, fig=self.canvasFeature.getFigure())
        elif self.radioContributionClassifier.isChecked():
            specific_name = self.comboContributionClassifier.currentText() + '_coef.csv'
            feature_selector_name = self.comboContributionFeatureSelector.currentText()
            file_path = self._SearchSpecificFile(self.spinClassifierFeatureNumber.value(), specific_name, feature_selector_name)
            if file_path:
                df = pd.read_csv(file_path, index_col=0)
                feature_name = list(df.index)
                value = list(np.abs(df.iloc[:, 0]))

                #add positive and negatiove info for coef
                processed_feature_name = list(df.index)
                original_value = list(df.iloc[:, 0])
                for index in range(len(original_value)):
                    if original_value[index] > 0:
                        processed_feature_name[index] = processed_feature_name[index] + ' P'
                    else:
                        processed_feature_name[index] = processed_feature_name[index] + ' N'

                try:
                    SortRadiomicsFeature(processed_feature_name, value, is_show=False, fig=self.canvasFeature.getFigure())
                except:
                    GeneralFeatureSort(processed_feature_name, value,
                                       is_show=False, fig=self.canvasFeature.getFigure())


        self.canvasFeature.draw()
示例#3
0
    def UpdateContribution(self):
        if (not self.__is_ui_ready) or self.__is_clear:
            return

        try:
            pipeline_name = self._fae.GetStoreName(
                self.comboContributionNormalizor.currentText(),
                self.comboContributionDimension.currentText(),
                self.comboContributionFeatureSelector.currentText(),
                str(self.spinContributeFeatureNumber.value()),
                self.comboContributionClassifier.currentText())
            norm_folder, dr_folder, fs_folder, cls_folder = self._fae.SplitFolder(
                pipeline_name, self._root_folder)

            if self.radioContributionFeatureSelector.isChecked():
                file_name = self.comboContributionFeatureSelector.currentText(
                ) + '_sort.csv'
                file_path = os.path.join(fs_folder, file_name)

                if file_path:
                    df = pd.read_csv(file_path, index_col=0)
                    value = list(df.iloc[:, 0])

                    sort_by = df.columns.values[0]
                    if sort_by == 'rank':
                        reverse = False
                    elif sort_by == 'F' or sort_by == 'weight':
                        reverse = True
                    else:
                        reverse = False
                        print('Invalid feature selector sort name.')

                    # add positive and negatiove info for coef
                    processed_feature_name = list(df.index)
                    original_value = list(df.iloc[:, 0])
                    for index in range(len(original_value)):
                        if original_value[index] > 0:
                            processed_feature_name[
                                index] = processed_feature_name[index] + ' P'
                        else:
                            processed_feature_name[
                                index] = processed_feature_name[index] + ' N'

                    GeneralFeatureSort(
                        processed_feature_name,
                        value,
                        max_num=self.spinContributeFeatureNumber.value(),
                        is_show=False,
                        fig=self.canvasFeature.getFigure(),
                        reverse=reverse)

            elif self.radioContributionClassifier.isChecked():
                specific_name = self.comboContributionClassifier.currentText(
                ) + '_coef.csv'
                file_path = os.path.join(cls_folder, specific_name)

                if os.path.exists(file_path):
                    df = pd.read_csv(file_path, index_col=0)
                    value = list(np.abs(df.iloc[:, 0]))

                    # add positive and negatiove info for coef
                    processed_feature_name = list(df.index)
                    original_value = list(df.iloc[:, 0])
                    for index in range(len(original_value)):
                        if original_value[index] > 0:
                            processed_feature_name[
                                index] = processed_feature_name[index] + ' P'
                        else:
                            processed_feature_name[
                                index] = processed_feature_name[index] + ' N'

                    GeneralFeatureSort(processed_feature_name,
                                       value,
                                       is_show=False,
                                       fig=self.canvasFeature.getFigure())
            self.canvasFeature.draw()
        except Exception as e:
            content = 'In Visualization, UpdateContribution failed'
            self.logger.error('{}{}'.format(content, str(e)))
            QMessageBox.about(self, content, e.__str__())
示例#4
0
    def UpdateContribution(self):
        if not self.__is_ui_ready:
            return

        try:
            one_result_folder_name = self.comboContributionNormalizor.currentText() + '_' + \
                                self.comboContributionDimension.currentText() + '_' + \
                                self.comboContributionFeatureSelector.currentText() + '_' + \
                                str(self.spinContributeFeatureNumber.value()) + '_' + \
                                self.comboContributionClassifier.currentText()
            one_result_folder = os.path.join(self._root_folder, one_result_folder_name)
            # This is compatible with the previous version
            if not os.path.exists(one_result_folder):
                one_result_folder_name = self.comboContributionNormalizor.currentText() + '_Cos_' + \
                                         self.comboContributionFeatureSelector.currentText() + '_' + \
                                         str(self.spinContributeFeatureNumber.value()) + '_' + \
                                         self.comboContributionClassifier.currentText()
                one_result_folder = os.path.join(self._root_folder, one_result_folder_name)

            if self.radioContributionFeatureSelector.isChecked():
                file_name = self.comboContributionFeatureSelector.currentText() + '_sort.csv'
                file_path = os.path.join(one_result_folder, file_name)

                if not os.path.exists(file_path):
                    file_name = self.comboContributionFeatureSelector.currentText().lower() + '_sort.csv'
                    file_path = os.path.join(one_result_folder, file_name)

                if file_path:
                    df = pd.read_csv(file_path, index_col=0)
                    value = list(df.iloc[:, 0])

                    #add positive and negatiove info for coef
                    processed_feature_name = list(df.index)
                    original_value = list(df.iloc[:, 0])
                    for index in range(len(original_value)):
                        if original_value[index] > 0:
                            processed_feature_name[index] = processed_feature_name[index] + ' P'
                        else:
                            processed_feature_name[index] = processed_feature_name[index] + ' N'

                    GeneralFeatureSort(processed_feature_name, value, max_num=self.spinContributeFeatureNumber.value(),
                                       is_show=False, fig=self.canvasFeature.getFigure())

            elif self.radioContributionClassifier.isChecked():
                specific_name = self.comboContributionClassifier.currentText() + '_coef.csv'
                file_path = os.path.join(one_result_folder, specific_name)

                if not os.path.exists(file_path):
                    specific_name = self.comboContributionClassifier.currentText().lower() + '_coef.csv'
                    file_path = os.path.join(one_result_folder, specific_name)

                if file_path:
                    df = pd.read_csv(file_path, index_col=0)
                    feature_name = list(df.index)
                    value = list(np.abs(df.iloc[:, 0]))

                    #add positive and negatiove info for coef
                    processed_feature_name = list(df.index)
                    original_value = list(df.iloc[:, 0])
                    for index in range(len(original_value)):
                        if original_value[index] > 0:
                            processed_feature_name[index] = processed_feature_name[index] + ' P'
                        else:
                            processed_feature_name[index] = processed_feature_name[index] + ' N'

                    # try:
                    #     SortRadiomicsFeature(processed_feature_name, value, is_show=False, fig=self.canvasFeature.getFigure())
                    # except:
                    GeneralFeatureSort(processed_feature_name, value,
                                           is_show=False, fig=self.canvasFeature.getFigure())
            self.canvasFeature.draw()
        except Exception as e:
            content = 'In Visualization, UpdateContribution failed'
            self.logger.error('{}{}'.format(content, str(e)))
            QMessageBox.about(self, content, e.__str__())