From 900912090af972121c7d5a1df024ed12776adf39 Mon Sep 17 00:00:00 2001 From: Yorusora <2944763079@qq.com> Date: Tue, 20 May 2025 20:25:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96<=E6=95=B0=E6=8D=AE=E7=B2=BE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5>=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/Module_detect_Jpeak.py | 7 + func/Module_detect_Rpeak.py | 7 + func/Module_label_check.py | 28 +++ func/Module_precisely_align.py | 228 +++++++++++++------- func/utils/ConfigParams.py | 19 +- func/utils/Constants.py | 146 ++++++------- ui/setting/precisely_align_input_setting.py | 44 +++- ui/setting/precisely_align_input_setting.ui | 66 +++++- 8 files changed, 386 insertions(+), 159 deletions(-) diff --git a/func/Module_detect_Jpeak.py b/func/Module_detect_Jpeak.py index 036ad25..61652c3 100644 --- a/func/Module_detect_Jpeak.py +++ b/func/Module_detect_Jpeak.py @@ -110,6 +110,13 @@ class SettingWindow(QMainWindow): Path(ConfigParams.BCG_FILTER + str(self.ui.spinBox_input_freq.value()) + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_save.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_PSG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.JPEAK_REVISE + + str(self.ui.spinBox_input_freq.value()) + + ConfigParams.ENDSWITH_TXT)))) class MainWindow_detect_Jpeak(QMainWindow): diff --git a/func/Module_detect_Rpeak.py b/func/Module_detect_Rpeak.py index ab9a4b1..03308e9 100644 --- a/func/Module_detect_Rpeak.py +++ b/func/Module_detect_Rpeak.py @@ -107,6 +107,13 @@ class SettingWindow(QMainWindow): Path(ConfigParams.ECG_FILTER + str(self.ui.spinBox_input_freq.value()) + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_save.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_PSG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.RPEAK_FINAL + + str(self.ui.spinBox_input_freq.value()) + + ConfigParams.ENDSWITH_TXT)))) class MainWindow_detect_Rpeak(QMainWindow): diff --git a/func/Module_label_check.py b/func/Module_label_check.py index d3ac375..87d5548 100644 --- a/func/Module_label_check.py +++ b/func/Module_label_check.py @@ -166,6 +166,20 @@ class SettingWindow(QMainWindow): Path(ConfigParams.BCG_FILTER + str(self.ui.spinBox_input_freq_signal.value()) + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_input_peak.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.JPEAK_REVISE + + str(self.ui.spinBox_input_freq_signal.value()) + + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_save.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.JPEAK_REVISE_CORRECTED + + str(self.ui.spinBox_input_freq_signal.value()) + + ConfigParams.ENDSWITH_TXT)))) elif self.mode == "ECG": self.ui.plainTextEdit_file_path_input_signal.setPlainText( str((Path(self.root_path) / @@ -174,6 +188,20 @@ class SettingWindow(QMainWindow): Path(ConfigParams.ECG_FILTER + str(self.ui.spinBox_input_freq_signal.value()) + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_input_peak.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_PSG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.RPEAK_FINAL + + str(self.ui.spinBox_input_freq_signal.value()) + + ConfigParams.ENDSWITH_TXT)))) + self.ui.plainTextEdit_file_path_save.setPlainText( + str((Path(self.root_path) / + ConfigParams.PUBLIC_PATH_PSG_TEXT / + Path(str(self.sampID)) / + Path(ConfigParams.RPEAK_FINAL_CORRECTED + + str(self.ui.spinBox_input_freq_signal.value()) + + ConfigParams.ENDSWITH_TXT)))) else: raise ValueError("模式不存在") diff --git a/func/Module_precisely_align.py b/func/Module_precisely_align.py index 3978441..34766e6 100644 --- a/func/Module_precisely_align.py +++ b/func/Module_precisely_align.py @@ -94,6 +94,8 @@ class SettingWindow(QMainWindow): self.config = None self.__read_config__() + self.ui.spinBox_input_freq_orgBcg.valueChanged.connect(self.__update_ui__) + self.ui.spinBox_input_freq_BCG.valueChanged.connect(self.__update_ui__) self.ui.spinBox_input_freq_ECG.valueChanged.connect(self.__update_ui__) self.ui.pushButton_confirm.clicked.connect(self.__write_config__) self.ui.pushButton_cancel.clicked.connect(self.__rollback_config__) @@ -112,47 +114,29 @@ class SettingWindow(QMainWindow): Config.update({ "Path": { "Input_OrgBCG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_INPUT_ORGBCG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Input_BCG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_INPUT_BCG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Input_Jpeak": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_INPUT_JPEAK_FILENAME + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Input_ECG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_INPUT_ECG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Input_Rpeak": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_INPUT_RPEAK_FILENAME + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Input_Approximately_Align": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_APPROXIMATELY_ALIGNINFO_FILENAME + - ConfigParams.ENDSWITH_CSV))), + Path(str(self.sampID)))), "Save_AlignInfo": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_ALIGNINFO_FILENAME + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Save_OrgBCG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_ORGBCG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Save_BCG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_BCG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Save_ECG": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_ECG_FILENAME + - str(Config["InputConfig"]["ECGFreq"]) + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Save_Jpeak": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_JPEAK_FILENAME + - ConfigParams.ENDSWITH_TXT))), + Path(str(self.sampID)))), "Save_Rpeak": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED / - Path(str(self.sampID)) / Path(ConfigParams.PRECISELY_ALIGN_SAVE_RPEAK_FILENAME + - ConfigParams.ENDSWITH_TXT))) + Path(str(self.sampID)))) }, "Coordinate": { "BCG_front_1": 0, @@ -198,6 +182,8 @@ class SettingWindow(QMainWindow): }) # 数据回显 + self.ui.spinBox_input_freq_orgBcg.setValue(Config["InputConfig"]["orgBcgFreq"]) + self.ui.spinBox_input_freq_BCG.setValue(Config["InputConfig"]["BCGFreq"]) self.ui.spinBox_input_freq_ECG.setValue(Config["InputConfig"]["ECGFreq"]) self.ui.plainTextEdit_file_path_input_orgBcg.setPlainText(Config["Path"]["Input_OrgBCG"]) self.ui.plainTextEdit_file_path_input_BCG.setPlainText(Config["Path"]["Input_BCG"]) @@ -214,6 +200,8 @@ class SettingWindow(QMainWindow): def __write_config__(self): # 从界面写入配置 + Config["InputConfig"]["orgBcgFreq"] = self.ui.spinBox_input_freq_orgBcg.value() + Config["InputConfig"]["BCGFreq"] = self.ui.spinBox_input_freq_BCG.value() Config["InputConfig"]["ECGFreq"] = self.ui.spinBox_input_freq_ECG.value() Config["Path"]["Input_OrgBCG"] = self.ui.plainTextEdit_file_path_input_orgBcg.toPlainText() Config["Path"]["Input_BCG"] = self.ui.plainTextEdit_file_path_input_BCG.toPlainText() @@ -229,6 +217,8 @@ class SettingWindow(QMainWindow): Config["Path"]["Save_Rpeak"] = self.ui.plainTextEdit_file_path_save_Rpeak.toPlainText() # 保存配置到文件 + self.config["InputConfig"]["orgBcgFreq"] = self.ui.spinBox_input_freq_orgBcg.value() + self.config["InputConfig"]["BCGFreq"] = self.ui.spinBox_input_freq_BCG.value() self.config["InputConfig"]["ECGFreq"] = self.ui.spinBox_input_freq_ECG.value() with open(ConfigParams.PRECISELY_ALIGN_CONFIG_FILE_PATH, "w") as f: @@ -244,55 +234,57 @@ class SettingWindow(QMainWindow): str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_INPUT_ORGBCG_FILENAME + - str(self.ui.spinBox_input_freq_ECG.value()) + + Path(ConfigParams.ORGBCG_RAW + + str(self.ui.spinBox_input_freq_orgBcg.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_input_BCG.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_TEXT / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_INPUT_BCG_FILENAME + - str(self.ui.spinBox_input_freq_ECG.value()) + + Path(ConfigParams.BCG_FILTER + + str(self.ui.spinBox_input_freq_BCG.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_input_ECG.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_INPUT_ECG_FILENAME + + Path(ConfigParams.ECG_FILTER + str(self.ui.spinBox_input_freq_ECG.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_save_orgBcg.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_SAVE_ORGBCG_FILENAME + - str(self.ui.spinBox_input_freq_ECG.value()) + + Path(ConfigParams.ORGBCG_SYNC + + str(self.ui.spinBox_input_freq_orgBcg.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_save_BCG.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_SAVE_BCG_FILENAME + - str(self.ui.spinBox_input_freq_ECG.value()) + + Path(ConfigParams.BCG_SYNC + + str(self.ui.spinBox_input_freq_BCG.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_save_ECG.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_SAVE_ECG_FILENAME + + Path(ConfigParams.ECG_SYNC + str(self.ui.spinBox_input_freq_ECG.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_save_Jpeak.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_ORGBCG_ALIGNED / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_SAVE_JPEAK_FILENAME + + Path(ConfigParams.JPEAK_SYNC + + str(self.ui.spinBox_input_freq_BCG.value()) + ConfigParams.ENDSWITH_TXT)))) self.ui.plainTextEdit_file_path_save_Rpeak.setPlainText( str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED / Path(str(self.sampID)) / - Path(ConfigParams.PRECISELY_ALIGN_SAVE_RPEAK_FILENAME + + Path(ConfigParams.RPEAK_SYNC + + str(self.ui.spinBox_input_freq_ECG.value()) + ConfigParams.ENDSWITH_TXT)))) @@ -650,7 +642,7 @@ class MainWindow_precisely_align(QMainWindow): PublicFunc.text_output(self.ui, "(1/3)" + result.info, Constants.TIPS_TYPE_INFO) # 处理数据 - PublicFunc.progressbar_update(self, 2, 3, Constants.DRAWING_DATA, 50) + PublicFunc.progressbar_update(self, 2, 3, Constants.PRECISELY_ALIGN_PROCESSING_DATA, 50) result = self.data.data_process_for_calculate_correlation() if not result.status: PublicFunc.text_output(self.ui, "(2/3)" + result.info, Constants.TIPS_TYPE_ERROR) @@ -946,7 +938,7 @@ class MainWindow_precisely_align(QMainWindow): try: if self.data is not None: if self.data.Jpeak is None or self.data.Rpeak is None: - PublicFunc.msgbox_output(self, Constants.PRECISELY_ALIGN_FAILURE_REASON["Data_Not_Exist"], Constants.MSGBOX_TYPE_ERROR) + PublicFunc.msgbox_output(self, Constants.FAILURE_REASON["Data_Not_Exist"], Constants.MSGBOX_TYPE_ERROR) return sender = self.sender() @@ -1435,11 +1427,69 @@ class Data: self.argmax_ECG = None def open_file(self): - if ((not Path(Config["Path"]["Input_BCG"]).exists()) + if Path(Config["Path"]["Input_OrgBCG"]).is_file(): + Config["Path"]["Input_OrgBCG"] = str(Path(Config["Path"]["Input_OrgBCG"]).parent) + if Path(Config["Path"]["Input_BCG"]).is_file(): + Config["Path"]["Input_BCG"] = str(Path(Config["Path"]["Input_BCG"]).parent) + if Path(Config["Path"]["Input_Jpeak"]).is_file(): + Config["Path"]["Input_Jpeak"] = str(Path(Config["Path"]["Input_Jpeak"]).parent) + if Path(Config["Path"]["Input_ECG"]).is_file(): + Config["Path"]["Input_ECG"] = str(Path(Config["Path"]["Input_ECG"]).parent) + if Path(Config["Path"]["Input_Rpeak"]).is_file(): + Config["Path"]["Input_Rpeak"] = str(Path(Config["Path"]["Input_Rpeak"]).parent) + if Path(Config["Path"]["Input_Approximately_Align"]).is_file(): + Config["Path"]["Input_Approximately_Align"] = str(Path(Config["Path"]["Input_Approximately_Align"]).parent) + + result = PublicFunc.examine_file(Config["Path"]["Input_OrgBCG"], ConfigParams.ORGBCG_RAW) + if result.status: + Config["Path"]["Input_OrgBCG"] = result.data["path"] + Config["InputConfig"]["orgBcgFreq"] = result.data["freq"] + Config["Path"]["Input_Approximately_Align"] = str( + Path(Config["Path"]["Input_Approximately_Align"]) / Path( + ConfigParams.APPROXIMATELY_ALIGN_INFO + ConfigParams.ENDSWITH_CSV)) + Config["Path"]["Save_AlignInfo"] = str( + Path(Config["Path"]["Save_AlignInfo"]) / Path( + ConfigParams.PRECISELY_ALIGN_INFO + ConfigParams.ENDSWITH_TXT)) + Config["Path"]["Save_OrgBCG"] = str( + Path(Config["Path"]["Save_OrgBCG"]) / Path( + ConfigParams.ORGBCG_SYNC + str(Config["InputConfig"]["orgBcgFreq"]) + ConfigParams.ENDSWITH_TXT)) + else: + return result + result = PublicFunc.examine_file(Config["Path"]["Input_BCG"], ConfigParams.BCG_FILTER) + if result.status: + Config["Path"]["Input_BCG"] = result.data["path"] + Config["InputConfig"]["BCGFreq"] = result.data["freq"] + Config["Path"]["Input_Jpeak"] = str( + Path(Config["Path"]["Input_Jpeak"]) / Path(ConfigParams.JPEAK_REVISE_CORRECTED + str(Config["InputConfig"]["BCGFreq"]) + ConfigParams.ENDSWITH_TXT)) + Config["Path"]["Save_BCG"] = str( + Path(Config["Path"]["Save_BCG"]) / Path( + ConfigParams.BCG_SYNC + str(Config["InputConfig"]["BCGFreq"]) + ConfigParams.ENDSWITH_TXT)) + Config["Path"]["Save_Jpeak"] = str( + Path(Config["Path"]["Save_Jpeak"]) / Path( + ConfigParams.JPEAK_SYNC + str(Config["InputConfig"]["BCGFreq"]) + ConfigParams.ENDSWITH_TXT)) + else: + return result + result = PublicFunc.examine_file(Config["Path"]["Input_ECG"], ConfigParams.ECG_FILTER) + if result.status: + Config["Path"]["Input_ECG"] = result.data["path"] + Config["InputConfig"]["ECGFreq"] = result.data["freq"] + Config["Path"]["Input_Rpeak"] = str( + Path(Config["Path"]["Input_Rpeak"]) / Path(ConfigParams.RPEAK_FINAL_CORRECTED + str(Config["InputConfig"]["ECGFreq"]) + ConfigParams.ENDSWITH_TXT)) + Config["Path"]["Save_ECG"] = str( + Path(Config["Path"]["Save_ECG"]) / Path( + ConfigParams.ECG_SYNC + str(Config["InputConfig"]["ECGFreq"]) + ConfigParams.ENDSWITH_TXT)) + Config["Path"]["Save_Rpeak"] = str( + Path(Config["Path"]["Save_Rpeak"]) / Path( + ConfigParams.RPEAK_SYNC + str(Config["InputConfig"]["ECGFreq"]) + ConfigParams.ENDSWITH_TXT)) + else: + return result + + if ((not Path(Config["Path"]["Input_OrgBCG"]).exists()) + or (not Path(Config["Path"]["Input_BCG"]).exists()) or (not Path(Config["Path"]["Input_Jpeak"]).exists()) or (not Path(Config["Path"]["Input_ECG"]).exists()) or (not Path(Config["Path"]["Input_Rpeak"]).exists())): - return Result().failure(info=Constants.INPUT_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Data_Path_Not_Exist"]) + return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) try: self.raw_orgBcg = read_csv(Config["Path"]["Input_OrgBCG"], @@ -1460,13 +1510,14 @@ class Data: self.argmax_BCG = np_argmax(self.raw_BCG) self.argmax_ECG = np_argmax(self.raw_ECG) except Exception as e: - return Result().failure(info=Constants.INPUT_FAILURE + Constants.PRECISELY_ALIGN_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: df = read_csv(Config["Path"]["Input_Approximately_Align"]) pos = df["pos"].values[-1] ApplyFrequency = df["ApplyFrequency"].values[-1] - self.approximately_align_pos = int(pos * (Config["InputConfig"]["ECGFreq"] / ApplyFrequency)) + self.approximately_align_pos = int(pos * (Config["InputConfig"]["UseFreq"] / ApplyFrequency)) if self.approximately_align_pos > 0: self.BCG_early = False elif self.approximately_align_pos < 0: @@ -1481,7 +1532,8 @@ class Data: def data_process_for_calculate_correlation(self): if self.Jpeak is None or self.Rpeak is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_PROCESS_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Data_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_PROCESS_FAILURE + + Constants.FAILURE_REASON["Data_Not_Exist"]) try: self.JJIs = diff(self.Jpeak) @@ -1491,18 +1543,21 @@ class Data: result = {"JJIVs": JJIVs, "RRIVs": RRIVs} except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_PROCESS_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Process_Data_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_PROCESS_FAILURE + + Constants.FAILURE_REASON["Process_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_PROCESS_FINISHED, data=result) def calculate_correlation_front(self, mode, shift_front=None): if ((Config["IV_Coordinate"]["BCG_front_1"] == Config["IV_Coordinate"]["BCG_front_2"]) or (Config["IV_Coordinate"]["ECG_front_1"] == Config["IV_Coordinate"]["ECG_front_2"])): - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Value_Equal"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + + Constants.FAILURE_REASON["Calculate_Correlation_Value_Equal"]) if ((Config["IV_Coordinate"]["BCG_front_2"] - Config["IV_Coordinate"]["BCG_front_1"]) >= (Config["IV_Coordinate"]["ECG_front_2"] - Config["IV_Coordinate"]["ECG_front_1"])): - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_JJIVRange_too_Large"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + + Constants.FAILURE_REASON["Calculate_Correlation_JJIVRange_too_Large"]) try: if mode == "init": @@ -1531,7 +1586,7 @@ class Data: offset_interval = np_sum(RRI[:shift]) - (Jpeak_cut[0] - Rpeak_cut[0]) anchor_J = self.Jpeak[Config["IV_Coordinate"]["BCG_front_1"]] anchor_R = self.Rpeak[Config["IV_Coordinate"]["ECG_front_1"] + shift] - offset_interval_duration = offset_interval / Config["InputConfig"]["ECGFreq"] + offset_interval_duration = offset_interval / Config["InputConfig"]["UseFreq"] Config["front"]["shift"] = shift Config["front"]["offset_interval"] = offset_interval @@ -1556,18 +1611,21 @@ class Data: } } except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + + Constants.FAILURE_REASON["Calculate_Correlation_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_CALCULATE_FINISHED_FRONT, data=result) def calculate_correlation_back(self, mode, shift_back=None): if ((Config["IV_Coordinate"]["BCG_back_1"] == Config["IV_Coordinate"]["BCG_back_2"]) or (Config["IV_Coordinate"]["ECG_back_1"] == Config["IV_Coordinate"]["ECG_back_2"])): - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Value_Equal"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + + Constants.FAILURE_REASON["Calculate_Correlation_Value_Equal"]) if ((Config["IV_Coordinate"]["BCG_back_2"] - Config["IV_Coordinate"]["BCG_back_1"]) >= (Config["IV_Coordinate"]["ECG_back_2"] - Config["IV_Coordinate"]["ECG_back_1"])): - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_JJIVRange_too_Large"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + + Constants.FAILURE_REASON["Calculate_Correlation_JJIVRange_too_Large"]) try: if mode == "init": @@ -1596,7 +1654,7 @@ class Data: offset_interval = np_sum(RRI[:shift]) - (Jpeak_cut[0] - Rpeak_cut[0]) anchor_J = self.Jpeak[Config["IV_Coordinate"]["BCG_back_1"]] anchor_R = self.Rpeak[Config["IV_Coordinate"]["ECG_back_1"] + shift] - offset_interval_duration = offset_interval / Config["InputConfig"]["ECGFreq"] + offset_interval_duration = offset_interval / Config["InputConfig"]["UseFreq"] Config["back"]["shift"] = shift Config["back"]["offset_interval"] = offset_interval @@ -1621,7 +1679,8 @@ class Data: } } except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + + Constants.FAILURE_REASON["Calculate_Correlation_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_CALCULATE_FINISHED_BACK, data=result) @@ -1630,7 +1689,7 @@ class Data: if mode == "init": anchor0 = [Config["front"]["anchor_R"], Config["front"]["anchor_J"]] anchor1 = [Config["back"]["anchor_R"], Config["back"]["anchor_J"]] - Config["orgfs"] = ((int(anchor1[1]) - int(anchor0[1])) * Config["InputConfig"]["ECGFreq"] / + Config["orgfs"] = ((int(anchor1[1]) - int(anchor0[1])) * Config["InputConfig"]["UseFreq"] / (int(anchor1[0]) - int(anchor0[0]))) Config["offset_anchor"] = anchor0[0] - anchor0[1] @@ -1654,11 +1713,11 @@ class Data: anchor0[1] = anchor0[1] + off anchor1[1] = anchor1[1] + off - self.res_BCG = resample(self.res_BCG, orgfs, Config["InputConfig"]["ECGFreq"]) - self.res_orgBcg = resample(self.res_orgBcg, orgfs, Config["InputConfig"]["ECGFreq"]) + self.res_BCG = resample(self.res_BCG, orgfs, Config["InputConfig"]["UseFreq"]) + self.res_orgBcg = resample(self.res_orgBcg, orgfs, Config["InputConfig"]["UseFreq"]) - anchor0[1] = round(int(anchor0[1]) * Config["InputConfig"]["ECGFreq"] / orgfs) - anchor1[1] = round(int(anchor1[1]) * Config["InputConfig"]["ECGFreq"] / orgfs) + anchor0[1] = round(int(anchor0[1]) * Config["InputConfig"]["UseFreq"] / orgfs) + anchor1[1] = round(int(anchor1[1]) * Config["InputConfig"]["UseFreq"] / orgfs) off = anchor1[0] - anchor1[1] if off > 0: @@ -1705,7 +1764,8 @@ class Data: else: raise ValueError("模式不存在") except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_ALIGN_CORRELATION_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Correlation_Align_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_ALIGN_CORRELATION_FAILURE + + Constants.FAILURE_REASON["Correlation_Align_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_ALIGN_CORRELATION_FINISHED, data=result) @@ -1750,8 +1810,8 @@ class Data: self.cut_Jpeak.append(peaks[idx]) self.cut_Jpeak = asarray(self.cut_Jpeak).astype(int) - frontcut_index_BCG = int((self.argmax_BCG - np_argmax(self.res_BCG) / Config["InputConfig"]["ECGFreq"] * Config["orgfs"])) - backcut_index_BCG = int(len(self.res_BCG) / Config["InputConfig"]["ECGFreq"] * Config["orgfs"] + np_argmax(self.raw_BCG) - np_argmax(self.res_BCG) / Config["InputConfig"]["ECGFreq"] * Config["orgfs"]) + frontcut_index_BCG = int((self.argmax_BCG - np_argmax(self.res_BCG) / Config["InputConfig"]["UseFreq"] * Config["orgfs"])) + backcut_index_BCG = int(len(self.res_BCG) / Config["InputConfig"]["UseFreq"] * Config["orgfs"] + np_argmax(self.raw_BCG) - np_argmax(self.res_BCG) / Config["InputConfig"]["UseFreq"] * Config["orgfs"]) frontcut_index_ECG = self.argmax_ECG - np_argmax(self.cut_ECG) backcut_index_ECG = len(self.cut_ECG) + self.argmax_ECG - np_argmax(self.cut_ECG) @@ -1760,7 +1820,8 @@ class Data: Config["frontcut_index_ECG"] = frontcut_index_ECG Config["backcut_index_ECG"] = backcut_index_ECG except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_POSTPROCESS_VIEW_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["PostProcess_Align_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_POSTPROCESS_VIEW_FAILURE + + Constants.FAILURE_REASON["PostProcess_Align_Exception"] + "\n" + format_exc()) info = f"{Constants.PRECISELY_ALIGN_POSTPROCESS_VIEW_FINISHED},BCG前后段被切割的坐标值为[{frontcut_index_BCG}, {backcut_index_BCG}],ECG前后段被切割的坐标值为[{frontcut_index_ECG}, {backcut_index_ECG}]" return Result().success(info=info) @@ -1800,62 +1861,73 @@ class Data: save_data = [str(save_data)] DataFrame(save_data).to_csv(Config["Path"]["Save_AlignInfo"], index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FINISHED) def save_res_orgBcg(self, chunk): if self.res_orgBcg is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["res_orgBcg_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + + Constants.FAILURE_REASON["res_orgBcg_Not_Exist"]) try: chunk.to_csv(Config["Path"]["Save_OrgBCG"], mode='a', index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FINISHED) def save_res_BCG(self, chunk): if self.res_BCG is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["res_BCG_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + + Constants.FAILURE_REASON["res_BCG_Not_Exist"]) try: chunk.to_csv(Config["Path"]["Save_BCG"], mode='a', index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FINISHED) def save_cut_ECG(self, chunk): if self.cut_ECG is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["cut_ECG_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + + Constants.FAILURE_REASON["cut_ECG_Not_Exist"]) try: chunk.to_csv(Config["Path"]["Save_ECG"], mode='a', index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FINISHED) def save_Jpeak(self, chunk): if self.cut_Jpeak is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["cut_Jpeak_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + + Constants.FAILURE_REASON["cut_Jpeak_Not_Exist"]) try: chunk.to_csv(Config["Path"]["Save_Jpeak"], mode='a', index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FINISHED) def save_Rpeak(self, chunk): if self.cut_Rpeak is None: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["cut_Rpeak_Not_Exist"]) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + + Constants.FAILURE_REASON["cut_Rpeak_Not_Exist"]) try: chunk.to_csv(Config["Path"]["Save_Rpeak"], mode='a', index=False, header=False) except Exception as e: - return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) + return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + + Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc()) return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FINISHED) diff --git a/func/utils/ConfigParams.py b/func/utils/ConfigParams.py index 2b8ffc7..76dfe25 100644 --- a/func/utils/ConfigParams.py +++ b/func/utils/ConfigParams.py @@ -33,7 +33,8 @@ class ConfigParams: ECG_RAW: str = "ECG II_Raw_" THO_RAW: str = "Effort Tho_Raw_" ABD_RAW: str = "Effort Abd_Raw_" - + FLOWT_RAW: str = "Flow T_Raw_" + FLOWP_RAW: str = "Flow P_Raw_" BCG_FILTER: str = "BCG_Filter_" ECG_FILTER: str = "ECG_Filter_" JPEAK_REVISE: str = "Jpeak_revise_" @@ -41,6 +42,17 @@ class ConfigParams: JPEAK_REVISE_CORRECTED: str = "Jpeak_revise_corrected_" RPEAK_FINAL_CORRECTED: str = "Rpeak_final_corrected_" APPROXIMATELY_ALIGN_INFO: str = "Approximately_Align_Info" + PRECISELY_ALIGN_INFO: str = "Precisely_Align_Info" + ORGBCG_SYNC: str = "OrgBCG_Sync_" + ECG_SYNC: str = "ECG_Sync_" + THO_SYNC: str = "Effort Tho_Sync_" + ABD_SYNC: str = "Effort Abd_Sync_" + FLOWT_SYNC: str = "Flow T_Sync_" + FLOWP_SYNC: str = "Flow P_Sync_" + BCG_SYNC: str = "BCG_Sync_" + ECG_SYNC: str = "ECG_Sync_" + JPEAK_SYNC: str = "Jpeak_Sync_" + RPEAK_SYNC: str = "Rpeak_Sync_" @@ -172,7 +184,10 @@ class ConfigParams: PRECISELY_ALIGN_CONFIG_FILE_PATH: str = "./config/Config_precisely_align.yaml" PRECISELY_ALIGN_CONFIG_NEW_CONTENT: dict = { "InputConfig": { - "ECGFreq": 1000 + "orgBcgFreq": 1000, + "BCGFreq": 1000, + "ECGFreq": 1000, + "UseFreq": 1000 } } PRECISELY_ALIGN_INPUT_ORGBCG_FILENAME: str = "OrgBCG_Raw_" diff --git a/func/utils/Constants.py b/func/utils/Constants.py index c730311..5574608 100644 --- a/func/utils/Constants.py +++ b/func/utils/Constants.py @@ -96,10 +96,23 @@ class Constants: "Model_File_Not_Exist": "(模型文件不存在)", "Open_Data_Exception": "(打开数据异常)", + "Process_Exception": "(处理异常)", "Preprocess_Exception": "(预处理异常)", "Save_Exception": "(保存异常)", "Predict_Exception": "(预测异常)", - "Read_Model_Exception": "(读取模型异常)" + "Read_Model_Exception": "(读取模型异常)", + "Calculate_Correlation_Value_Equal": "(计算相关性参数相同)", + "Calculate_Correlation_JJIVRange_too_Large": "(计算相关性JJIV范围大于RRIV范围)", + "Calculate_Correlation_Exception": "(计算相关性异常)", + "Correlation_Align_Exception": "(处理相关对齐异常)", + "PostProcess_Align_Exception": "(数据后处理异常)", + + + "res_orgBcg_Not_Exist": "(切割后orgBcg不存在)", + "res_BCG_Not_Exist": "(切割后BCG不存在)", + "cut_ECG_Not_Exist": "(切割后ECG不存在)", + "cut_Jpeak_Not_Exist": "(切割后J峰不存在)", + "cut_Rpeak_Not_Exist": "(切割后R峰不存在)" } # 预处理 @@ -181,6 +194,63 @@ class Constants: LABEL_CHECK_NO_POINT_IN_THE_INTERVAL: str = "所选区间内无新增或删除点" LABEL_CHECK_ACTION_LABEL_MULTIPLE_NAME: str = f"批量更改标签({ConfigParams.LABEL_CHECK_ACTION_LABEL_MULTIPLE_SHORTCUT_KEY})" + # 数据精同步 + PRECISELY_ALIGN_PROCESSING_DATA: str = "正在处理数据" + PRECISELY_ALIGN_PROCESS_FINISHED: str = "处理完成" + PRECISELY_ALIGN_PROCESS_FAILURE: str = "处理失败" + + PRECISELY_ALIGN_CALCULATING_CORRELATION_FRONT: str = "正在计算前段相关性" + PRECISELY_ALIGN_CALCULATE_FINISHED_FRONT: str = "计算前段相关性完成" + PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT: str = "计算前段相关性失败" + PRECISELY_ALIGN_CALCULATING_CORRELATION_BACK: str = "正在计算后段相关性" + PRECISELY_ALIGN_CALCULATE_FINISHED_BACK: str = "计算后段相关性完成" + PRECISELY_ALIGN_CALCULATE_FAILURE_BACK: str = "计算后段相关性失败" + + PRECISELY_ALIGN_ALIGNING_CORRELATION: str = "正在处理相关对齐" + PRECISELY_ALIGN_ALIGN_CORRELATION_FINISHED: str = "处理相关对齐完成" + PRECISELY_ALIGN_ALIGN_CORRELATION_FAILURE: str = "处理相关对齐失败" + + PRECISELY_ALIGN_POSTPROCESSING_VIEW: str = "正在数据后处理" + PRECISELY_ALIGN_POSTPROCESS_VIEW_FINISHED: str = "数据后处理完成" + PRECISELY_ALIGN_POSTPROCESS_VIEW_FAILURE: str = "数据后处理失败" + + PRECISELY_ALIGN_SAVING_ALIGNINFO: str = "正在保存对齐信息" + PRECISELY_ALIGN_SAVING_ALIGNINFO_FINISHED: str = "保存对齐信息完成" + PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE: str = "保存对齐信息失败" + + PRECISELY_ALIGN_SAVING_RES_ORGBCG: str = "正在保存切割后orgBcg" + PRECISELY_ALIGN_SAVING_RES_ORGBCG_FINISHED: str = "保存切割后orgBcg完成" + PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE: str = "保存切割后orgBcg失败" + + PRECISELY_ALIGN_SAVING_RES_BCG: str = "正在保存切割后BCG" + PRECISELY_ALIGN_SAVING_RES_BCG_FINISHED: str = "保存切割后BCG完成" + PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE: str = "保存切割后BCG失败" + + PRECISELY_ALIGN_SAVING_CUT_ECG: str = "正在保存切割后ECG" + PRECISELY_ALIGN_SAVING_CUT_ECG_FINISHED: str = "保存切割后ECG完成" + PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE: str = "保存切割后ECG失败" + + PRECISELY_ALIGN_SAVING_CUT_JPEAK: str = "正在保存切割后J峰" + PRECISELY_ALIGN_SAVING_CUT_JPEAK_FINISHED: str = "保存切割后J峰完成" + PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE: str = "保存切割后J峰失败" + + PRECISELY_ALIGN_SAVING_CUT_RPEAK: str = "正在保存切割后R峰" + PRECISELY_ALIGN_SAVING_CUT_RPEAK_FINISHED: str = "保存切割后R峰完成" + PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE: str = "保存切割后R峰失败" + + PRECISELY_ALIGN_PLOT_LABEL_JJIV: str = "JJIV" + PRECISELY_ALIGN_PLOT_LABEL_RRIV: str = "RRIV" + PRECISELY_ALIGN_PLOT_LABEL_CORRE_RRIV_JJIV: str = "corre(RRIV, JJIV)" + PRECISELY_ALIGN_PLOT_LABEL_ECG: str = "ECG" + PRECISELY_ALIGN_PLOT_LABEL_BCG: str = "BCG" + PRECISELY_ALIGN_PLOT_LABEL_RPEAK: str = "peak_ECG" + PRECISELY_ALIGN_PLOT_LABEL_JPEAK: str = "peak_BCG" + PRECISELY_ALIGN_PLOT_LABEL_SELECTED_POINT: str = "Selected Point" + PRECISELY_ALIGN_NO_POINT_IN_THE_INTERVAL: str = "所选区间内无有效点" + PRECISELY_ALIGN_RECOVER_SCALE: str = "尺度恢复" + PRECISELY_ALIGN_ACTION_GET_RANGE_NAME: str = f"设置范围({ConfigParams.PRECISELY_ALIGN_ACTION_GET_RANGE_SHORTCUT_KEY})" + + # 数据粗同步 @@ -245,80 +315,6 @@ class Constants: "Save_Exception": "(保存异常)" } - # 数据精同步 - PRECISELY_ALIGN_PROCESSING_DATA: str = "正在处理数据" - PRECISELY_ALIGN_PROCESS_FINISHED: str = "处理完成" - PRECISELY_ALIGN_PROCESS_FAILURE: str = "处理失败" - - PRECISELY_ALIGN_CALCULATING_CORRELATION_FRONT: str = "正在计算前段相关性" - PRECISELY_ALIGN_CALCULATE_FINISHED_FRONT: str = "计算前段相关性完成" - PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT: str = "计算前段相关性失败" - PRECISELY_ALIGN_CALCULATING_CORRELATION_BACK: str = "正在计算后段相关性" - PRECISELY_ALIGN_CALCULATE_FINISHED_BACK: str = "计算后段相关性完成" - PRECISELY_ALIGN_CALCULATE_FAILURE_BACK: str = "计算后段相关性失败" - - PRECISELY_ALIGN_ALIGNING_CORRELATION: str = "正在处理相关对齐" - PRECISELY_ALIGN_ALIGN_CORRELATION_FINISHED: str = "处理相关对齐完成" - PRECISELY_ALIGN_ALIGN_CORRELATION_FAILURE: str = "处理相关对齐失败" - - PRECISELY_ALIGN_POSTPROCESSING_VIEW: str = "正在数据后处理" - PRECISELY_ALIGN_POSTPROCESS_VIEW_FINISHED: str = "数据后处理完成" - PRECISELY_ALIGN_POSTPROCESS_VIEW_FAILURE: str = "数据后处理失败" - - PRECISELY_ALIGN_SAVING_ALIGNINFO: str = "正在保存对齐信息" - PRECISELY_ALIGN_SAVING_ALIGNINFO_FINISHED: str = "保存对齐信息完成" - PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE: str = "保存对齐信息失败" - - PRECISELY_ALIGN_SAVING_RES_ORGBCG: str = "正在保存切割后orgBcg" - PRECISELY_ALIGN_SAVING_RES_ORGBCG_FINISHED: str = "保存切割后orgBcg完成" - PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE: str = "保存切割后orgBcg失败" - - PRECISELY_ALIGN_SAVING_RES_BCG: str = "正在保存切割后BCG" - PRECISELY_ALIGN_SAVING_RES_BCG_FINISHED: str = "保存切割后BCG完成" - PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE: str = "保存切割后BCG失败" - - PRECISELY_ALIGN_SAVING_CUT_ECG: str = "正在保存切割后ECG" - PRECISELY_ALIGN_SAVING_CUT_ECG_FINISHED: str = "保存切割后ECG完成" - PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE: str = "保存切割后ECG失败" - - PRECISELY_ALIGN_SAVING_CUT_JPEAK: str = "正在保存切割后J峰" - PRECISELY_ALIGN_SAVING_CUT_JPEAK_FINISHED: str = "保存切割后J峰完成" - PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE: str = "保存切割后J峰失败" - - PRECISELY_ALIGN_SAVING_CUT_RPEAK: str = "正在保存切割后R峰" - PRECISELY_ALIGN_SAVING_CUT_RPEAK_FINISHED: str = "保存切割后R峰完成" - PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE: str = "保存切割后R峰失败" - - PRECISELY_ALIGN_FAILURE_REASON = { - "Data_Path_Not_Exist": "(数据路径不存在)", - "Read_Data_Exception": "(读取数据异常)", - "Data_Not_Exist": "(数据不存在)", - "Process_Data_Exception": "(处理数据异常)", - "Calculate_Correlation_Value_Equal": "(计算相关性参数相同)", - "Calculate_Correlation_JJIVRange_too_Large": "(计算相关性JJIV范围大于RRIV范围)", - "Calculate_Correlation_Exception": "(计算相关性异常)", - "Correlation_Align_Exception": "(处理相关对齐异常)", - "PostProcess_Align_Exception": "(数据后处理异常)", - "res_orgBcg_Not_Exist": "(切割后orgBcg不存在)", - "res_BCG_Not_Exist": "(切割后BCG不存在)", - "cut_ECG_Not_Exist": "(切割后ECG不存在)", - "cut_Jpeak_Not_Exist": "(切割后J峰不存在)", - "cut_Rpeak_Not_Exist": "(切割后R峰不存在)", - "Save_Exception": "(保存异常)" - } - - PRECISELY_ALIGN_PLOT_LABEL_JJIV: str = "JJIV" - PRECISELY_ALIGN_PLOT_LABEL_RRIV: str = "RRIV" - PRECISELY_ALIGN_PLOT_LABEL_CORRE_RRIV_JJIV: str = "corre(RRIV, JJIV)" - PRECISELY_ALIGN_PLOT_LABEL_ECG: str = "ECG" - PRECISELY_ALIGN_PLOT_LABEL_BCG: str = "BCG" - PRECISELY_ALIGN_PLOT_LABEL_RPEAK: str = "peak_ECG" - PRECISELY_ALIGN_PLOT_LABEL_JPEAK: str = "peak_BCG" - PRECISELY_ALIGN_PLOT_LABEL_SELECTED_POINT: str = "Selected Point" - PRECISELY_ALIGN_NO_POINT_IN_THE_INTERVAL: str = "所选区间内无有效点" - PRECISELY_ALIGN_RECOVER_SCALE: str = "尺度恢复" - PRECISELY_ALIGN_ACTION_GET_RANGE_NAME: str = f"设置范围({ConfigParams.PRECISELY_ALIGN_ACTION_GET_RANGE_SHORTCUT_KEY})" - # 冗余数据切割和标签映射 CUT_PSG_GETTING_FILE_AND_FREQ: str = "正在获取文件及其采样率" CUT_PSG_GET_FILE_AND_FREQ_FINISHED: str = "获取文件及其采样率完成" diff --git a/ui/setting/precisely_align_input_setting.py b/ui/setting/precisely_align_input_setting.py index b9d4f8b..4a454e5 100644 --- a/ui/setting/precisely_align_input_setting.py +++ b/ui/setting/precisely_align_input_setting.py @@ -82,12 +82,31 @@ class Ui_MainWindow_precisely_align_input_setting(object): self.groupBox_file_path_input_orgBcg.setObjectName(u"groupBox_file_path_input_orgBcg") self.verticalLayout_8 = QVBoxLayout(self.groupBox_file_path_input_orgBcg) self.verticalLayout_8.setObjectName(u"verticalLayout_8") + self.horizontalLayout_5 = QHBoxLayout() + self.horizontalLayout_5.setObjectName(u"horizontalLayout_5") + self.label_5 = QLabel(self.groupBox_file_path_input_orgBcg) + self.label_5.setObjectName(u"label_5") + self.label_5.setFont(font) + + self.horizontalLayout_5.addWidget(self.label_5) + + self.spinBox_input_freq_orgBcg = QSpinBox(self.groupBox_file_path_input_orgBcg) + self.spinBox_input_freq_orgBcg.setObjectName(u"spinBox_input_freq_orgBcg") + self.spinBox_input_freq_orgBcg.setFont(font) + self.spinBox_input_freq_orgBcg.setMinimum(1) + self.spinBox_input_freq_orgBcg.setMaximum(1000000) + + self.horizontalLayout_5.addWidget(self.spinBox_input_freq_orgBcg) + + + self.verticalLayout_8.addLayout(self.horizontalLayout_5) + self.plainTextEdit_file_path_input_orgBcg = QPlainTextEdit(self.groupBox_file_path_input_orgBcg) self.plainTextEdit_file_path_input_orgBcg.setObjectName(u"plainTextEdit_file_path_input_orgBcg") self.verticalLayout_8.addWidget(self.plainTextEdit_file_path_input_orgBcg) - self.verticalLayout_8.setStretch(0, 3) + self.verticalLayout_8.setStretch(1, 3) self.gridLayout_2.addWidget(self.groupBox_file_path_input_orgBcg, 0, 0, 1, 2) @@ -112,12 +131,31 @@ class Ui_MainWindow_precisely_align_input_setting(object): self.groupBox_file_path_input_BCG.setObjectName(u"groupBox_file_path_input_BCG") self.verticalLayout_5 = QVBoxLayout(self.groupBox_file_path_input_BCG) self.verticalLayout_5.setObjectName(u"verticalLayout_5") + self.horizontalLayout_4 = QHBoxLayout() + self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") + self.label_4 = QLabel(self.groupBox_file_path_input_BCG) + self.label_4.setObjectName(u"label_4") + self.label_4.setFont(font) + + self.horizontalLayout_4.addWidget(self.label_4) + + self.spinBox_input_freq_BCG = QSpinBox(self.groupBox_file_path_input_BCG) + self.spinBox_input_freq_BCG.setObjectName(u"spinBox_input_freq_BCG") + self.spinBox_input_freq_BCG.setFont(font) + self.spinBox_input_freq_BCG.setMinimum(1) + self.spinBox_input_freq_BCG.setMaximum(1000000) + + self.horizontalLayout_4.addWidget(self.spinBox_input_freq_BCG) + + + self.verticalLayout_5.addLayout(self.horizontalLayout_4) + self.plainTextEdit_file_path_input_BCG = QPlainTextEdit(self.groupBox_file_path_input_BCG) self.plainTextEdit_file_path_input_BCG.setObjectName(u"plainTextEdit_file_path_input_BCG") self.verticalLayout_5.addWidget(self.plainTextEdit_file_path_input_BCG) - self.verticalLayout_5.setStretch(0, 3) + self.verticalLayout_5.setStretch(1, 3) self.gridLayout_2.addWidget(self.groupBox_file_path_input_BCG, 1, 0, 1, 1) @@ -228,12 +266,14 @@ class Ui_MainWindow_precisely_align_input_setting(object): self.groupBox_file_path_save.setTitle(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u5bf9\u9f50\u4fe1\u606f\u4fdd\u5b58\u8def\u5f84", None)) self.plainTextEdit_file_path_save_AlignInfo.setPlaceholderText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u4fdd\u5b58\u8def\u5f84", None)) self.groupBox_file_path_input_orgBcg.setTitle(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u539f\u59cborgBcg\u8def\u5f84", None)) + self.label_5.setText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u91c7\u6837\u7387(Hz)\uff1a", None)) self.plainTextEdit_file_path_input_orgBcg.setPlainText("") self.plainTextEdit_file_path_input_orgBcg.setPlaceholderText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u6587\u4ef6\u8def\u5f84", None)) self.groupBox_file_path_save_3.setTitle(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u5bf9\u9f50J\u5cf0\u548cR\u5cf0\u4fdd\u5b58\u8def\u5f84", None)) self.plainTextEdit_file_path_save_Jpeak.setPlaceholderText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u4fdd\u5b58\u8def\u5f84", None)) self.plainTextEdit_file_path_save_Rpeak.setPlaceholderText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u4fdd\u5b58\u8def\u5f84", None)) self.groupBox_file_path_input_BCG.setTitle(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u9884\u5904\u7406\u540e\u7684BCG\u8def\u5f84", None)) + self.label_4.setText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u91c7\u6837\u7387(Hz)\uff1a", None)) self.plainTextEdit_file_path_input_BCG.setPlainText("") self.plainTextEdit_file_path_input_BCG.setPlaceholderText(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u6587\u4ef6\u8def\u5f84", None)) self.groupBox_file_path_input_Jpeak.setTitle(QCoreApplication.translate("MainWindow_precisely_align_input_setting", u"\u4eba\u5de5\u7ea0\u6b63\u540e\u7684J\u5cf0\u8def\u5f84", None)) diff --git a/ui/setting/precisely_align_input_setting.ui b/ui/setting/precisely_align_input_setting.ui index 1580093..e2b7935 100644 --- a/ui/setting/precisely_align_input_setting.ui +++ b/ui/setting/precisely_align_input_setting.ui @@ -89,7 +89,38 @@ 原始orgBcg路径 - + + + + + + + + 12 + + + + 采样率(Hz): + + + + + + + + 12 + + + + 1 + + + 1000000 + + + + + @@ -131,7 +162,38 @@ 预处理后的BCG路径 - + + + + + + + + 12 + + + + 采样率(Hz): + + + + + + + + 12 + + + + 1 + + + 1000000 + + + + +