diff --git a/func/Module_detect_Jpeak.py b/func/Module_detect_Jpeak.py index 11f36ff..9ccca43 100644 --- a/func/Module_detect_Jpeak.py +++ b/func/Module_detect_Jpeak.py @@ -424,6 +424,10 @@ class Data: Constants.FAILURE_REASON["Data_Not_Exist"]) try: + if ((Config["Filter"]["BandPassLow"] >= Config["Filter"]["BandPassHigh"]) or + (Config["Filter"]["BandPassLow"] <= 0) or (Config["Filter"]["BandPassHigh"] <= 0)): + return Result().failure( + info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) self.processed_data = preprocess(self.raw_data, Config["InputConfig"]["Freq"], Config["Filter"]["BandPassLow"], @@ -445,6 +449,9 @@ class Data: Constants.FAILURE_REASON["Data_Not_Exist"]) try: + if Config["IntervalLow"] >= Config["IntervalHigh"]: + return Result().failure( + info=Constants.DETECT_JPEAK_PREDICT_FAILURE + Constants.FAILURE_REASON["Interval_Args_Not_Correct"]) self.peak, self.interval = Jpeak_Detection(model.selected_model, Path(model.model_folder_path) / Path(model.selected_model), self.processed_data, diff --git a/func/Module_detect_Rpeak.py b/func/Module_detect_Rpeak.py index f884eb4..879d68e 100644 --- a/func/Module_detect_Rpeak.py +++ b/func/Module_detect_Rpeak.py @@ -425,6 +425,10 @@ class Data: Constants.FAILURE_REASON["Data_Not_Exist"]) try: + if ((Config["Filter"]["BandPassLow"] >= Config["Filter"]["BandPassHigh"]) or + (Config["Filter"]["BandPassLow"] <= 0) or (Config["Filter"]["BandPassHigh"] <= 0)): + return Result().failure( + info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) self.processed_data = preprocess(self.raw_data, Config["InputConfig"]["Freq"], Config["Filter"]["BandPassLow"], diff --git a/func/Module_label_check.py b/func/Module_label_check.py index e28b0b1..80bf7a1 100644 --- a/func/Module_label_check.py +++ b/func/Module_label_check.py @@ -986,17 +986,31 @@ class Data: try: if Config["Mode"] == "BCG": - self.processed_data = data_preprocess_for_label_check(self.raw_data, - Config["Filter"]["BCGBandPassOrder"], - Config["Filter"]["BCGBandPassLow"], - Config["Filter"]["BCGBandPassHigh"], - Config["InputConfig"]["Freq"]) + if Config["Filter"]["BCGBandPassOrder"] == 0: + self.processed_data = self.raw_data + else: + if ((Config["Filter"]["BCGBandPassLow"] >= Config["Filter"]["BCGBandPassHigh"]) or + (Config["Filter"]["BCGBandPassLow"] <= 0) or (Config["Filter"]["BCGBandPassHigh"] <= 0)): + return Result().failure( + info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) + self.processed_data = data_preprocess_for_label_check(self.raw_data, + Config["Filter"]["BCGBandPassOrder"], + Config["Filter"]["BCGBandPassLow"], + Config["Filter"]["BCGBandPassHigh"], + Config["InputConfig"]["Freq"]) elif Config["Mode"] == "ECG": - self.processed_data = data_preprocess_for_label_check(self.raw_data, - Config["Filter"]["ECGBandPassOrder"], - Config["Filter"]["ECGBandPassLow"], - Config["Filter"]["ECGBandPassHigh"], - Config["InputConfig"]["Freq"]) + if Config["Filter"]["ECGBandPassOrder"] == 0: + self.processed_data = self.raw_data + else: + if ((Config["Filter"]["ECGBandPassLow"] >= Config["Filter"]["ECGBandPassHigh"]) or + (Config["Filter"]["ECGBandPassLow"] <= 0) or (Config["Filter"]["ECGBandPassHigh"] <= 0)): + return Result().failure( + info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) + self.processed_data = data_preprocess_for_label_check(self.raw_data, + Config["Filter"]["ECGBandPassOrder"], + Config["Filter"]["ECGBandPassLow"], + Config["Filter"]["ECGBandPassHigh"], + Config["InputConfig"]["Freq"]) else: raise ValueError("模式不存在") self.original_peak_y = [self.processed_data[x] for x in self.original_peak] diff --git a/func/Module_preprocess.py b/func/Module_preprocess.py index ed869a4..c52ca9d 100644 --- a/func/Module_preprocess.py +++ b/func/Module_preprocess.py @@ -456,7 +456,8 @@ class Data: if Config["Filter"]["BCGBandPassOrder"] == 0: self.processed_data = self.raw_data else: - if Config["Filter"]["BCGBandPassLow"] >= Config["Filter"]["BCGBandPassHigh"]: + if ((Config["Filter"]["BCGBandPassLow"] >= Config["Filter"]["BCGBandPassHigh"]) or + (Config["Filter"]["BCGBandPassLow"] <= 0) or (Config["Filter"]["BCGBandPassHigh"] <= 0)): return Result().failure( info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) self.processed_data = Butterworth_for_BCG_PreProcess(self.raw_data, type='bandpass', @@ -468,7 +469,8 @@ class Data: if Config["Filter"]["ECGBandPassOrder"] == 0: self.processed_data = self.raw_data else: - if Config["Filter"]["ECGBandPassLow"] >= Config["Filter"]["ECGBandPassHigh"]: + if ((Config["Filter"]["ECGBandPassLow"] >= Config["Filter"]["ECGBandPassHigh"]) or + (Config["Filter"]["ECGBandPassLow"] <= 0) or (Config["Filter"]["ECGBandPassHigh"] <= 0)): return Result().failure( info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"]) self.processed_data = Butterworth_for_ECG_PreProcess(self.raw_data, type='bandpass', diff --git a/func/Module_resp_quality_label.py b/func/Module_resp_quality_label.py index 2c7f594..b37a74c 100644 --- a/func/Module_resp_quality_label.py +++ b/func/Module_resp_quality_label.py @@ -811,6 +811,7 @@ class MainWindow_resp_quality_label(QMainWindow): if self.ui.radioButton_orgBcg_fillterMode_custom.isChecked(): if self.check_filter_args() is False: PublicFunc.msgbox_output(self, Constants.RESP_QUALITY_LABEL_CUSTOM_FILTER_ARGS_ERROR, Constants.MSGBOX_TYPE_ERROR) + PublicFunc.finish_operation(self, ButtonState) return result = self.__plot__() if not result.status: @@ -1035,7 +1036,8 @@ class MainWindow_resp_quality_label(QMainWindow): self.ax1_spectrum.set_title(Constants.RESP_QUALITY_LABEL_SPECTRUM_THO_TITLE, fontsize=8) def check_filter_args(self): - if (float(Config["Filter"]["BandPassLow"]) >= float(Config["Filter"]["BandPassHigh"])): + if ((float(Config["Filter"]["BandPassLow"]) >= float(Config["Filter"]["BandPassHigh"])) or + (float(Config["Filter"]["BandPassLow"]) <= 0) or (float(Config["Filter"]["BandPassHigh"]) <= 0)): return False return True diff --git a/func/utils/Constants.py b/func/utils/Constants.py index b1c6d08..512e286 100644 --- a/func/utils/Constants.py +++ b/func/utils/Constants.py @@ -106,7 +106,8 @@ class Constants: "Data_Length_not_Correct": "(orgBcg和BCG长度不匹配)", "Artifact_Format_Not_Correct": "(体动长度或格式不正确)", "Data_Length_Not_Correct": "(信号长度不正确)", - "Filter_Args_Not_Correct": "(滤波器参数输入不正确)", + "Filter_Args_Not_Correct": "(滤波器参数输入不正确,上下截止频率都要大于0,且上截止频率应大于下截止频率)", + "Interval_Args_Not_Correct": "(间期参数输入不正确,上间期阈值应大于下间期阈值)", "Open_Data_Exception": "(打开数据异常)", "Process_Exception": "(处理异常)", @@ -448,8 +449,8 @@ class Constants: RESP_QUALITY_LABEL_ADD_POINTS_SUCCESSFULLY: str = "成功新增点,横坐标:" RESP_QUALITY_LABEL_REMOVE_POINTS_SUCCESSFULLY: str = "成功删除点,横坐标:" RESP_QUALITY_LABEL_NO_POINT_IN_THE_INTERVAL: str = "所选区间内无新增或删除点" - RESP_QUALITY_LABEL_CUSTOM_FILTER_ARGS_ERROR: str = "OrgBCG带通滤波频率设置范围应为数字,范围是0~1" - RESP_QUALITY_LABEL_AUTOLABEL_ARGS_ERROR: str = "人工标注阈值设置范围应为数字,范围是0~1" + RESP_QUALITY_LABEL_CUSTOM_FILTER_ARGS_ERROR: str = "OrgBCG带通滤波频率设置范围应为数字,范围是0~1,且上截止频率应大于下截止频率" + RESP_QUALITY_LABEL_AUTOLABEL_ARGS_ERROR: str = "人工标注阈值设置范围应为数字,范围是0~1,且[1]应大于[0]" RESP_QUALITY_LABEL_CHECK_ARGS_QUESTION_CONTENT: str = "你确定要执行此操作吗,请确保参数输入正确" RESP_QUALITY_LABEL_ACTION_LABEL_MULTIPLE_NAME: str = f"批量更改标签({Params.RESP_QUALITY_LABEL_ACTION_LABEL_MULTIPLE_SHORTCUT_KEY})" RESP_QUALITY_LABEL_A_QUALITY: int = 1