为<BCG的J峰算法定位>、<ECG的R峰算法定位>、<人工纠正>增加了不做滤波的选项

This commit is contained in:
Yorusora
2025-06-28 20:35:10 +08:00
parent aa0d59f925
commit c9202174fb
11 changed files with 292 additions and 133 deletions

View File

@ -207,6 +207,8 @@ class MainWindow_detect_Jpeak(QMainWindow):
self.ui.spinBox_intervalHigh.editingFinished.connect(self.__update_config__)
self.ui.checkBox_useCPU.stateChanged.connect(self.__update_config__)
self.ui.comboBox_model.currentTextChanged.connect(self.__update_config__)
self.ui.radioButton_skip_process.toggled.connect(self.__update_config__)
self.ui.radioButton_bandpass_process.toggled.connect(self.__update_config__)
@overrides
def closeEvent(self, event):
@ -262,6 +264,7 @@ class MainWindow_detect_Jpeak(QMainWindow):
return Result().failure(info=Constants.DRAW_FAILURE)
def __update_config__(self):
sender = self.sender()
Config["Filter"]["BandPassLow"] = self.ui.doubleSpinBox_bandPassLow.value()
Config["Filter"]["BandPassHigh"] = self.ui.doubleSpinBox_bandPassHigh.value()
Config["PeaksValue"] = self.ui.spinBox_peaksValue.value()
@ -270,6 +273,10 @@ class MainWindow_detect_Jpeak(QMainWindow):
Config["IntervalHigh"] = self.ui.spinBox_intervalHigh.value()
Config["UseCPU"] = self.ui.checkBox_useCPU.isChecked()
Config["DetectMethod"] = self.ui.comboBox_model.currentText()
if sender == self.ui.radioButton_skip_process:
Config["Filter"]["Mode"] = "skip"
elif sender == self.ui.radioButton_bandpass_process:
Config["Filter"]["Mode"] = "bandpass"
def __slot_btn_input__(self):
PublicFunc.__disableAllButton__(self, ButtonState)
@ -444,21 +451,24 @@ 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"],
Config["Filter"]["BandPassHigh"],
Config["AmpValue"])
if Config["Filter"]["Mode"] == "skip":
self.processed_data = self.raw_data[:len(self.raw_data) // (Config["InputConfig"]["Freq"] * 10) * Config["InputConfig"]["Freq"] * 10]
return Result().success(info=Constants.PREPROCESS_NO_NEED)
elif Config["Filter"]["Mode"] == "bandpass":
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"],
Config["Filter"]["BandPassHigh"],
Config["AmpValue"])
return Result().success(info=Constants.PREPROCESS_FINISHED)
except Exception as e:
return Result().failure(info=Constants.PREPROCESS_FAILURE +
Constants.FAILURE_REASON["Preprocess_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.PREPROCESS_FINISHED)
def predict_Jpeak(self, model):
if not (Path(model.model_folder_path) / Path(model.selected_model)).exists():
return Result().failure(info=Constants.DETECT_JPEAK_PREDICT_FAILURE +

View File

@ -201,6 +201,8 @@ class MainWindow_detect_Rpeak(QMainWindow):
self.ui.doubleSpinBox_bandPassHigh.editingFinished.connect(self.__update_config__)
self.ui.spinBox_peaksValue.editingFinished.connect(self.__update_config__)
self.ui.comboBox_method.currentTextChanged.connect(self.__update_config__)
self.ui.radioButton_skip_process.toggled.connect(self.__update_config__)
self.ui.radioButton_bandpass_process.toggled.connect(self.__update_config__)
@overrides
def closeEvent(self, event):
@ -260,10 +262,15 @@ class MainWindow_detect_Rpeak(QMainWindow):
return Result().failure(info=Constants.DRAW_FAILURE)
def __update_config__(self):
sender = self.sender()
Config["Filter"]["BandPassLow"] = self.ui.doubleSpinBox_bandPassLow.value()
Config["Filter"]["BandPassHigh"] = self.ui.doubleSpinBox_bandPassHigh.value()
Config["PeaksValue"] = self.ui.spinBox_peaksValue.value()
Config["DetectMethod"] = self.ui.comboBox_method.currentText()
if sender == self.ui.radioButton_skip_process:
Config["Filter"]["Mode"] = "skip"
elif sender == self.ui.radioButton_bandpass_process:
Config["Filter"]["Mode"] = "bandpass"
def __slot_btn_input__(self):
PublicFunc.__disableAllButton__(self, ButtonState)
@ -446,20 +453,23 @@ 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"],
Config["Filter"]["BandPassHigh"])
if Config["Filter"]["Mode"] == "skip":
self.processed_data = self.raw_data
return Result().success(info=Constants.PREPROCESS_NO_NEED)
elif Config["Filter"]["Mode"] == "bandpass":
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"],
Config["Filter"]["BandPassHigh"])
return Result().success(info=Constants.PREPROCESS_FINISHED)
except Exception as e:
return Result().failure(info=Constants.PREPROCESS_FAILURE +
Constants.FAILURE_REASON["Preprocess_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.PREPROCESS_FINISHED)
def predict_Rpeak(self):
if self.processed_data is None:
return Result().failure(info=Constants.DETECT_RPEAK_PREDICT_FAILURE +

View File

@ -122,6 +122,10 @@ class SettingWindow(QMainWindow):
self.ui.plainTextEdit_file_path_input_peak.setPlainText(Config["Path"]["Input_Peak"])
self.ui.plainTextEdit_file_path_input_approximately_align.setPlainText(Config["Path"]["Input_Approximately_Align"])
self.ui.plainTextEdit_file_path_save.setPlainText(Config["Path"]["Save"])
if Config["Filter"]["Mode"] == "skip":
self.ui.radioButton_skip_process.setChecked(True)
elif Config["Filter"]["Mode"] == "bandpass":
self.ui.radioButton_bandpass_process.setChecked(True)
if Config["Mode"] == "BCG":
self.ui.spinBox_bandPassOrder.setValue(Config["Filter"]["BCGBandPassOrder"])
self.ui.doubleSpinBox_bandPassLow.setValue(Config["Filter"]["BCGBandPassLow"])
@ -140,6 +144,10 @@ class SettingWindow(QMainWindow):
Config["Path"]["Input_Peak"] = self.ui.plainTextEdit_file_path_input_peak.toPlainText()
Config["Path"]["Input_Approximately_Align"] = self.ui.plainTextEdit_file_path_input_approximately_align.toPlainText()
Config["Path"]["Save"] = self.ui.plainTextEdit_file_path_save.toPlainText()
if self.ui.radioButton_skip_process.isChecked():
Config["Filter"]["Mode"] = "skip"
elif self.ui.radioButton_bandpass_process.isChecked():
Config["Filter"]["Mode"] = "bandpass"
if Config["Mode"] == "BCG":
Config["Filter"]["BCGBandPassOrder"] = self.ui.spinBox_bandPassOrder.value()
Config["Filter"]["BCGBandPassLow"] = self.ui.doubleSpinBox_bandPassLow.value()
@ -1054,7 +1062,7 @@ class Data:
try:
if Config["Mode"] == "BCG":
if Config["Filter"]["BCGBandPassOrder"] == 0:
if Config["Filter"]["BCGBandPassOrder"] == 0 or Config["Filter"]["Mode"] == "skip":
self.processed_data = self.raw_data
else:
if ((Config["Filter"]["BCGBandPassLow"] >= Config["Filter"]["BCGBandPassHigh"]) or
@ -1067,7 +1075,7 @@ class Data:
Config["Filter"]["BCGBandPassHigh"],
Config["InputConfig"]["Freq"])
elif Config["Mode"] == "ECG":
if Config["Filter"]["ECGBandPassOrder"] == 0:
if Config["Filter"]["ECGBandPassOrder"] == 0 or Config["Filter"]["Mode"] == "skip":
self.processed_data = self.raw_data
else:
if ((Config["Filter"]["ECGBandPassLow"] >= Config["Filter"]["ECGBandPassHigh"]) or

View File

@ -139,6 +139,7 @@ class Params:
"Freq": 1000
},
"Filter": {
"Mode": "skip",
"BandPassLow": 2,
"BandPassHigh": 10
},
@ -159,6 +160,7 @@ class Params:
"Freq": 1000
},
"Filter": {
"Mode": "skip",
"BandPassLow": 1,
"BandPassHigh": 25
},
@ -174,6 +176,7 @@ class Params:
"Freq": 1000
},
"Filter": {
"Mode": "skip",
"BCGBandPassOrder": 2,
"BCGBandPassLow": 2,
"BCGBandPassHigh": 10,

View File

@ -24,6 +24,7 @@ class Constants:
PREPROCESSING_DATA: str = "正在预处理数据"
PREPROCESS_FINISHED: str = "预处理完成"
PREPROCESS_FAILURE: str = "预处理失败"
PREPROCESS_NO_NEED: str = "不需要预处理"
RESAMPLING_DATA: str = "正在数据重采样"
RESAMPLE_FINISHED: str = "重采样完成"