diff --git a/func/Module_SA_label.py b/func/Module_SA_label.py
index 0668599..4440646 100644
--- a/func/Module_SA_label.py
+++ b/func/Module_SA_label.py
@@ -3,15 +3,16 @@ from pathlib import Path
from traceback import format_exc
import matplotlib.pyplot as plt
+from PySide6.QtCore import QCoreApplication
from PySide6.QtGui import QAction, QFont, QColor
-from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication, QButtonGroup, QTableWidget, QTableWidgetItem
+from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication, QButtonGroup, QTableWidget, QTableWidgetItem, \
+ QHeaderView
from matplotlib import gridspec
from matplotlib.backends.backend_qt import NavigationToolbar2QT
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg
from numpy import array, zeros, append, linspace, place, nan
from overrides import overrides
-from pandas import read_csv, DataFrame
-from scipy.signal import resample
+from pandas import read_csv, DataFrame, Series, concat
from yaml import dump, load, FullLoader
from func.Filters.Preprocessing import Butterworth_for_ECG_PreProcess
@@ -109,41 +110,25 @@ class SettingWindow(QMainWindow):
Config.update({
"Path": {
"Input_OrgBCG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_ORGBCG_FILENAME +
- str(Config["InputConfig"]["OrgBCGFreq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_Tho": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_THO_FILENAME +
- str(Config["InputConfig"]["ThoFreq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_Abd": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_ABD_FILENAME +
- str(Config["InputConfig"]["AbdFreq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_FlowT": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_FLOWT_FILENAME +
- str(Config["InputConfig"]["FlowTFreq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_FlowP": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_FLOWP_FILENAME +
- str(Config["InputConfig"]["FlowPFreq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_SpO2": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_SPO2_FILENAME +
- str(Config["InputConfig"]["SpO2Freq"]) +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_Artifact": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_ARTIFACT_FILENAME +
- ConfigParams.ENDSWITH_TXT))),
+ Path(str(self.sampID)))),
"Input_Label": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_INPUT_LABEL_FILENAME +
- ConfigParams.ENDSWITH_CSV))),
+ Path(str(self.sampID)))),
"Save": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_SAVE_FILENAME +
- ConfigParams.ENDSWITH_CSV))),
+ Path(str(self.sampID)))),
"Save_2": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL /
- Path(str(self.sampID)) / Path(ConfigParams.SA_LABEL_SAVE2_FILENAME +
- ConfigParams.ENDSWITH_CSV)))
+ Path(str(self.sampID))))
},
"PlotEventIndex": 0,
"TimeMoveCount": 0,
@@ -210,42 +195,42 @@ class SettingWindow(QMainWindow):
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_ORGBCG_FILENAME +
+ Path(ConfigParams.ORGBCG_SYNC +
str(self.ui.spinBox_input_freq_signal_OrgBCG.value()) +
ConfigParams.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_input_signal_Tho.setPlainText(
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_THO_FILENAME +
+ Path(ConfigParams.THO_SYNC +
str(self.ui.spinBox_input_freq_signal_Tho.value()) +
ConfigParams.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_input_signal_Abd.setPlainText(
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_ABD_FILENAME +
+ Path(ConfigParams.ABD_SYNC +
str(self.ui.spinBox_input_freq_signal_Abd.value()) +
ConfigParams.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_input_signal_FlowT.setPlainText(
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_FLOWT_FILENAME +
+ Path(ConfigParams.FLOWT_SYNC +
str(self.ui.spinBox_input_freq_signal_FlowT.value()) +
ConfigParams.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_input_signal_FlowP.setPlainText(
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_FLOWP_FILENAME +
+ Path(ConfigParams.FLOWP_SYNC +
str(self.ui.spinBox_input_freq_signal_FlowP.value()) +
ConfigParams.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_input_signal_SpO2.setPlainText(
str((Path(self.root_path) /
ConfigParams.PUBLIC_PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
- Path(ConfigParams.SA_LABEL_INPUT_SPO2_FILENAME +
+ Path(ConfigParams.SPO2_SYNC +
str(self.ui.spinBox_input_freq_signal_SpO2.value()) +
ConfigParams.ENDSWITH_TXT))))
@@ -317,7 +302,7 @@ class MainWindow_SA_label(QMainWindow):
self.ui.verticalLayout_canvas.addWidget(self.canvas)
self.ui.verticalLayout_canvas.addWidget(self.figToolbar)
self.gs = gridspec.GridSpec(7, 1, height_ratios=[1, 1, 1, 1, 1, 3, 2])
- self.fig.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
+ self.fig.subplots_adjust(top=0.98, bottom=0.05, right=0.98, left=0.1, hspace=0, wspace=0)
self.ax0 = self.fig.add_subplot(self.gs[0])
self.ax0.grid(True)
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
@@ -345,7 +330,6 @@ class MainWindow_SA_label(QMainWindow):
self.ax6 = self.fig.add_subplot(self.gs[6], sharex=self.ax0)
self.ax6.grid(True)
self.ax6.xaxis.set_major_formatter(ConfigParams.FORMATTER)
- self.ax6.tick_params(axis='x', colors=Constants.PLOT_COLOR_WHITE)
PublicFunc.__resetAllButton__(self, ButtonState)
@@ -353,8 +337,8 @@ class MainWindow_SA_label(QMainWindow):
self.ui.tableWidget_label_add.setHorizontalHeaderLabels(['事件类型', '标签类型', '起始时间(s)', '终止时间(s)'])
self.ui.tableWidget_label.setEditTriggers(QTableWidget.NoEditTriggers)
self.ui.tableWidget_label_add.setEditTriggers(QTableWidget.NoEditTriggers)
- self.ui.tableWidget_label.horizontalHeader().setStretchLastSection(True)
- self.ui.tableWidget_label_add.horizontalHeader().setStretchLastSection(True)
+ self.ui.tableWidget_label.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
+ self.ui.tableWidget_label_add.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.buttonGroup_event = QButtonGroup(self)
self.buttonGroup_class = QButtonGroup(self)
@@ -371,10 +355,40 @@ class MainWindow_SA_label(QMainWindow):
self.ui.pushButton_input.clicked.connect(self.__slot_btn_input__)
self.ui.pushButton_input_setting.clicked.connect(self.setting.show)
- self.ui.tableWidget_label.cellDoubleClicked.connect(self.slot_tableWidget_label_on_cell_double_clicked)
- self.ui.lineEdit_filter_label.textChanged.connect(self.slot_lineEdit_filter_label)
- self.ui.lineEdit_filter_label_add.textChanged.connect(self.slot_lineEdit_filter_label)
+ self.ui.tableWidget_label.cellDoubleClicked.connect(self.__slot_tableWidget_label_on_cell_double_clicked__)
+ self.ui.lineEdit_filter_label.textChanged.connect(self.__slot_lineEdit_filter_label__)
+ self.ui.lineEdit_filter_label_add.textChanged.connect(self.__slot_lineEdit_filter_label__)
+ self.ui.pushButton_prev.clicked.connect(self.__slot_btn_move__)
+ self.ui.pushButton_next.clicked.connect(self.__slot_btn_move__)
+ self.ui.pushButton_confirmLabel.clicked.connect(self.__slot_btn_confirmLabel__)
+ self.ui.pushButton_quick_remark_input_waitingForTalk.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_maybeDesaturation.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_maybeWrongLabeled.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_durationNoEnough.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_littleChange.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_noNormalRespBetweenArtifact.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_lowSignalNoiseRatio.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_quick_remark_input_changeOnMiddle.clicked.connect(self.__slot_btn_quick_remark__)
+ self.ui.pushButton_previous10s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.pushButton_previous30s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.pushButton_previous60s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.pushButton_next10s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.pushButton_next30s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.pushButton_next60s.clicked.connect(self.__slot_btn_moveBySecond__)
+ self.ui.checkBox_examineBySecond.clicked.connect(self.__slot_checkBox_examineBySecond__)
+ self.ui.checkBox_examineLabeled.clicked.connect(self.__slot_checkBox_examineLabeled__)
+ self.ui.pushButton_prev.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_BTN_PREV_SHORTCUT_KEY))
+ self.ui.pushButton_confirmLabel.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_BTN_CONFIRMLABEL_SHORTCUT_KEY))
+ self.ui.pushButton_next.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_BTN_NEXT_SHORTCUT_KEY))
+ self.ui.radioButton_OSA.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_OSA_SHORTCUT_KEY))
+ self.ui.radioButton_CSA.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_CSA_SHORTCUT_KEY))
+ self.ui.radioButton_MSA.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_MSA_SHORTCUT_KEY))
+ self.ui.radioButton_HPY.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_HPY_SHORTCUT_KEY))
+ self.ui.radioButton_1_class.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_1_CLASS_SHORTCUT_KEY))
+ self.ui.radioButton_2_class.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_2_CLASS_SHORTCUT_KEY))
+ self.ui.radioButton_3_class.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_RADIOBUTTON_3_CLASS_SHORTCUT_KEY))
+ self.ui.pushButton_quick_remark_input_waitingForTalk.setShortcut(QCoreApplication.translate("MainWindow", ConfigParams.SA_LABEL_BTN_QUICK_REMARK_WAITINGFORTALK_SHORTCUT_KEY))
@overrides
def closeEvent(self, event):
@@ -415,7 +429,7 @@ class MainWindow_SA_label(QMainWindow):
def __reset__(self):
ButtonState["Current"].update(ButtonState["Default"].copy())
- def __plot__(self):
+ def __plot__(self, *args, **kwargs):
# 清空画框
self.reset_axes()
@@ -426,8 +440,31 @@ class MainWindow_SA_label(QMainWindow):
self.draw_one_event()
self.canvas.draw()
except Exception as e:
- return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
- return Result().success(info=Constants.DRAWING_FINISHED)
+ return Result().failure(info=Constants.DRAW_FAILURE + "\n" + format_exc())
+ elif sender == self.ui.tableWidget_label or sender == self.ui.tableWidget_label_add:
+ try:
+ self.draw_one_event()
+ self.canvas.draw()
+ except Exception as e:
+ return Result().failure(info=Constants.DRAW_FAILURE + "\n" + format_exc())
+ elif sender == self.ui.pushButton_prev or sender == self.ui.pushButton_next:
+ try:
+ self.draw_one_event()
+ self.canvas.draw()
+ except Exception as e:
+ return Result().failure(info=Constants.DRAW_FAILURE + "\n" + format_exc())
+ elif (sender == self.ui.pushButton_previous10s or
+ sender == self.ui.pushButton_previous30s or
+ sender == self.ui.pushButton_previous60s or
+ sender == self.ui.pushButton_next10s or
+ sender == self.ui.pushButton_next30s or
+ sender == self.ui.pushButton_next60s):
+ try:
+ self.draw_new_event(*args, **kwargs)
+ self.canvas.draw()
+ except Exception as e:
+ return Result().failure(info=Constants.DRAW_FAILURE + "\n" + format_exc())
+ return Result().success(info=Constants.DRAW_FINISHED)
@@ -468,9 +505,10 @@ class MainWindow_SA_label(QMainWindow):
else:
self.ui.radioButton_2_class.setChecked(True)
except Exception as e:
- return Result().failure(info=Constants.SA_LABEL_UPDATE_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Update_Info_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.UPDATE_FAILURE +
+ Constants.FAILURE_REASON["Update_Info_Exception"] + "\n" + format_exc())
- return Result().success(info=Constants.SA_LABEL_UPDATE_FINISHED)
+ return Result().success(info=Constants.UPDATE_FINISHED)
def update_tableWidget(self):
try:
@@ -580,9 +618,10 @@ class MainWindow_SA_label(QMainWindow):
item = self.ui.tableWidget_label_add.item(index, col)
item.setBackground(QColor(255, 255, 255))
except Exception as e:
- return Result().failure(info=Constants.SA_LABEL_UPDATE_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Update_tableWidget_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.UPDATE_FAILURE +
+ Constants.FAILURE_REASON["Update_tableWidget_Exception"] + "\n" + format_exc())
- return Result().success(info=Constants.SA_LABEL_UPDATE_FINISHED)
+ return Result().success(info=Constants.UPDATE_FINISHED)
def __slot_btn_input__(self):
PublicFunc.__disableAllButton__(self, ButtonState)
@@ -604,7 +643,7 @@ class MainWindow_SA_label(QMainWindow):
PublicFunc.text_output(self.ui, "(1/7)" + result.info, Constants.TIPS_TYPE_INFO)
# 获取存档
- PublicFunc.progressbar_update(self, 2, 7, Constants.SA_LABEL_LOADING_ARCHIVE, 20)
+ PublicFunc.progressbar_update(self, 2, 7, Constants.LOADING_ARCHIVE, 20)
result = self.data.get_archive()
if not result.status:
PublicFunc.text_output(self.ui, "(2/7)" + result.info, Constants.TIPS_TYPE_ERROR)
@@ -615,7 +654,7 @@ class MainWindow_SA_label(QMainWindow):
PublicFunc.text_output(self.ui, "(2/7)" + result.info, Constants.TIPS_TYPE_INFO)
# 数据预处理
- PublicFunc.progressbar_update(self, 3, 7, Constants.SA_LABEL_PROCESSING_DATA, 30)
+ PublicFunc.progressbar_update(self, 3, 7, Constants.PREPROCESSING_DATA, 30)
result = self.data.preprocess()
if not result.status:
PublicFunc.text_output(self.ui, "(3/7)" + result.info, Constants.TIPS_TYPE_ERROR)
@@ -628,6 +667,8 @@ class MainWindow_SA_label(QMainWindow):
# 重采样
PublicFunc.progressbar_update(self, 4, 7, Constants.RESAMPLING_DATA, 50)
result = self.data.resample()
+ for key, value in self.data.channel.items():
+ PublicFunc.text_output(self.ui, key + "重采样后的长度:" + str(len(value)), Constants.TIPS_TYPE_INFO)
if not result.status:
PublicFunc.text_output(self.ui, "(4/7)" + result.info, Constants.TIPS_TYPE_ERROR)
PublicFunc.msgbox_output(self, result.info, Constants.MSGBOX_TYPE_ERROR)
@@ -648,7 +689,7 @@ class MainWindow_SA_label(QMainWindow):
PublicFunc.text_output(self.ui, "(5/7)" + result.info, Constants.TIPS_TYPE_INFO)
# 更新表格
- PublicFunc.progressbar_update(self, 6, 7, Constants.SA_LABEL_UPDATING_TABLE, 90)
+ PublicFunc.progressbar_update(self, 6, 7, Constants.UPDATING_TABLEWIDGET, 90)
result = self.update_tableWidget()
if not result.status:
PublicFunc.text_output(self.ui, "(6/7)" + result.info, Constants.TIPS_TYPE_ERROR)
@@ -659,7 +700,7 @@ class MainWindow_SA_label(QMainWindow):
PublicFunc.text_output(self.ui, "(6/7)" + result.info, Constants.TIPS_TYPE_INFO)
# 更新信息
- PublicFunc.progressbar_update(self, 7, 7, Constants.SA_LABEL_UPDATING_INFO, 95)
+ PublicFunc.progressbar_update(self, 7, 7, Constants.UPDATING_INFO, 95)
result = self.update_UI_Args()
if not result.status:
PublicFunc.text_output(self.ui, "(7/7)" + result.info, Constants.TIPS_TYPE_ERROR)
@@ -669,6 +710,10 @@ class MainWindow_SA_label(QMainWindow):
else:
PublicFunc.text_output(self.ui, "(7/7)" + result.info, Constants.TIPS_TYPE_INFO)
+ if (self.data.df_corrected["isLabeled"] == 1).all():
+ self.ui.checkBox_examineLabeled.setChecked(False)
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_ALL_LABELED, Constants.MSGBOX_TYPE_INFO)
+
self.__reset__()
self.figToolbar.action_Reset_Signal_and_Time.setEnabled(True)
for action in self.figToolbar._actions.values():
@@ -686,23 +731,212 @@ class MainWindow_SA_label(QMainWindow):
ButtonState["Current"]["pushButton_prev"] = True
ButtonState["Current"]["pushButton_next"] = True
ButtonState["Current"]["pushButton_confirmLabel"] = True
- ButtonState["Current"]["pushButton_previous10s"] = True
- ButtonState["Current"]["pushButton_previous30s"] = True
- ButtonState["Current"]["pushButton_previous60s"] = True
- ButtonState["Current"]["pushButton_next10s"] = True
- ButtonState["Current"]["pushButton_next30s"] = True
- ButtonState["Current"]["pushButton_next60s"] = True
+ ButtonState["Current"]["pushButton_previous10s"] = False
+ ButtonState["Current"]["pushButton_previous30s"] = False
+ ButtonState["Current"]["pushButton_previous60s"] = False
+ ButtonState["Current"]["pushButton_next10s"] = False
+ ButtonState["Current"]["pushButton_next30s"] = False
+ ButtonState["Current"]["pushButton_next60s"] = False
PublicFunc.finish_operation(self, ButtonState)
- def slot_tableWidget_label_on_cell_double_clicked(self, row, column):
- self.reset_axes()
+ def __slot_btn_confirmLabel__(self):
+ try:
+ if (int(self.ui.spinBox_correctStart.value()) * Config["InputConfig"]["PlotFreq"] > len(self.data.channel['orgdata']) or
+ int(self.ui.spinBox_correctStart.value()) < 0 or
+ int(self.ui.spinBox_correctEnd.value()) < 0 or
+ int(self.ui.spinBox_correctStart.value()) * Config["InputConfig"]["PlotFreq"] > len(self.data.channel['orgdata'])):
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_LENGTH_TOO_LONG, Constants.MSGBOX_TYPE_ERROR)
+ return
+ if int(self.ui.spinBox_correctEnd.value()) - int(self.ui.spinBox_correctStart.value()) < 10:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_LENGTH_LESS_THEN_10S, Constants.MSGBOX_TYPE_WARNING)
+
+ if self.ui.checkBox_examineBySecond.isChecked():
+ if int(self.ui.spinBox_correctStart.value()) < int(self.ui.spinBox_correctEnd.value()):
+ if self.ui.radioButton_1_class.isChecked():
+ score = int(1)
+ elif self.ui.radioButton_2_class.isChecked():
+ score = int(2)
+ elif self.ui.radioButton_3_class.isChecked():
+ score = int(3)
+ else:
+ raise ValueError("score值不存在")
+ remark = self.ui.lineEdit_remark.text()
+ correct_Start = int(self.ui.spinBox_correctStart.value())
+ correct_End = int(self.ui.spinBox_correctEnd.value())
+ if self.ui.radioButton_OSA.isChecked():
+ correct_EventsType = "Obstructive apnea"
+ elif self.ui.radioButton_CSA.isChecked():
+ correct_EventsType = "Central apnea"
+ elif self.ui.radioButton_MSA.isChecked():
+ correct_EventsType = "Mixed apnea"
+ elif self.ui.radioButton_HPY.isChecked():
+ correct_EventsType = "Hypopnea"
+ else:
+ raise ValueError("correct_EventsType值不存在")
+ isLabeled = int(1)
+ self.data.df_addNew = self.pd_add_new_row(self.data.df_addNew, score, remark, correct_Start,
+ correct_End, correct_EventsType, isLabeled)
+ result = self.data.save_2()
+ info = f"保存新事件打标结果到csv。score:{str(score)},correct_Start:{str(correct_Start)},correct_End:{str(correct_End)},correct_EventsType:{str(correct_EventsType)}"
+ PublicFunc.text_output(self.ui, info, Constants.MSGBOX_TYPE_INFO)
+ else:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_WRONG_ARGS, Constants.MSGBOX_TYPE_ERROR)
+ else:
+ if int(self.ui.spinBox_correctStart.value()) < int(self.ui.spinBox_correctEnd.value()):
+ if self.ui.radioButton_1_class.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "score"] = int(1)
+ elif self.ui.radioButton_2_class.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "score"] = int(2)
+ elif self.ui.radioButton_3_class.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "score"] = int(3)
+ self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "remark"] = self.ui.lineEdit_remark.text()
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"] = int(
+ self.ui.spinBox_correctStart.value())
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"] = int(
+ self.ui.spinBox_correctEnd.value())
+ if self.ui.radioButton_OSA.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "correct_EventsType"] = "Obstructive apnea"
+ elif self.ui.radioButton_CSA.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "correct_EventsType"] = "Central apnea"
+ elif self.ui.radioButton_MSA.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "correct_EventsType"] = "Mixed apnea"
+ elif self.ui.radioButton_HPY.isChecked():
+ self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "correct_EventsType"] = "Hypopnea"
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "isLabeled"] = int(1)
+ # self.data.df_corrected.to_csv(
+ # self.BCG_Label_Path / f"export{self.mainWindow.ui_SA_label_left.comboBox_sampID.currentText()}_all.csv",
+ # mode='w', index=None, encoding="gbk")
+ result = self.data.save()
+ index = str(Config["PlotEventIndex"] + 1)
+ score = str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "score"])
+ correct_Start = str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"])
+ correct_End = str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"])
+ correct_EventsType = str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_EventsType"])
+ info = f"保存index{index}标注结果到csv。score:{score},correct_Start:{correct_Start},correct_End:{correct_End},correct_EventsType:{correct_EventsType}"
+ PublicFunc.text_output(self.ui, info, Constants.MSGBOX_TYPE_INFO)
+ if (self.data.df_corrected.loc[Config["EventLabelIndexList"]]["isLabeled"] == 1).all():
+ self.ui.checkBox_examineLabeled.setChecked(False)
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_ALL_LABELED, Constants.TIPS_TYPE_INFO)
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_ALL_LABELED, Constants.MSGBOX_TYPE_INFO)
+ else:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_WRONG_ARGS, Constants.MSGBOX_TYPE_ERROR)
+ self.update_tableWidget()
+ except ValueError as e:
+ info = Constants.SAVE_FAILURE + "\n" + format_exc()
+ PublicFunc.msgbox_output(self, info, Constants.MSGBOX_TYPE_ERROR)
+
+ def __slot_btn_move__(self):
+ if self.data is None:
+ return
+
+ sender = self.sender()
+
+ if sender == self.ui.pushButton_prev:
+ if Config["PlotEventIndex"] == 0:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_VIEWING_FIRST, Constants.MSGBOX_TYPE_INFO)
+ return
+ else:
+ Config["PlotEventIndex"] = Config["PlotEventIndex"] - 1
+ if self.ui.checkBox_examineLabeled.isChecked():
+ while self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "isLabeled"] == 1 and Config["PlotEventIndex"] > 0:
+ Config["PlotEventIndex"] = Config["PlotEventIndex"] - 1
+ if Config["PlotEventIndex"] == 0:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_VIEWING_FIRST, Constants.MSGBOX_TYPE_INFO)
+ break
+ self.__plot__()
+ self.update_UI_Args()
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_PREV_EVENT + str(Config["PlotEventIndex"] + 1),
+ Constants.TIPS_TYPE_INFO)
+ elif sender == self.ui.pushButton_next:
+ if Config["PlotEventIndex"] == len(self.data.df_corrected) - 1:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_VIEWING_LAST, Constants.MSGBOX_TYPE_INFO)
+ return
+ else:
+ Config["PlotEventIndex"] = Config["PlotEventIndex"] + 1
+ if self.ui.checkBox_examineLabeled.isChecked():
+ while self.data.df_corrected.at[Config["EventLabelIndexList"][
+ Config["PlotEventIndex"]], "isLabeled"] == 1 and Config["PlotEventIndex"] < len(
+ self.data.df_corrected) - 1:
+ Config["PlotEventIndex"] = Config["PlotEventIndex"] + 1
+ if Config["PlotEventIndex"] == len(self.data.df_corrected) - 1:
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_VIEWING_LAST, Constants.MSGBOX_TYPE_INFO)
+ break
+ self.__plot__()
+ self.update_UI_Args()
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_NEXT_EVENT + str(Config["PlotEventIndex"] + 1),
+ Constants.TIPS_TYPE_INFO)
+
+ def __slot_btn_moveBySecond__(self):
+ sender = self.sender()
+
+ self.ui.lineEdit_remark.setText("")
+ self.ui.radioButton_OSA.setChecked(True)
+ if sender == self.ui.pushButton_previous10s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_PREV10S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] - 10
+ self.__plot__(Config["TimeMoveCount"])
+ elif sender == self.ui.pushButton_previous30s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_PREV30S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] - 30
+ self.__plot__(Config["TimeMoveCount"])
+ elif sender == self.ui.pushButton_previous60s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_PREV60S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] - 60
+ self.__plot__(Config["TimeMoveCount"])
+ elif sender == self.ui.pushButton_next10s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_NEXT10S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] + 10
+ self.__plot__(Config["TimeMoveCount"])
+ elif sender == self.ui.pushButton_next30s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_NEXT30S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] + 30
+ self.__plot__(Config["TimeMoveCount"])
+ elif sender == self.ui.pushButton_next60s:
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_MOVE_NEXT60S, Constants.MSGBOX_TYPE_INFO)
+ Config["TimeMoveCount"] = Config["TimeMoveCount"] + 60
+ self.__plot__(Config["TimeMoveCount"])
+
+ def __slot_btn_quick_remark__(self):
+ sender = self.sender()
+
+ if sender == self.ui.pushButton_quick_remark_input_waitingForTalk:
+ self.ui.lineEdit_remark.setText("待讨论")
+ elif sender == self.ui.pushButton_quick_remark_input_maybeDesaturation:
+ self.ui.lineEdit_remark.setText("形似潮式呼吸")
+ self.ui.radioButton_1_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_maybeWrongLabeled:
+ self.ui.lineEdit_remark.setText("疑似医生误标")
+ self.ui.radioButton_2_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_durationNoEnough:
+ self.ui.lineEdit_remark.setText("时长不足")
+ self.ui.radioButton_2_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_littleChange:
+ self.ui.lineEdit_remark.setText("起伏变化不大")
+ self.ui.radioButton_2_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_noNormalRespBetweenArtifact:
+ self.ui.lineEdit_remark.setText("体动间无正常呼吸")
+ self.ui.radioButton_2_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_lowSignalNoiseRatio:
+ self.ui.lineEdit_remark.setText("信噪比低")
+ self.ui.radioButton_2_class.setChecked(True)
+ elif sender == self.ui.pushButton_quick_remark_input_changeOnMiddle:
+ self.ui.lineEdit_remark.setText("中间起伏")
+ self.ui.radioButton_2_class.setChecked(True)
+
+ def __slot_tableWidget_label_on_cell_double_clicked__(self, row, column):
Config["PlotEventIndex"] = int(row)
- PublicFunc.text_output(self.ui, "{},index".format(Constants.SA_LABEL_JUMP, Config["PlotEventIndex"]), Constants.TIPS_TYPE_INFO)
- self.draw_one_event()
+ PublicFunc.text_output(self.ui, "{},index {}".format(Constants.SA_LABEL_JUMP, Config["PlotEventIndex"] + 1), Constants.TIPS_TYPE_INFO)
+ self.__plot__()
self.update_UI_Args()
- def slot_lineEdit_filter_label(self, filter_text):
+ def __slot_lineEdit_filter_label__(self, filter_text):
sender = self.sender()
if sender == self.ui.lineEdit_filter_label:
@@ -726,6 +960,39 @@ class MainWindow_SA_label(QMainWindow):
else:
raise ValueError("信号发生器错误")
+ def __slot_checkBox_examineLabeled__(self):
+ if self.ui.checkBox_examineLabeled.isChecked():
+ if (self.data.df_corrected.loc[Config["EventLabelIndexList"]]["isLabeled"] == 1).all():
+ self.ui.checkBox_examineLabeled.setChecked(False)
+ PublicFunc.text_output(self.ui, Constants.SA_LABEL_ALL_LABELED, Constants.TIPS_TYPE_INFO)
+ PublicFunc.msgbox_output(self, Constants.SA_LABEL_ALL_LABELED, Constants.MSGBOX_TYPE_INFO)
+
+ def __slot_checkBox_examineBySecond__(self):
+ if self.ui.checkBox_examineBySecond.isChecked():
+ ButtonState["Current"]["pushButton_previous10s"] = True
+ ButtonState["Current"]["pushButton_previous30s"] = True
+ ButtonState["Current"]["pushButton_previous60s"] = True
+ ButtonState["Current"]["pushButton_next10s"] = True
+ ButtonState["Current"]["pushButton_next30s"] = True
+ ButtonState["Current"]["pushButton_next60s"] = True
+ ButtonState["Current"]["pushButton_prev"]: False
+ ButtonState["Current"]["pushButton_next"]: False
+ self.ui.checkBox_examineLabeled.setEnabled(False)
+ self.ui.radioButton_OSA.setChecked(True)
+ self.ui.radioButton_2_class.setChecked(True)
+ self.ui.radioButton_3_class.setEnabled(False)
+ self.ui.lineEdit_remark.setText("")
+ else:
+ ButtonState["Current"]["pushButton_previous10s"] = False
+ ButtonState["Current"]["pushButton_previous30s"] = False
+ ButtonState["Current"]["pushButton_previous60s"] = False
+ ButtonState["Current"]["pushButton_next10s"] = False
+ ButtonState["Current"]["pushButton_next30s"] = False
+ ButtonState["Current"]["pushButton_next60s"] = False
+ self.ui.checkBox_examineLabeled.setEnabled(True)
+ self.ui.radioButton_3_class.setEnabled(True)
+ PublicFunc.finish_operation(self, ButtonState)
+
def toggle_resetOriginalView(self):
self.figToolbar.home()
self.figToolbar.action_Reset_Signal_and_Time.setChecked(False)
@@ -777,7 +1044,6 @@ class MainWindow_SA_label(QMainWindow):
Config["BCG_EP"] = bcg_EP
bcg_duration = bcg_EP - bcg_SP
- # "index:{} epoch:{} event:{}".format(Config["PlotEventIndex"], one_bcg_data['Epoch'], one_bcg_data['Event type'])
# 进行向两边延展
bcg_SP = bcg_SP - Config["AddSecond"]["Front"]
bcg_EP = bcg_EP + Config["AddSecond"]["Back"]
@@ -785,10 +1051,8 @@ class MainWindow_SA_label(QMainWindow):
if not (self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "isLabeled"] == -1):
bcg_duration_new = self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"] - \
self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"]
- self.ui.spinBox_correctStart.setValue(
- str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"]))
- self.ui.spinBox_correctEnd.setValue(
- str(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"]))
+ self.ui.spinBox_correctStart.setValue(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"])
+ self.ui.spinBox_correctEnd.setValue(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"])
self.ui.label_BCG_event.setText("Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)))
self.ui.label_BCG_event_2.setText("Epoch:{} Duration:{}s New Duration:{}s".format(one_bcg_data["Epoch"], bcg_duration, bcg_duration_new))
else:
@@ -797,31 +1061,61 @@ class MainWindow_SA_label(QMainWindow):
self.ui.spinBox_correctEnd.setValue(Config["BCG_EP"])
self.ui.label_BCG_event.setText("Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)))
self.ui.label_BCG_event_2.setText("Epoch:{} Duration:{}s".format(one_bcg_data["Epoch"], bcg_duration))
-
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="Flow T", bcg_duration_new=bcg_duration_new,
+ print(1)
+ self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="Flow T", bcg_duration_new=bcg_duration_new,
show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="Flow P", bcg_duration_new=bcg_duration_new,
+ self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow P", bcg_duration_new=bcg_duration_new,
show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", bcg_duration_new=bcg_duration_new,
+ self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", bcg_duration_new=bcg_duration_new,
show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", bcg_duration_new=bcg_duration_new,
+ self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", bcg_duration_new=bcg_duration_new,
show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5],
+ self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5],
bcg_duration_new=bcg_duration_new, show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
+ self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
event_show_under=False, bcg_duration_new=bcg_duration_new, show_mode="one")
- self.plt_channel(plt_=plt, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
+ self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
event_show_under=False,
- title="Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)),
bcg_duration_new=bcg_duration_new, show_mode="one")
self.ax0.callbacks.connect('xlim_changed', lambda ax: self.on_xlim_change(ax))
- def plt_channel(self, plt_, SP, EP, channel, event_code=[1, 2, 3, 4], event_show_under=False,
- title=None, bcg_duration_new=-1,
- show_mode=None):
+ def draw_new_event(self, time_move_count: int):
+ one_bcg_data = self.data.df_corrected.loc[Config["PlotEventIndex"]]
+
+ # 获取BCG事件开始与结束时间
+ bcg_SP = one_bcg_data["Start"]
+ bcg_EP = one_bcg_data["End"]
+ Config["BCG_SP"] = bcg_SP
+ Config["BCG_EP"] = bcg_EP
+ bcg_duration = bcg_EP - bcg_SP
+
+ # 进行向两边延展
+ bcg_SP = bcg_SP - Config["AddSecond"]["Front"] + time_move_count
+ bcg_EP = bcg_EP + Config["AddSecond"]["Back"] + time_move_count
+
+ self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="Flow T", show_mode="new")
+ self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow P", show_mode="new")
+ self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", show_mode="new")
+ self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", show_mode="new")
+ self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5], show_mode="new")
+ self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
+ event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
+ event_show_under=False, show_mode="new")
+ self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
+ event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
+ event_show_under=False,
+ show_mode="new")
+
+ self.ui.label_BCG_event.setText(
+ "Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)))
+ self.ui.label_BCG_event_2.setText("Epoch:{} Duration:{}s".format(one_bcg_data["Epoch"], bcg_duration))
+
+ self.ax0.callbacks.connect('xlim_changed', lambda ax: self.on_xlim_change(ax))
+
+ def plt_channel(self, plt_, SP, EP, channel, event_code=[1, 2, 3, 4], event_show_under=False, bcg_duration_new=-1, show_mode=None):
SP = 0 if SP < 0 else SP
plt_.plot(linspace(SP, EP, (EP - SP) * Config["InputConfig"]["PlotFreq"]),
self.data.channel[channel][SP * Config["InputConfig"]["PlotFreq"]:EP * Config["InputConfig"]["PlotFreq"]], label=channel,
@@ -850,69 +1144,83 @@ class MainWindow_SA_label(QMainWindow):
plt_.plot(linspace(SP, EP, (EP - SP) * Config["InputConfig"]["PlotFreq"]), y, color=self.color_cycle[j],
linestyle="-")
plt_.legend(fontsize=8, loc=1)
- if title is not None:
- plt_.title(title)
-
- ax = plt.gca()
- ax.grid(True)
+ ax_ = [self.ax0, self.ax1, self.ax2, self.ax3, self.ax4, self.ax5, self.ax6]
# 绘制半透明矩形框
if show_mode == "one":
if not (bcg_duration_new == -1):
if self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "correct_EventsType"] == "Obstructive apnea":
- ax.axvspan(
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_End"],
- color='red',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_EventsType"] == "Obstructive apnea":
+ for ax in ax_:
+ ax.axvspan(
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"],
+ color='red',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "correct_EventsType"] == "Central apnea":
- ax.axvspan(
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_End"],
- color='blue',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_EventsType"] == "Central apnea":
+ for ax in ax_:
+ ax.axvspan(
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"],
+ color='blue',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "correct_EventsType"] == "Mixed apnea":
- ax.axvspan(
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_End"],
- color='gray',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_EventsType"] == "Mixed apnea":
+ for ax in ax_:
+ ax.axvspan(
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"],
+ color='gray',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "correct_EventsType"] == "Hypopnea":
- ax.axvspan(
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "correct_End"],
- color='pink',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_EventsType"] == "Hypopnea":
+ for ax in ax_:
+ ax.axvspan(
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "correct_End"],
+ color='pink',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
else:
if self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "Event type"] == "Obstructive apnea":
- ax.axvspan(self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "End"],
- color='red',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Event type"] == "Obstructive apnea":
+ for ax in ax_:
+ ax.axvspan(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "End"],
+ color='red',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "Event type"] == "Central apnea":
- ax.axvspan(self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "End"],
- color='blue',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Event type"] == "Central apnea":
+ for ax in ax_:
+ ax.axvspan(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "End"],
+ color='blue',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "Event type"] == "Mixed apnea":
- ax.axvspan(self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "End"],
- color='gray',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Event type"] == "Mixed apnea":
+ for ax in ax_:
+ ax.axvspan(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "End"],
+ color='gray',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
elif self.data.df_corrected.at[
- self.data.df_corrected[Config["PlotEventIndex"]], "Event type"] == "Hypopnea":
- ax.axvspan(self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "Start"],
- self.data.df_corrected.at[self.data.df_corrected[Config["PlotEventIndex"]], "End"],
- color='pink',
- alpha=0.3)
+ Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Event type"] == "Hypopnea":
+ for ax in ax_:
+ ax.axvspan(self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "Start"],
+ self.data.df_corrected.at[Config["EventLabelIndexList"][Config["PlotEventIndex"]], "End"],
+ color='pink',
+ alpha=ConfigParams.SA_LABEL_TRANSPARENCY)
+ def pd_add_new_row(self, df, score: int, remark: str, correct_Start: int, correct_End: int, correct_EventsType: str,
+ isLabeled: int):
+ new_row = Series(index=df.columns, data=nan)
+ new_row["score"] = score
+ new_row["remark"] = remark
+ new_row["correct_Start"] = correct_Start
+ new_row["correct_End"] = correct_End
+ new_row["correct_EventsType"] = correct_EventsType
+ new_row["isLabeled"] = isLabeled
+ return concat([df, DataFrame([new_row])], ignore_index=True)
class Data:
@@ -934,13 +1242,13 @@ class Data:
self.lowPass20Hz_Resampled = None
self.lowPassResp_Resampled = None
self.channel = {
- "orgdata": self.lowPass20Hz_Resampled,
- "0.7lowpass_resp": self.lowPassResp_Resampled,
- "Effort Tho": self.Tho_Resampled,
- "Effort Abd": self.Abd_Resampled,
- "Flow T": self.FlowT_Resampled,
- "Flow P": self.FlowP_Resampled,
- "SpO2": self.SpO2_Resampled
+ "orgdata": array([]),
+ "0.7lowpass_resp": array([]),
+ "Effort Tho": array([]),
+ "Effort Abd": array([]),
+ "Flow T": array([]),
+ "Flow P": array([]),
+ "SpO2": array([])
}
self.event_label = None
@@ -951,6 +1259,23 @@ class Data:
self.df_addNew = None
def open_file(self):
+ if Path(Config["Path"]["Input_OrgBCG"]).is_file():
+ Config["Path"]["Input_OrgBCG"] = str(Path(Config["Path"]["Input_orgBcg"]).parent)
+ if Path(Config["Path"]["Input_Tho"]).is_file():
+ Config["Path"]["Input_Tho"] = str(Path(Config["Path"]["Input_Tho"]).parent)
+ if Path(Config["Path"]["Input_Abd"]).is_file():
+ Config["Path"]["Input_Abd"] = str(Path(Config["Path"]["Input_Abd"]).parent)
+ if Path(Config["Path"]["Input_FlowT"]).is_file():
+ Config["Path"]["Input_FlowT"] = str(Path(Config["Path"]["Input_FlowT"]).parent)
+ if Path(Config["Path"]["Input_FlowP"]).is_file():
+ Config["Path"]["Input_FlowP"] = str(Path(Config["Path"]["Input_FlowP"]).parent)
+ if Path(Config["Path"]["Input_SpO2"]).is_file():
+ Config["Path"]["Input_SpO2"] = str(Path(Config["Path"]["Input_SpO2"]).parent)
+ if Path(Config["Path"]["Input_Artifact"]).is_file():
+ Config["Path"]["Input_Artifact"] = str(Path(Config["Path"]["Input_Artifact"]).parent)
+ if Path(Config["Path"]["Input_Label"]).is_file():
+ Config["Path"]["Input_Label"] = str(Path(Config["Path"]["Input_Label"]).parent)
+
if ((not Path(Config["Path"]["Input_OrgBCG"]).exists())
or (not Path(Config["Path"]["Input_Tho"]).exists())
or (not Path(Config["Path"]["Input_Abd"]).exists())
@@ -958,7 +1283,54 @@ class Data:
or (not Path(Config["Path"]["Input_FlowP"]).exists())
or (not Path(Config["Path"]["Input_SpO2"]).exists())
or (not Path(Config["Path"]["Input_Artifact"]).exists())):
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Data_Path_Not_Exist"])
+ return Result().failure(info=Constants.INPUT_FAILURE +
+ Constants.FAILURE_REASON["Path_Not_Exist"])
+
+ result = PublicFunc.examine_file(Config["Path"]["Input_OrgBCG"], ConfigParams.ORGBCG_SYNC)
+ if result.status:
+ Config["Path"]["Input_OrgBCG"] = result.data["path"]
+ Config["InputConfig"]["OrgBCGFreq"] = result.data["freq"]
+ else:
+ return result
+ result = PublicFunc.examine_file(Config["Path"]["Input_Tho"], ConfigParams.THO_SYNC)
+ if result.status:
+ Config["Path"]["Input_Tho"] = result.data["path"]
+ Config["InputConfig"]["ThoFreq"] = result.data["freq"]
+ else:
+ return result
+ result = PublicFunc.examine_file(Config["Path"]["Input_Abd"], ConfigParams.ABD_SYNC)
+ if result.status:
+ Config["Path"]["Input_Abd"] = result.data["path"]
+ Config["InputConfig"]["AbdFreq"] = result.data["freq"]
+ else:
+ return result
+ result = PublicFunc.examine_file(Config["Path"]["Input_FlowT"], ConfigParams.FLOWT_SYNC)
+ if result.status:
+ Config["Path"]["Input_FlowT"] = result.data["path"]
+ Config["InputConfig"]["FlowTFreq"] = result.data["freq"]
+ else:
+ return result
+ result = PublicFunc.examine_file(Config["Path"]["Input_FlowP"], ConfigParams.FLOWP_SYNC)
+ if result.status:
+ Config["Path"]["Input_FlowP"] = result.data["path"]
+ Config["InputConfig"]["FlowPFreq"] = result.data["freq"]
+ else:
+ return result
+ result = PublicFunc.examine_file(Config["Path"]["Input_SpO2"], ConfigParams.SPO2_SYNC)
+ if result.status:
+ Config["Path"]["Input_SpO2"] = result.data["path"]
+ Config["InputConfig"]["SpO2Freq"] = result.data["freq"]
+ else:
+ return result
+
+ Config["Path"]["Input_Artifact"] = str(
+ Path(Config["Path"]["Input_Artifact"]) / Path(ConfigParams.ARTIFACT_A + ConfigParams.ENDSWITH_TXT))
+ Config["Path"]["Input_Label"] = str(
+ Path(Config["Path"]["Input_Label"]) / Path(ConfigParams.SA_LABEL_SYNC + ConfigParams.ENDSWITH_CSV))
+ Config["Path"]["Save"] = str(
+ Path(Config["Path"]["Save"]) / Path(ConfigParams.SA_LABEL_CORRECTED + ConfigParams.ENDSWITH_CSV))
+ Config["Path"]["Save_2"] = str(
+ Path(Config["Path"]["Save_2"]) / Path(ConfigParams.SA_LABEL_ADD + ConfigParams.ENDSWITH_CSV))
try:
self.OrgBCG = read_csv(Config["Path"]["Input_OrgBCG"],
@@ -984,19 +1356,22 @@ class Data:
header=None).to_numpy().reshape(-1)
self.event_label = zeros(len(self.OrgBCG) + (int(Config["AddSecond"]["Front"] + int(Config["AddSecond"]["Back"])) * Config["InputConfig"]["PlotFreq"]))
except Exception as e:
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.INPUT_FAILURE +
+ Constants.FAILURE_REASON["Open_Data_Exception"] + "\n" + format_exc())
try:
# 检查体动标签正确性,长度
if len(self.Artifact) % 4 != 0:
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Artifact_Format_Not_Correct"])
+ return Result().failure(info=Constants.INPUT_FAILURE +
+ Constants.FAILURE_REASON["Artifact_Format_Not_Correct"])
for i in range(0, len(self.Artifact), 4):
unit_data = self.Artifact[i:i + 4]
if len(unit_data) < 4:
break
self.Artifact = self.Artifact.reshape(-1, 4)
except Exception as e:
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Get_Artifact_Format_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.INPUT_FAILURE +
+ Constants.FAILURE_REASON["Get_Artifact_Format_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.INPUT_FINISHED)
@@ -1041,7 +1416,7 @@ class Data:
self.df_addNew["isLabeled"] = self.df_addNew["isLabeled"].astype(int)
self.df_addNew.to_csv(Config["Path"]["Save_2"], index=False, encoding="gbk")
Config["EventLabelIndexList"] = self.df_corrected.index.tolist()
- return Result().success(info=Constants.SA_LABEL_ARCHIVE_NOT_EXIST)
+ return Result().success(info=Constants.ARCHIVE_NOT_EXIST)
else:
try:
self.df_corrected = read_csv(Config["Path"]["Save"], encoding="gbk")
@@ -1049,12 +1424,12 @@ class Data:
csv_headers = self.df_corrected.columns.tolist()
if not (("score" in csv_headers) or ("remark" in csv_headers) or ("correct_Start" in csv_headers) or (
"correct_End") in csv_headers or ("isLabeled" in csv_headers)):
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON[
+ return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON[
"Label_Format_Exception"])
csv_headers = self.df_addNew.columns.tolist()
if not (("score" in csv_headers) or ("remark" in csv_headers) or ("correct_Start" in csv_headers) or (
"correct_End") in csv_headers or ("isLabeled" in csv_headers)):
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON[
+ return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON[
"Label_Format_Exception"])
Config["EventLabelIndexList"] = self.df_corrected.index.tolist()
for one_data in self.df_corrected.index:
@@ -1071,14 +1446,14 @@ class Data:
elif one_data["Event type"] == "Mixed apnea":
self.event_label[SP:EP] = 4
except Exception as e:
- return Result().failure(info=Constants.INPUT_FAILURE + Constants.SA_LABEL_FAILURE_REASON[
+ return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON[
"Label_Format_Exception"] + "\n" + format_exc())
- return Result().success(info=Constants.SA_LABEL_ARCHIVE_EXIST)
+ return Result().success(info=Constants.ARCHIVE_EXIST)
def preprocess(self):
if self.OrgBCG is None:
- return Result().failure(info=Constants.SA_LABEL_PROCESS_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Raw_Data_Not_Exist"])
+ return Result().failure(info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
self.lowPass20Hz = Butterworth_for_ECG_PreProcess(self.OrgBCG, Config["InputConfig"]["OrgBCGFreq"],
@@ -1098,13 +1473,15 @@ class Data:
continue
self.artifact_label[SP:EP] = artifact_type
except Exception as e:
- return Result().failure(info=Constants.SA_LABEL_PROCESS_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Filter_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.PREPROCESS_FAILURE +
+ Constants.FAILURE_REASON["Preprocess_Exception"] + "\n" + format_exc())
- return Result().success(info=Constants.SA_LABEL_PROCESS_FINISHED)
+ return Result().success(info=Constants.PREPROCESS_FINISHED)
def resample(self):
if self.Tho is None or self.Abd is None or self.FlowT is None or self.FlowP is None or self.SpO2 is None or self.lowPass20Hz is None or self.lowPassResp is None:
- return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Raw_Data_Not_Exist"])
+ return Result().failure(info=Constants.RESAMPLE_FAILURE +
+ Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["OrgBCGFreq"] < Config["InputConfig"]["PlotFreq"]:
@@ -1194,18 +1571,49 @@ class Data:
(int(Config["AddSecond"]["Front"] + int(Config["AddSecond"]["Back"]))
* Config["InputConfig"]["PlotFreq"])))
- self.channel["orgdata"] = self.lowPass20Hz_Resampled,
- self.channel["7lowpass_resp"] = self.lowPassResp_Resampled,
- self.channel["Effort Tho"] = self.Tho_Resampled,
- self.channel["Effort Abd"] = self.Abd_Resampled,
- self.channel["Flow T"] = self.FlowT_Resampled,
- self.channel["Flow P"] = self.FlowP_Resampled,
- self.channel["SpO2"] = self.SpO2_Resampled,
+ self.channel["orgdata"] = self.lowPass20Hz_Resampled
+ self.channel["0.7lowpass_resp"] = self.lowPassResp_Resampled
+ self.channel["Effort Tho"] = self.Tho_Resampled
+ self.channel["Effort Abd"] = self.Abd_Resampled
+ self.channel["Flow T"] = self.FlowT_Resampled
+ self.channel["Flow P"] = self.FlowP_Resampled
+ self.channel["SpO2"] = self.SpO2_Resampled
except Exception as e:
- return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.SA_LABEL_FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
+ return Result().failure(info=Constants.RESAMPLE_FAILURE +
+ Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)
+ def save(self):
+ 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_corrected is None:
+ return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
+
+ try:
+ self.df_corrected.to_csv(Config["Path"]["Save"], mode='w', index=None, encoding="gbk")
+ except Exception as e:
+ return Result().failure(info=Constants.SAVE_FAILURE +
+ Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
+
+ return Result().success(Constants.SAVE_FINISHED)
+
+ def save_2(self):
+ if (not Path(Config["Path"]["Save_2"]).parent.exists()) or (not Path(Config["Path"]["Save_2"]).parent.is_dir()):
+ Path(Config["Path"]["Save_2"]).parent.mkdir(parents=True, exist_ok=True)
+
+ if self.df_addNew is None:
+ return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
+
+ try:
+ self.df_addNew.to_csv(Config["Path"]["Save_2"], mode='w', index=None, encoding="gbk")
+ except Exception as e:
+ return Result().failure(info=Constants.SAVE_FAILURE +
+ Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
+
+ return Result().success(Constants.SAVE_FINISHED)
+
class CustomNavigationToolbar(NavigationToolbar2QT):
def __init__(self, canvas, parent):
diff --git a/func/utils/Constants.py b/func/utils/Constants.py
index 64079d1..71a1735 100644
--- a/func/utils/Constants.py
+++ b/func/utils/Constants.py
@@ -392,6 +392,7 @@ class Constants:
SA_LABEL_MOVE_NEXT60S: str = "向后60秒"
SA_LABEL_LENGTH_TOO_LONG: str = "起始时间或终止时间超出信号长度范围,请输入正确的参数"
SA_LABEL_LENGTH_LESS_THEN_10S: str = "当前标注的事件的持续时间小于10秒"
+ SA_LABEL_WRONG_ARGS: str = "起始时间和终止时间输入错误"
diff --git a/ui/MainWindow/MainWindow_SA_label.py b/ui/MainWindow/MainWindow_SA_label.py
index b2e08f5..21c196f 100644
--- a/ui/MainWindow/MainWindow_SA_label.py
+++ b/ui/MainWindow/MainWindow_SA_label.py
@@ -81,84 +81,6 @@ class Ui_MainWindow_SA_label(object):
self.verticalLayout_2.addItem(self.verticalSpacer)
- self.groupBox_plotArgs = QGroupBox(self.groupBox_left)
- self.groupBox_plotArgs.setObjectName(u"groupBox_plotArgs")
- self.gridLayout_2 = QGridLayout(self.groupBox_plotArgs)
- self.gridLayout_2.setObjectName(u"gridLayout_2")
- self.label_3 = QLabel(self.groupBox_plotArgs)
- self.label_3.setObjectName(u"label_3")
- sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
- sizePolicy1.setHorizontalStretch(0)
- sizePolicy1.setVerticalStretch(0)
- sizePolicy1.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
- self.label_3.setSizePolicy(sizePolicy1)
- self.label_3.setFont(font1)
-
- self.gridLayout_2.addWidget(self.label_3, 1, 0, 1, 1)
-
- self.label_5 = QLabel(self.groupBox_plotArgs)
- self.label_5.setObjectName(u"label_5")
- sizePolicy1.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth())
- self.label_5.setSizePolicy(sizePolicy1)
- self.label_5.setFont(font1)
-
- self.gridLayout_2.addWidget(self.label_5, 2, 0, 1, 1)
-
- self.label_4 = QLabel(self.groupBox_plotArgs)
- self.label_4.setObjectName(u"label_4")
- sizePolicy1.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
- self.label_4.setSizePolicy(sizePolicy1)
- self.label_4.setFont(font1)
-
- self.gridLayout_2.addWidget(self.label_4, 0, 0, 1, 1)
-
- self.label_10 = QLabel(self.groupBox_plotArgs)
- self.label_10.setObjectName(u"label_10")
- sizePolicy1.setHeightForWidth(self.label_10.sizePolicy().hasHeightForWidth())
- self.label_10.setSizePolicy(sizePolicy1)
- self.label_10.setFont(font1)
-
- self.gridLayout_2.addWidget(self.label_10, 3, 0, 1, 1)
-
- self.spinBox_plot_freq = QSpinBox(self.groupBox_plotArgs)
- self.spinBox_plot_freq.setObjectName(u"spinBox_plot_freq")
- self.spinBox_plot_freq.setFont(font1)
- self.spinBox_plot_freq.setMinimum(1)
- self.spinBox_plot_freq.setMaximum(10000)
-
- self.gridLayout_2.addWidget(self.spinBox_plot_freq, 0, 1, 1, 1)
-
- self.spinBox_orgBcg_freq = QSpinBox(self.groupBox_plotArgs)
- self.spinBox_orgBcg_freq.setObjectName(u"spinBox_orgBcg_freq")
- self.spinBox_orgBcg_freq.setFont(font1)
- self.spinBox_orgBcg_freq.setMinimum(1)
- self.spinBox_orgBcg_freq.setMaximum(10000)
-
- self.gridLayout_2.addWidget(self.spinBox_orgBcg_freq, 1, 1, 1, 1)
-
- self.spinBox_front_add_second = QSpinBox(self.groupBox_plotArgs)
- self.spinBox_front_add_second.setObjectName(u"spinBox_front_add_second")
- self.spinBox_front_add_second.setFont(font1)
- self.spinBox_front_add_second.setMinimum(1)
- self.spinBox_front_add_second.setMaximum(10000)
-
- self.gridLayout_2.addWidget(self.spinBox_front_add_second, 2, 1, 1, 1)
-
- self.spinBox_back_add_second = QSpinBox(self.groupBox_plotArgs)
- self.spinBox_back_add_second.setObjectName(u"spinBox_back_add_second")
- self.spinBox_back_add_second.setFont(font1)
- self.spinBox_back_add_second.setMinimum(1)
- self.spinBox_back_add_second.setMaximum(10000)
-
- self.gridLayout_2.addWidget(self.spinBox_back_add_second, 3, 1, 1, 1)
-
-
- self.verticalLayout_2.addWidget(self.groupBox_plotArgs)
-
- self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
-
- self.verticalLayout_2.addItem(self.verticalSpacer_2)
-
self.groupBox_label = QGroupBox(self.groupBox_left)
self.groupBox_label.setObjectName(u"groupBox_label")
self.gridLayout_3 = QGridLayout(self.groupBox_label)
@@ -209,11 +131,11 @@ class Ui_MainWindow_SA_label(object):
self.gridLayout_3.addItem(self.verticalSpacer_4, 2, 0, 1, 2)
- self.gridLayout_3.setRowMinimumHeight(0, 1)
- self.gridLayout_3.setRowMinimumHeight(1, 5)
- self.gridLayout_3.setRowMinimumHeight(2, 1)
- self.gridLayout_3.setRowMinimumHeight(3, 1)
- self.gridLayout_3.setRowMinimumHeight(4, 5)
+ self.gridLayout_3.setRowStretch(0, 2)
+ self.gridLayout_3.setRowStretch(1, 10)
+ self.gridLayout_3.setRowStretch(2, 1)
+ self.gridLayout_3.setRowStretch(4, 2)
+ self.gridLayout_3.setRowStretch(5, 10)
self.verticalLayout_2.addWidget(self.groupBox_label)
@@ -235,11 +157,9 @@ class Ui_MainWindow_SA_label(object):
self.verticalLayout_2.setStretch(0, 2)
self.verticalLayout_2.setStretch(1, 1)
- self.verticalLayout_2.setStretch(2, 4)
+ self.verticalLayout_2.setStretch(2, 15)
self.verticalLayout_2.setStretch(3, 1)
- self.verticalLayout_2.setStretch(4, 15)
- self.verticalLayout_2.setStretch(5, 1)
- self.verticalLayout_2.setStretch(6, 5)
+ self.verticalLayout_2.setStretch(4, 5)
self.gridLayout.addWidget(self.groupBox_left, 0, 0, 1, 1)
@@ -448,67 +368,67 @@ class Ui_MainWindow_SA_label(object):
self.gridLayout_5.setObjectName(u"gridLayout_5")
self.pushButton_quick_remark_input_durationNoEnough = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_durationNoEnough.setObjectName(u"pushButton_quick_remark_input_durationNoEnough")
- sizePolicy2 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
- sizePolicy2.setHorizontalStretch(0)
- sizePolicy2.setVerticalStretch(0)
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_durationNoEnough.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_durationNoEnough.setSizePolicy(sizePolicy2)
+ sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
+ sizePolicy1.setHorizontalStretch(0)
+ sizePolicy1.setVerticalStretch(0)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_durationNoEnough.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_durationNoEnough.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_durationNoEnough.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_durationNoEnough, 1, 1, 1, 1)
self.pushButton_quick_remark_input_maybeWrongLabeled = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_maybeWrongLabeled.setObjectName(u"pushButton_quick_remark_input_maybeWrongLabeled")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_maybeWrongLabeled.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_maybeWrongLabeled.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_maybeWrongLabeled.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_maybeWrongLabeled.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_maybeWrongLabeled.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_maybeWrongLabeled, 1, 0, 1, 1)
self.pushButton_quick_remark_input_noNormalRespBetweenArtifact = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.setObjectName(u"pushButton_quick_remark_input_noNormalRespBetweenArtifact")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_noNormalRespBetweenArtifact.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_noNormalRespBetweenArtifact, 2, 1, 1, 1)
self.pushButton_quick_remark_input_maybeDesaturation = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_maybeDesaturation.setObjectName(u"pushButton_quick_remark_input_maybeDesaturation")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_maybeDesaturation.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_maybeDesaturation.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_maybeDesaturation.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_maybeDesaturation.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_maybeDesaturation.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_maybeDesaturation, 0, 1, 1, 1)
self.pushButton_quick_remark_input_littleChange = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_littleChange.setObjectName(u"pushButton_quick_remark_input_littleChange")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_littleChange.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_littleChange.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_littleChange.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_littleChange.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_littleChange.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_littleChange, 2, 0, 1, 1)
self.pushButton_quick_remark_input_waitingForTalk = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_waitingForTalk.setObjectName(u"pushButton_quick_remark_input_waitingForTalk")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_waitingForTalk.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_waitingForTalk.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_waitingForTalk.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_waitingForTalk.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_waitingForTalk.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_waitingForTalk, 0, 0, 1, 1)
self.pushButton_quick_remark_input_lowSignalNoiseRatio = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_lowSignalNoiseRatio.setObjectName(u"pushButton_quick_remark_input_lowSignalNoiseRatio")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_lowSignalNoiseRatio.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_lowSignalNoiseRatio.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_lowSignalNoiseRatio.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_lowSignalNoiseRatio.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_lowSignalNoiseRatio.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_lowSignalNoiseRatio, 3, 0, 1, 1)
self.pushButton_quick_remark_input_changeOnMiddle = QPushButton(self.groupBox_label_operation)
self.pushButton_quick_remark_input_changeOnMiddle.setObjectName(u"pushButton_quick_remark_input_changeOnMiddle")
- sizePolicy2.setHeightForWidth(self.pushButton_quick_remark_input_changeOnMiddle.sizePolicy().hasHeightForWidth())
- self.pushButton_quick_remark_input_changeOnMiddle.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_quick_remark_input_changeOnMiddle.sizePolicy().hasHeightForWidth())
+ self.pushButton_quick_remark_input_changeOnMiddle.setSizePolicy(sizePolicy1)
self.pushButton_quick_remark_input_changeOnMiddle.setFont(font1)
self.gridLayout_5.addWidget(self.pushButton_quick_remark_input_changeOnMiddle, 3, 1, 1, 1)
@@ -561,24 +481,24 @@ class Ui_MainWindow_SA_label(object):
self.gridLayout_7.setObjectName(u"gridLayout_7")
self.pushButton_prev = QPushButton(self.groupBox_label_operation)
self.pushButton_prev.setObjectName(u"pushButton_prev")
- sizePolicy2.setHeightForWidth(self.pushButton_prev.sizePolicy().hasHeightForWidth())
- self.pushButton_prev.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_prev.sizePolicy().hasHeightForWidth())
+ self.pushButton_prev.setSizePolicy(sizePolicy1)
self.pushButton_prev.setFont(font1)
self.gridLayout_7.addWidget(self.pushButton_prev, 0, 0, 1, 1)
self.pushButton_next = QPushButton(self.groupBox_label_operation)
self.pushButton_next.setObjectName(u"pushButton_next")
- sizePolicy2.setHeightForWidth(self.pushButton_next.sizePolicy().hasHeightForWidth())
- self.pushButton_next.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_next.sizePolicy().hasHeightForWidth())
+ self.pushButton_next.setSizePolicy(sizePolicy1)
self.pushButton_next.setFont(font1)
self.gridLayout_7.addWidget(self.pushButton_next, 1, 0, 1, 1)
self.pushButton_confirmLabel = QPushButton(self.groupBox_label_operation)
self.pushButton_confirmLabel.setObjectName(u"pushButton_confirmLabel")
- sizePolicy2.setHeightForWidth(self.pushButton_confirmLabel.sizePolicy().hasHeightForWidth())
- self.pushButton_confirmLabel.setSizePolicy(sizePolicy2)
+ sizePolicy1.setHeightForWidth(self.pushButton_confirmLabel.sizePolicy().hasHeightForWidth())
+ self.pushButton_confirmLabel.setSizePolicy(sizePolicy1)
self.pushButton_confirmLabel.setFont(font1)
self.gridLayout_7.addWidget(self.pushButton_confirmLabel, 0, 1, 2, 1)
@@ -632,11 +552,6 @@ class Ui_MainWindow_SA_label(object):
self.groupBox_left.setTitle(QCoreApplication.translate("MainWindow_SA_label", u"\u7761\u7720\u547c\u5438\u6682\u505c\u4e8b\u4ef6\u6807\u6ce8", None))
self.pushButton_input_setting.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u5bfc\u5165\u8bbe\u7f6e", None))
self.pushButton_input.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u5f00\u59cb\u5bfc\u5165", None))
- self.groupBox_plotArgs.setTitle(QCoreApplication.translate("MainWindow_SA_label", u"\u53c2\u6570\u8bbe\u7f6e", None))
- self.label_3.setText(QCoreApplication.translate("MainWindow_SA_label", u"orgBcg\u4fe1\u53f7\u91c7\u6837\u7387(Hz)", None))
- self.label_5.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u4fe1\u53f7\u5411\u524d\u6269\u5c55(s)", None))
- self.label_4.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u7ed8\u56fe\u91c7\u6837\u7387(Hz)", None))
- self.label_10.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u4fe1\u53f7\u5411\u540e\u6269\u5c55(s)", None))
self.groupBox_label.setTitle(QCoreApplication.translate("MainWindow_SA_label", u"\u6807\u7b7e\u8bb0\u5f55", None))
self.label.setText(QCoreApplication.translate("MainWindow_SA_label", u"\u539f\u6570\u636e\u7684\u6807\u7b7e", None))
self.lineEdit_filter_label_add.setPlaceholderText(QCoreApplication.translate("MainWindow_SA_label", u"\u7b5b\u9009\u5668", None))
diff --git a/ui/MainWindow/MainWindow_SA_label.ui b/ui/MainWindow/MainWindow_SA_label.ui
index c7cebdb..2e35b97 100644
--- a/ui/MainWindow/MainWindow_SA_label.ui
+++ b/ui/MainWindow/MainWindow_SA_label.ui
@@ -42,7 +42,7 @@
睡眠呼吸暂停事件标注
-
+
-
-
@@ -96,166 +96,12 @@
- -
-
-
- 参数设置
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 12
-
-
-
- orgBcg信号采样率(Hz)
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 12
-
-
-
- 信号向前扩展(s)
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 12
-
-
-
- 绘图采样率(Hz)
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 12
-
-
-
- 信号向后扩展(s)
-
-
-
- -
-
-
-
- 12
-
-
-
- 1
-
-
- 10000
-
-
-
- -
-
-
-
- 12
-
-
-
- 1
-
-
- 10000
-
-
-
- -
-
-
-
- 12
-
-
-
- 1
-
-
- 10000
-
-
-
- -
-
-
-
- 12
-
-
-
- 1
-
-
- 10000
-
-
-
-
-
-
- -
-
-
- Qt::Orientation::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
标签记录
-
+
-
diff --git a/ui/setting/SA_label_input_setting.py b/ui/setting/SA_label_input_setting.py
index 64a6fbd..b0a055c 100644
--- a/ui/setting/SA_label_input_setting.py
+++ b/ui/setting/SA_label_input_setting.py
@@ -274,6 +274,18 @@ class Ui_MainWindow_SA_label_input_setting(object):
self.gridLayout_2.addWidget(self.groupBox_file_path_input_artifact, 5, 0, 1, 1)
+ self.groupBox_file_path_input_label = QGroupBox(self.groupBox)
+ self.groupBox_file_path_input_label.setObjectName(u"groupBox_file_path_input_label")
+ self.verticalLayout_12 = QVBoxLayout(self.groupBox_file_path_input_label)
+ self.verticalLayout_12.setObjectName(u"verticalLayout_12")
+ self.plainTextEdit_file_path_input_label = QPlainTextEdit(self.groupBox_file_path_input_label)
+ self.plainTextEdit_file_path_input_label.setObjectName(u"plainTextEdit_file_path_input_label")
+
+ self.verticalLayout_12.addWidget(self.plainTextEdit_file_path_input_label)
+
+
+ self.gridLayout_2.addWidget(self.groupBox_file_path_input_label, 5, 1, 1, 1)
+
self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 4)
@@ -328,6 +340,8 @@ class Ui_MainWindow_SA_label_input_setting(object):
self.groupBox_file_path_input_artifact.setTitle(QCoreApplication.translate("MainWindow_SA_label_input_setting", u"\u4f53\u52a8Artifact_a\u8def\u5f84", None))
self.plainTextEdit_file_path_input_artifact.setPlainText("")
self.plainTextEdit_file_path_input_artifact.setPlaceholderText(QCoreApplication.translate("MainWindow_SA_label_input_setting", u"\u6587\u4ef6\u8def\u5f84", None))
+ self.groupBox_file_path_input_label.setTitle(QCoreApplication.translate("MainWindow_SA_label_input_setting", u"\u540c\u6b65\u540e\u7684\u547c\u5438\u6682\u505c\u6807\u7b7e\u4fdd\u5b58\u8def\u5f84", None))
+ self.plainTextEdit_file_path_input_label.setPlaceholderText(QCoreApplication.translate("MainWindow_SA_label_input_setting", u"\u6587\u4ef6\u8def\u5f84", None))
self.pushButton_confirm.setText(QCoreApplication.translate("MainWindow_SA_label_input_setting", u"\u786e\u5b9a", None))
# retranslateUi
diff --git a/ui/setting/SA_label_input_setting.ui b/ui/setting/SA_label_input_setting.ui
index 666686f..700fec9 100644
--- a/ui/setting/SA_label_input_setting.ui
+++ b/ui/setting/SA_label_input_setting.ui
@@ -389,6 +389,22 @@
+ -
+
+
+ 同步后的呼吸暂停标签保存路径
+
+
+
-
+
+
+ 文件路径
+
+
+
+
+
+