1、完善命名规范
2、完成<冗余数据切割和标签映射>的全部代码
This commit is contained in:
@ -49,7 +49,6 @@ ButtonState = {
|
||||
class SettingWindow(QMainWindow):
|
||||
|
||||
def __init__(self, mode, root_path, sampID):
|
||||
|
||||
super(SettingWindow, self).__init__()
|
||||
self.ui = Ui_MainWindow_label_check_input_setting()
|
||||
self.ui.setupUi(self)
|
||||
@ -70,7 +69,6 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.pushButton_cancel.clicked.connect(self.close)
|
||||
|
||||
def __read_config__(self):
|
||||
|
||||
if not Path(ConfigParams.LABEL_CHECK_CONFIG_FILE_PATH).exists():
|
||||
with open(ConfigParams.LABEL_CHECK_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(ConfigParams.LABEL_CHECK_CONFIG_NEW_CONTENT, f)
|
||||
@ -132,7 +130,6 @@ class SettingWindow(QMainWindow):
|
||||
raise ValueError("模式不存在")
|
||||
|
||||
def __write_config__(self):
|
||||
|
||||
# 从界面写入配置
|
||||
Config["InputConfig"]["Freq"] = self.ui.spinBox_input_freq_signal.value()
|
||||
Config["Path"]["Input_Signal"] = self.ui.plainTextEdit_file_path_input_signal.toPlainText()
|
||||
@ -158,11 +155,9 @@ class SettingWindow(QMainWindow):
|
||||
self.close()
|
||||
|
||||
def __rollback_config__(self):
|
||||
|
||||
self.__read_config__()
|
||||
|
||||
def __update_ui__(self):
|
||||
|
||||
if self.mode == "BCG":
|
||||
self.ui.plainTextEdit_file_path_input_signal.setPlainText(
|
||||
str((Path(self.root_path) /
|
||||
@ -186,7 +181,6 @@ class SettingWindow(QMainWindow):
|
||||
class MainWindow_label_check(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
super(MainWindow_label_check, self).__init__()
|
||||
self.ui = Ui_MainWindow_label_check()
|
||||
self.ui.setupUi(self)
|
||||
@ -236,7 +230,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def show(self, mode, root_path, sampID):
|
||||
|
||||
super().show()
|
||||
self.mode = mode
|
||||
self.root_path = root_path
|
||||
@ -307,7 +300,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def closeEvent(self, event):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
PublicFunc.statusbar_show_msg(self, PublicFunc.format_status_msg(Constants.SHUTTING_DOWN))
|
||||
@ -331,11 +323,9 @@ class MainWindow_label_check(QMainWindow):
|
||||
|
||||
@staticmethod
|
||||
def __reset__():
|
||||
|
||||
ButtonState["Current"].update(ButtonState["Default"].copy())
|
||||
|
||||
def __plot__(self):
|
||||
|
||||
# 清空画框
|
||||
if self.point_peak_original is not None:
|
||||
self.point_peak_original.remove()
|
||||
@ -373,7 +363,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
return status, info
|
||||
|
||||
def __plot_peaks__(self):
|
||||
|
||||
try:
|
||||
self.point_peak_original, = self.ax0.plot(self.data.original_peak, self.data.original_peak_y, 'ro',
|
||||
label=Constants.LABEL_CHECK_PLOT_LABEL_PEAK_ORIGINAL)
|
||||
@ -389,14 +378,12 @@ class MainWindow_label_check(QMainWindow):
|
||||
return True, Constants.DRAWING_FINISHED
|
||||
|
||||
def __redraw_peaks__(self):
|
||||
|
||||
self.point_peak_corrected.remove()
|
||||
self.point_peak_corrected, = self.ax1.plot(self.data.corrected_peak, self.data.corrected_peak_y, 'ro',
|
||||
label=Constants.LABEL_CHECK_PLOT_LABEL_PEAK_CORRECTED)
|
||||
self.canvas.draw()
|
||||
|
||||
def __update_tableWidget_and_info__(self):
|
||||
|
||||
if self.data.original_peak is None or self.data.corrected_peak is None:
|
||||
return False, Constants.LABEL_CHECK_FAILURE_REASON["Peak_Not_Exist"]
|
||||
|
||||
@ -419,7 +406,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
return status, info
|
||||
|
||||
def __update_config__(self):
|
||||
|
||||
Config["FindPeaks"]["MinInterval"] = self.ui.doubleSpinBox_findpeaks_min_interval.value()
|
||||
Config["FindPeaks"]["MinHeight"] = self.ui.doubleSpinBox_findpeaks_min_height.value()
|
||||
Config["CustomAutoplayArgs"]["MoveLength"] = self.ui.spinBox_moveLength.value()
|
||||
@ -427,7 +413,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
Config["CustomAutoplayArgs"]["MoveSpeed"] = self.ui.spinBox_moveSpeed.value()
|
||||
|
||||
def __slot_btn_input__(self):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 清空画框
|
||||
@ -526,7 +511,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_save__(self):
|
||||
|
||||
reply = QMessageBox.question(self, Constants.QUESTION_TITLE,
|
||||
Constants.QUESTION_CONTENT + Config["Path"]["Save"],
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
@ -560,7 +544,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_move__(self):
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
@ -594,7 +577,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
PublicFunc.text_output(self.ui, Constants.LABEL_CHECK_PAUSE, Constants.TIPS_TYPE_INFO)
|
||||
|
||||
def __change_autoplay_args__(self):
|
||||
|
||||
sender = self.sender()
|
||||
|
||||
if sender == self.ui.radioButton_move_preset_1 and self.ui.radioButton_move_preset_1.isChecked():
|
||||
@ -637,7 +619,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.timer_autoplay.stop()
|
||||
|
||||
def __slot_tableWidget_on_cell_double_clicked__(self, row, col):
|
||||
|
||||
if Config["AutoplayArgs"]["AutoplayMode"] != "pause":
|
||||
self.ui.pushButton_pause.click()
|
||||
|
||||
@ -657,7 +638,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
PublicFunc.text_output(self.ui, f"{Constants.LABEL_CHECK_JUMP_X_INDEX}{str(int(x))}", Constants.TIPS_TYPE_INFO)
|
||||
|
||||
def reset_axes(self):
|
||||
|
||||
self.ax0.clear()
|
||||
self.ax1.clear()
|
||||
self.ax0.grid(True)
|
||||
@ -667,7 +647,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.ax1.xaxis.set_major_formatter(ConfigParams.FORMATTER)
|
||||
|
||||
def on_xlim_change(self, event_ax):
|
||||
|
||||
try:
|
||||
if self.annotation_tableWidget is not None:
|
||||
self.annotation_tableWidget.remove()
|
||||
@ -676,7 +655,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
pass
|
||||
|
||||
def autoplay_move_xlim(self):
|
||||
|
||||
if Config["AutoplayArgs"]["AutoplayMode"] == "prev" and self.autoplay_xlim_start < 0:
|
||||
Config["AutoplayArgs"]["AutoplayMode"] = "pause"
|
||||
self.timer_autoplay.stop()
|
||||
@ -694,7 +672,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.canvas.draw()
|
||||
|
||||
def on_motion(self, event):
|
||||
|
||||
if event.inaxes and self.ui.checkBox_show_reference_line.isChecked():
|
||||
# Clear previous reference lines and temporary points
|
||||
for line in self.ax0.lines[1:]:
|
||||
@ -715,7 +692,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.canvas.draw()
|
||||
|
||||
def toggle_home(self):
|
||||
|
||||
if Config["AutoplayArgs"]["AutoplayMode"] != "pause":
|
||||
self.ui.pushButton_pause.click()
|
||||
self.ax0.autoscale(True)
|
||||
@ -728,7 +704,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
PublicFunc.text_output(self.ui, Constants.LABEL_CHECK_RECOVER_SCALE, Constants.TIPS_TYPE_INFO)
|
||||
|
||||
def toggle_changeLabel(self, state):
|
||||
|
||||
if state:
|
||||
self.deactivate_figToolbar_buttons()
|
||||
self.figToolbar.action_Label_Multiple.setChecked(True)
|
||||
@ -750,7 +725,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.figToolbar.cid_mouse_hold = None
|
||||
|
||||
def deactivate_figToolbar_buttons(self):
|
||||
|
||||
for action in self.figToolbar._actions.values():
|
||||
if action.isChecked() == True:
|
||||
if action == self.figToolbar._actions['pan']:
|
||||
@ -759,7 +733,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.figToolbar.zoom()
|
||||
|
||||
def on_click(self, event):
|
||||
|
||||
if self.figToolbar.action_Label_Multiple.isChecked():
|
||||
if event.button == 1 or event.button == 3: # 左键或右键
|
||||
if event.button == 1:
|
||||
@ -776,7 +749,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.canvas.draw()
|
||||
|
||||
def on_release(self, event):
|
||||
|
||||
if self.figToolbar.action_Label_Multiple.isChecked():
|
||||
if self.figToolbar.rect_start_x is not None:
|
||||
self.figToolbar.rect_end_x = event.xdata
|
||||
@ -839,8 +811,7 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.data.corrected_peak.sort()
|
||||
self.data.corrected_peak_y = [self.data.processed_data[x] for x in self.data.corrected_peak]
|
||||
self.__update_tableWidget_and_info__()
|
||||
DataFrame(self.data.corrected_peak).to_csv(self.data.file_path_save,
|
||||
index=False, header=False)
|
||||
DataFrame(self.data.corrected_peak).to_csv(Config["Path"]["Save"], index=False, header=False)
|
||||
# 移除矩形patch
|
||||
if self.figToolbar.rect_patch_ax0 is not None and self.figToolbar.rect_patch_ax1 is not None:
|
||||
self.figToolbar.rect_patch_ax0.remove()
|
||||
@ -850,7 +821,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.canvas.draw()
|
||||
|
||||
def on_hold(self, event):
|
||||
|
||||
if self.figToolbar.rect_start_x is not None and event.xdata is not None:
|
||||
self.figToolbar.rect_end_x = event.xdata
|
||||
|
||||
@ -896,10 +866,6 @@ class MainWindow_label_check(QMainWindow):
|
||||
class Data:
|
||||
|
||||
def __init__(self):
|
||||
self.file_path_input_signal = Config["Path"]["Input_Signal"]
|
||||
self.file_path_input_peak = Config["Path"]["Input_Peak"]
|
||||
self.file_path_save = Config["Path"]["Save"]
|
||||
|
||||
self.raw_data = None
|
||||
self.processed_data = None
|
||||
self.original_peak = None
|
||||
@ -908,15 +874,14 @@ class Data:
|
||||
self.corrected_peak_y = None
|
||||
|
||||
def open_file(self):
|
||||
|
||||
if (not Path(Config["Path"]["Input_Signal"]).exists()) or (not Path(Config["Path"]["Input_Peak"]).exists()):
|
||||
return False, Constants.INPUT_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Data_Path_Not_Exist"]
|
||||
|
||||
try:
|
||||
self.raw_data = read_csv(self.file_path_input_signal,
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.original_peak = read_csv(self.file_path_input_peak,
|
||||
self.raw_data = read_csv(Config["Path"]["Input_Signal"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.original_peak = read_csv(Config["Path"]["Input_Peak"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
@ -925,18 +890,16 @@ class Data:
|
||||
return True, Constants.INPUT_FINISHED
|
||||
|
||||
def get_archive(self):
|
||||
|
||||
if not Path(Config["Path"]["Save"]).exists():
|
||||
self.corrected_peak = self.original_peak
|
||||
return True, Constants.LABEL_CHECK_ARCHIVE_NOT_EXIST
|
||||
else:
|
||||
self.corrected_peak = read_csv(self.file_path_save,
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.corrected_peak = read_csv(Config["Path"]["Save"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
return True, Constants.LABEL_CHECK_ARCHIVE_EXIST
|
||||
|
||||
def preprocess(self):
|
||||
|
||||
if self.raw_data is None:
|
||||
return False, Constants.LABEL_CHECK_PROCESS_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Raw_Data_Not_Exist"]
|
||||
|
||||
@ -963,12 +926,11 @@ class Data:
|
||||
return True, Constants.LABEL_CHECK_PROCESS_FINISHED
|
||||
|
||||
def save(self, chunk):
|
||||
|
||||
if self.corrected_peak is None:
|
||||
return False, Constants.SAVING_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Peak_Not_Exist"]
|
||||
|
||||
try:
|
||||
chunk.to_csv(self.file_path_save, mode='a', index=False, header=False)
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return False, Constants.SAVING_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Save_Exception"]
|
||||
|
||||
@ -1007,21 +969,17 @@ class CustomNavigationToolbar(NavigationToolbar2QT):
|
||||
self.rect_patch_ax1 = None # 用于绘制矩形的patch
|
||||
|
||||
def home(self, *args):
|
||||
|
||||
pass
|
||||
|
||||
def zoom(self, *args):
|
||||
|
||||
super().zoom(*args)
|
||||
self.deactivate_figToorbar_changeLabel_mode()
|
||||
|
||||
def pan(self, *args):
|
||||
|
||||
super().pan(*args)
|
||||
self.deactivate_figToorbar_changeLabel_mode()
|
||||
|
||||
def deactivate_figToorbar_changeLabel_mode(self):
|
||||
|
||||
if self.action_Label_Multiple.isChecked():
|
||||
self.action_Label_Multiple.setChecked(False)
|
||||
if self.cid_mouse_press is not None:
|
||||
|
||||
Reference in New Issue
Block a user