|
|
|
|
@ -3,12 +3,14 @@ from pathlib import Path
|
|
|
|
|
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
from PySide6.QtCore import QCoreApplication
|
|
|
|
|
from PySide6.QtGui import QColor
|
|
|
|
|
from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication, QTableWidget, QTableWidgetItem
|
|
|
|
|
from matplotlib import gridspec
|
|
|
|
|
from matplotlib.backends.backend_qt import NavigationToolbar2QT
|
|
|
|
|
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg
|
|
|
|
|
from numpy import array, int64, append, zeros, full, where, nan, arange, float64, isnan, place, count_nonzero, all as np_all
|
|
|
|
|
from numpy import array, int64, append, zeros, full, where, nan, arange, float64, isnan, place, count_nonzero, \
|
|
|
|
|
all as np_all, split
|
|
|
|
|
from overrides import overrides
|
|
|
|
|
from pandas import read_csv, DataFrame
|
|
|
|
|
from scipy.signal import resample, iirfilter, lfilter
|
|
|
|
|
@ -99,7 +101,7 @@ class SettingWindow(QMainWindow):
|
|
|
|
|
"Save": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL /
|
|
|
|
|
Path(str(self.sampID)))),
|
|
|
|
|
},
|
|
|
|
|
"Mode": "Undefined",
|
|
|
|
|
"Mode": "30s",
|
|
|
|
|
"DataPartNum": 0,
|
|
|
|
|
"CurrentDataIdx": 0,
|
|
|
|
|
"CurrentPartNum": 1,
|
|
|
|
|
@ -225,6 +227,33 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
|
|
|
|
|
self.ui.pushButton_input_setting.clicked.connect(self.setting.show)
|
|
|
|
|
self.ui.pushButton_input.clicked.connect(self.__slot_btn_input__)
|
|
|
|
|
self.ui.pushButton_prev.clicked.connect(self.__slot_btn_move__)
|
|
|
|
|
self.ui.pushButton_next.clicked.connect(self.__slot_btn_move__)
|
|
|
|
|
self.ui.tableWidget_a1.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.tableWidget_a2.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.tableWidget_b1.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.tableWidget_b2.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.tableWidget_c.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.tableWidget_f.cellDoubleClicked.connect(self.__slot_tablewidget_on_cell_double_clicked__)
|
|
|
|
|
self.ui.checkBox_highlight_longest_continuous.clicked.connect(self.__slot_checkBox_highlight_longest_continuous__)
|
|
|
|
|
self.ui.checkBox_display_afterfilter.clicked.connect(self.__slot_checkBox_display_afterfilter__)
|
|
|
|
|
self.ui.pushButton_invalid_signal_label.clicked.connect(self.__slot_btn_invalid_signal_label__)
|
|
|
|
|
self.ui.pushButton_Ctype_signal_label.clicked.connect(self.__slot_btn_Ctype_signal_label__)
|
|
|
|
|
self.ui.pushButton_a1.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.pushButton_a2.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.pushButton_b1.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.pushButton_b2.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.pushButton_c.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.pushButton_f.clicked.connect(self.__slot_btn_label__)
|
|
|
|
|
self.ui.checkBox_allin.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
self.ui.checkBox_type1.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
self.ui.checkBox_type2.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
self.ui.checkBox_type3.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
self.ui.checkBox_type4.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
self.ui.checkBox_type5.clicked.connect(self.__slot_checkBox__)
|
|
|
|
|
|
|
|
|
|
self.ui.pushButton_prev.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.BCG_QUALITY_LABEL_BTN_PREV_SHORTCUT_KEY))
|
|
|
|
|
self.ui.pushButton_next.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.BCG_QUALITY_LABEL_BTN_NEXT_SHORTCUT_KEY))
|
|
|
|
|
|
|
|
|
|
@overrides
|
|
|
|
|
def closeEvent(self, event):
|
|
|
|
|
@ -260,7 +289,17 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
|
|
|
|
|
if sender == self.ui.pushButton_input:
|
|
|
|
|
if (sender == self.ui.pushButton_input or
|
|
|
|
|
sender == self.ui.pushButton_prev or
|
|
|
|
|
sender == self.ui.pushButton_next or
|
|
|
|
|
self.ui.tableWidget_a1 or
|
|
|
|
|
self.ui.tableWidget_a2 or
|
|
|
|
|
self.ui.tableWidget_b1 or
|
|
|
|
|
self.ui.tableWidget_b2 or
|
|
|
|
|
self.ui.tableWidget_c or
|
|
|
|
|
self.ui.tableWidget_f or
|
|
|
|
|
self.ui.checkBox_highlight_longest_continuous or
|
|
|
|
|
self.ui.checkBox_display_afterfilter):
|
|
|
|
|
try:
|
|
|
|
|
artifact_type_seq = array([])
|
|
|
|
|
artifact_type_seq = artifact_type_seq.astype(int64)
|
|
|
|
|
@ -413,10 +452,16 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
self.change_tablewidget_mode()
|
|
|
|
|
self.update_tableWidget()
|
|
|
|
|
self.update_status()
|
|
|
|
|
ButtonState["Current"]["pushButton_input_setting"] = True
|
|
|
|
|
ButtonState["Current"]["pushButton_input"] = True
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
ButtonState["Current"]["pushButton_input_setting"] = False
|
|
|
|
|
ButtonState["Current"]["pushButton_input"] = False
|
|
|
|
|
ButtonState["Current"]["pushButton_invalid_signal_label"] = True
|
|
|
|
|
ButtonState["Current"]["pushButton_Ctype_signal_label"] = True
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
ButtonState["Current"]["pushButton_Ctype_signal_label"] = True
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
ButtonState["Current"]["pushButton_Ctype_signal_label"] = False
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
ButtonState["Current"]["pushButton_prev"] = True
|
|
|
|
|
ButtonState["Current"]["pushButton_next"] = True
|
|
|
|
|
ButtonState["Current"]["pushButton_save"] = True
|
|
|
|
|
@ -431,6 +476,270 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
|
|
|
|
|
PublicFunc.finish_operation(self, ButtonState)
|
|
|
|
|
|
|
|
|
|
def __slot_btn_move__(self):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
|
|
|
|
|
if sender == self.ui.pushButton_prev:
|
|
|
|
|
if Config["CurrentPartNum"] == 1:
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_VIEWING_THE_FIRST_PART, Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
PublicFunc.msgbox_output(self, Constants.BCG_QUALITY_LABEL_VIEWING_THE_FIRST_PART, Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
return
|
|
|
|
|
Config["CurrentPartNum"] -= 1
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
Config["CurrentDataIdx"] -= Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
Config["CurrentDataIdx"] -= Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
while (self.ui.checkBox_examine_tobeLabeled.isChecked() and
|
|
|
|
|
self.data.df_label.at[
|
|
|
|
|
Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] != Constants.BCG_QUALITY_LABEL_TOBELABELED):
|
|
|
|
|
Config["CurrentPartNum"] -= 1
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
Config["CurrentDataIdx"] -= Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
Config["CurrentDataIdx"] -= Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
if Config["CurrentPartNum"] == 0:
|
|
|
|
|
Config["CurrentPartNum"] = 1
|
|
|
|
|
Config["CurrentDataIdx"] = 0
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_VIEWING_THE_FIRST_PART_UNLABELED,
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
PublicFunc.msgbox_output(self, Constants.BCG_QUALITY_LABEL_VIEWING_THE_FIRST_PART_UNLABELED,
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
break
|
|
|
|
|
elif sender == self.ui.pushButton_next:
|
|
|
|
|
if Config["CurrentPartNum"] == Config["DataPartNum"]:
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_VIEWING_THE_LAST_PART, Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
PublicFunc.msgbox_output(self, Constants.BCG_QUALITY_LABEL_VIEWING_THE_LAST_PART, Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
return
|
|
|
|
|
Config["CurrentPartNum"] += 1
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
Config["CurrentDataIdx"] += Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
Config["CurrentDataIdx"] += Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
while (self.ui.checkBox_examine_tobeLabeled.isChecked() and
|
|
|
|
|
self.data.df_label.at[
|
|
|
|
|
Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] != Constants.BCG_QUALITY_LABEL_TOBELABELED):
|
|
|
|
|
Config["CurrentPartNum"] += 1
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
Config["CurrentDataIdx"] += Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
Config["CurrentDataIdx"] += Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
if Config["CurrentPartNum"] == Config["DataPartNum"] + 1:
|
|
|
|
|
Config["CurrentPartNum"] = Config["DataPartNum"]
|
|
|
|
|
if Config["Mode"] == "10s":
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["DataPartNum"] - 1) * Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
elif Config["Mode"] == "30s":
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["DataPartNum"] - 1) * Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_VIEWING_THE_LAST_PART_UNLABELED,
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
PublicFunc.msgbox_output(self, Constants.BCG_QUALITY_LABEL_VIEWING_THE_LAST_PART_UNLABELED,
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("发射信号不存在")
|
|
|
|
|
|
|
|
|
|
# 更新备注内容
|
|
|
|
|
if not (str(self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK]) ==
|
|
|
|
|
Constants.STRING_IS_NAN):
|
|
|
|
|
self.ui.lineEdit_remark.setText(
|
|
|
|
|
str(self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK]))
|
|
|
|
|
else:
|
|
|
|
|
self.ui.lineEdit_remark.setText(Constants.STRING_IS_EMPTY)
|
|
|
|
|
|
|
|
|
|
# 更新按钮颜色
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
|
|
|
|
|
if (self.data.df_label[
|
|
|
|
|
Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] != Constants.BCG_QUALITY_LABEL_TOBELABELED).all():
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_LABELED_FINISHED,
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
self.update_status()
|
|
|
|
|
self.update_tableWidget()
|
|
|
|
|
self.__plot__()
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_VIEWING_PART + str(Config["CurrentPartNum"]),
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
|
|
|
|
|
def __slot_tablewidget_on_cell_double_clicked__(self, row, column):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
length = Config["InputConfig"]["UseFreq"] * 30
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
length = Config["InputConfig"]["UseFreq"] * 10
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
|
|
|
|
|
if sender == self.ui.tableWidget_a1:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_a1.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
elif sender == self.ui.tableWidget_a2:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_a2.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
elif sender == self.ui.tableWidget_b1:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_b1.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
elif sender == self.ui.tableWidget_b2:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_b2.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
elif sender == self.ui.tableWidget_c:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_c.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
elif sender == self.ui.tableWidget_f:
|
|
|
|
|
Config["CurrentPartNum"] = int(self.ui.tableWidget_f.item(row, column).text())
|
|
|
|
|
Config["CurrentDataIdx"] = (Config["CurrentPartNum"] - 1) * length
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("发射信号不存在")
|
|
|
|
|
|
|
|
|
|
# 更新备注内容
|
|
|
|
|
if not (str(self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK]) ==
|
|
|
|
|
Constants.STRING_IS_NAN):
|
|
|
|
|
self.ui.lineEdit_remark.setText(str(self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK]))
|
|
|
|
|
else:
|
|
|
|
|
self.ui.lineEdit_remark.setText(Constants.STRING_IS_EMPTY)
|
|
|
|
|
|
|
|
|
|
# 更新按钮颜色
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
|
|
|
|
|
self.update_status()
|
|
|
|
|
self.__plot__()
|
|
|
|
|
PublicFunc.text_output(self.ui, Constants.BCG_QUALITY_LABEL_JUMP_PART + str(Config["CurrentPartNum"]),
|
|
|
|
|
Constants.MSGBOX_TYPE_INFO)
|
|
|
|
|
|
|
|
|
|
def __slot_btn_label__(self):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
|
|
|
|
|
if sender == self.ui.pushButton_a1:
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_30S_A1
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_10S_A
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
elif sender == self.ui.pushButton_a2:
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_30S_A2
|
|
|
|
|
elif sender == self.ui.pushButton_b1:
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_30S_B1
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_10S_B
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
elif sender == self.ui.pushButton_b2:
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_30S_B2
|
|
|
|
|
elif sender == self.ui.pushButton_c:
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_30S_C
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_10S_C
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
elif sender == self.ui.pushButton_f:
|
|
|
|
|
label = Constants.BCG_QUALITY_LABEL_TOBELABELED
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("发射信号不存在")
|
|
|
|
|
|
|
|
|
|
self.data.label[Config["CurrentPartNum"] - 1] = label
|
|
|
|
|
self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] = self.data.label
|
|
|
|
|
self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK] = (
|
|
|
|
|
self.ui.lineEdit_remark.text())
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
self.update_tableWidget()
|
|
|
|
|
result = self.data.save(label)
|
|
|
|
|
if not result.status:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_ERROR)
|
|
|
|
|
PublicFunc.msgbox_output(self, result.info, Constants.MSGBOX_TYPE_ERROR)
|
|
|
|
|
PublicFunc.finish_operation(self, ButtonState)
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_INFO)
|
|
|
|
|
|
|
|
|
|
def __slot_btn_invalid_signal_label__(self):
|
|
|
|
|
reply = QMessageBox.question(self, Constants.QUESTION_TITLE,
|
|
|
|
|
Constants.BCG_QUALITY_LABEL_LABEL_ALL_TO_TYPE_C_QUESTION_CONTENT,
|
|
|
|
|
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
|
|
|
if reply == QMessageBox.Yes:
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
self.data.label = full(self.data.label.shape, Constants.BCG_QUALITY_LABEL_30S_C).astype(str)
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
self.data.label = full(self.data.label.shape, Constants.BCG_QUALITY_LABEL_10S_C).astype(str)
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] = self.data.label
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
self.update_tableWidget()
|
|
|
|
|
result = self.data.save("无效信号标注")
|
|
|
|
|
if not result.status:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_ERROR)
|
|
|
|
|
PublicFunc.msgbox_output(self, result.info, Constants.MSGBOX_TYPE_ERROR)
|
|
|
|
|
PublicFunc.finish_operation(self, ButtonState)
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_INFO)
|
|
|
|
|
|
|
|
|
|
def __slot_btn_Ctype_signal_label__(self):
|
|
|
|
|
reply = QMessageBox.question(self, Constants.QUESTION_TITLE,
|
|
|
|
|
Constants.BCG_QUALITY_LABEL_LABEL_ARTIFACT_TO_TYPE_C_QUESTION_CONTENT,
|
|
|
|
|
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
|
|
|
|
if reply == QMessageBox.Yes:
|
|
|
|
|
artifact_mask = self.data.artifact_mask[:Config["InputConfig"]["UseFreq"] * 10 *
|
|
|
|
|
int(len(self.data.BCG) // (Config["InputConfig"]["UseFreq"] * 10))]
|
|
|
|
|
sub_artifact_mask = split(artifact_mask, len(artifact_mask) // (Config["InputConfig"]["UseFreq"] * 10))
|
|
|
|
|
for index, array in enumerate(sub_artifact_mask):
|
|
|
|
|
if 1 in array or 2 in array or 3 in array or 4 in array or 5 in array:
|
|
|
|
|
self.data.label[index] = Constants.BCG_QUALITY_LABEL_10S_C
|
|
|
|
|
self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] = self.data.label
|
|
|
|
|
self.change_labelBtn_color()
|
|
|
|
|
self.update_tableWidget()
|
|
|
|
|
result = self.data.save("C类信号标注")
|
|
|
|
|
if not result.status:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_ERROR)
|
|
|
|
|
PublicFunc.msgbox_output(self, result.info, Constants.MSGBOX_TYPE_ERROR)
|
|
|
|
|
PublicFunc.finish_operation(self, ButtonState)
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
PublicFunc.text_output(self.ui, result.info, Constants.TIPS_TYPE_INFO)
|
|
|
|
|
|
|
|
|
|
def __slot_checkBox_highlight_longest_continuous__(self):
|
|
|
|
|
self.__plot__()
|
|
|
|
|
|
|
|
|
|
def __slot_checkBox_display_afterfilter__(self):
|
|
|
|
|
self.__plot__()
|
|
|
|
|
|
|
|
|
|
def __slot_checkBox__(self):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|
|
|
|
|
|
if sender == self.ui.checkBox_allin:
|
|
|
|
|
if self.ui.checkBox_allin.isChecked():
|
|
|
|
|
self.ui.checkBox_type1.setChecked(True)
|
|
|
|
|
self.ui.checkBox_type2.setChecked(True)
|
|
|
|
|
self.ui.checkBox_type3.setChecked(True)
|
|
|
|
|
self.ui.checkBox_type4.setChecked(True)
|
|
|
|
|
self.ui.checkBox_type5.setChecked(True)
|
|
|
|
|
else:
|
|
|
|
|
self.ui.checkBox_type1.setChecked(False)
|
|
|
|
|
self.ui.checkBox_type2.setChecked(False)
|
|
|
|
|
self.ui.checkBox_type3.setChecked(False)
|
|
|
|
|
self.ui.checkBox_type4.setChecked(False)
|
|
|
|
|
self.ui.checkBox_type5.setChecked(False)
|
|
|
|
|
elif (sender == self.ui.checkBox_type1 or
|
|
|
|
|
sender == self.ui.checkBox_type2 or
|
|
|
|
|
sender == self.ui.checkBox_type3 or
|
|
|
|
|
sender == self.ui.checkBox_type4 or
|
|
|
|
|
sender == self.ui.checkBox_type5):
|
|
|
|
|
if (self.ui.checkBox_type1.isChecked() and
|
|
|
|
|
self.ui.checkBox_type2.isChecked() and
|
|
|
|
|
self.ui.checkBox_type3.isChecked() and
|
|
|
|
|
self.ui.checkBox_type4.isChecked() and
|
|
|
|
|
self.ui.checkBox_type5.isChecked()):
|
|
|
|
|
self.ui.checkBox_allin.setChecked(True)
|
|
|
|
|
else:
|
|
|
|
|
self.ui.checkBox_allin.setChecked(False)
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("发射信号不存在")
|
|
|
|
|
|
|
|
|
|
self.__plot__()
|
|
|
|
|
|
|
|
|
|
def update_status(self):
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
hour = int(((Config["CurrentDataIdx"] + (Config["InputConfig"]["UseFreq"] * 30)) / int(Config["InputConfig"]["UseFreq"])) // 3600)
|
|
|
|
|
@ -479,9 +788,9 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
for row, value in enumerate(label):
|
|
|
|
|
item = QTableWidgetItem(str(value).strip())
|
|
|
|
|
tableWidget.setItem(row, 0, item)
|
|
|
|
|
if (self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][
|
|
|
|
|
value - 1] != Constants.STRING_IS_EMPTY and
|
|
|
|
|
self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][value - 1] is not nan):
|
|
|
|
|
if (str(self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][
|
|
|
|
|
value - 1]) != Constants.STRING_IS_EMPTY and
|
|
|
|
|
str(self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][value - 1]) != Constants.STRING_IS_NAN):
|
|
|
|
|
item = tableWidget.item(row, 0)
|
|
|
|
|
item.setBackground(QColor(255, 200, 200))
|
|
|
|
|
else:
|
|
|
|
|
@ -517,9 +826,9 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
for row, value in enumerate(label):
|
|
|
|
|
item = QTableWidgetItem(str(value).strip())
|
|
|
|
|
tableWidget.setItem(row, 0, item)
|
|
|
|
|
if (self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][
|
|
|
|
|
value - 1] != Constants.STRING_IS_EMPTY and
|
|
|
|
|
self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][value - 1] is not nan):
|
|
|
|
|
if (str(self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][
|
|
|
|
|
value - 1]) != Constants.STRING_IS_EMPTY and
|
|
|
|
|
str(self.data.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK][value - 1]) != Constants.STRING_IS_NAN):
|
|
|
|
|
item = tableWidget.item(row, 0)
|
|
|
|
|
item.setBackground(QColor(255, 200, 200))
|
|
|
|
|
else:
|
|
|
|
|
@ -588,12 +897,48 @@ class MainWindow_bcg_quality_label(QMainWindow):
|
|
|
|
|
self.ui.tableWidget_b2.setHorizontalHeaderLabels(['b2'])
|
|
|
|
|
self.ui.tableWidget_c.setHorizontalHeaderLabels(['c'])
|
|
|
|
|
self.ui.tableWidget_f.setHorizontalHeaderLabels(['None'])
|
|
|
|
|
elif Config["Mode"] == "Undefined":
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def change_labelBtn_color(self):
|
|
|
|
|
if self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "a1":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.BCG_QUALITY_LABEL_LABELBTN_STYLE)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
elif self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "a2":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.BCG_QUALITY_LABEL_LABELBTN_STYLE)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
elif self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "b1":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.BCG_QUALITY_LABEL_LABELBTN_STYLE)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
elif self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "b2":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.BCG_QUALITY_LABEL_LABELBTN_STYLE)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
elif self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "c1":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.BCG_QUALITY_LABEL_LABELBTN_STYLE)
|
|
|
|
|
elif self.data.df_label.at[Config["CurrentPartNum"] - 1, Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] == "f1":
|
|
|
|
|
self.ui.pushButton_a1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_a2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b1.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_b2.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
self.ui.pushButton_c.setStyleSheet(Constants.STRING_IS_EMPTY)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Data():
|
|
|
|
|
|
|
|
|
|
@ -635,8 +980,6 @@ class Data():
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
Config["Path"]["Save"] = str(
|
|
|
|
|
Path(Config["Path"]["Save"]) / Path(ConfigParams.SQ_LABEL_10S + ConfigParams.ENDSWITH_CSV))
|
|
|
|
|
elif Config["Mode"] == "Undefined":
|
|
|
|
|
return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON["Mode_Undefined"])
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
|
|
|
|
|
@ -696,7 +1039,7 @@ class Data():
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
|
|
|
|
|
if not Path(Config["Path"]["Save"]).exists():
|
|
|
|
|
self.label = full(Config["DataPartNum"], Constants.BCG_QUALITY_LABEL_TOBELABELED)
|
|
|
|
|
self.label = full(Config["DataPartNum"], Constants.BCG_QUALITY_LABEL_TOBELABELED).astype(str)
|
|
|
|
|
self.df_label = DataFrame(columns=[Constants.BCG_QUALITY_LABEL_COLUMN_LABEL, Constants.BCG_QUALITY_LABEL_COLUMN_REMARK])
|
|
|
|
|
self.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_LABEL] = self.label
|
|
|
|
|
self.df_label[Constants.BCG_QUALITY_LABEL_COLUMN_REMARK] = Constants.STRING_IS_EMPTY
|
|
|
|
|
@ -740,6 +1083,28 @@ class Data():
|
|
|
|
|
|
|
|
|
|
return Result().success(info=Constants.PREPROCESS_FINISHED)
|
|
|
|
|
|
|
|
|
|
def save(self, label):
|
|
|
|
|
if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()):
|
|
|
|
|
Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
if self.df_label is None:
|
|
|
|
|
return Result().failure(info=ConfigParams.RESP_QUALITY_LABEL + Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
|
|
|
|
|
|
|
|
|
|
if Config["Mode"] == "30s":
|
|
|
|
|
filename = ConfigParams.SQ_LABEL_30S
|
|
|
|
|
elif Config["Mode"] == "10s":
|
|
|
|
|
filename = ConfigParams.SQ_LABEL_10S
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError("模式不存在")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
self.df_label.to_csv(Config["Path"]["Save"], index=False, encoding=ConfigParams.GBK_ENCODING)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
return Result().failure(info=filename + Constants.SAVE_FAILURE +
|
|
|
|
|
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
|
|
|
|
|
|
|
|
|
return Result().success(info=filename + Constants.SAVE_FINISHED + "标签为:" + str(label))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def wipe_industrialFrequencyNoise(data, fs):
|
|
|
|
|
|