优化异常处理,新增traceback打印以便于调试,调整低通滤波器参数

This commit is contained in:
2025-12-27 14:02:55 +08:00
parent df0df6ad4f
commit 986188cf9d

View File

@ -348,6 +348,7 @@ class Data:
PublicFunc.examine_artifact(self.Artifact)
self.Artifact = self.Artifact.reshape(-1, 4)
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.INPUT_FAILURE +
Constants.FAILURE_REASON[
"Get_Artifact_Format_Exception"] + "\n" + format_exc())
@ -449,6 +450,7 @@ class Data:
self.event_index_revised[start:end] = one_data["Index"]
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON[
"Label_Format_Exception"] + "\n" + format_exc())
@ -470,7 +472,7 @@ class Data:
'lowpass', low_cut=20, order=3)
self.lowPassResp = Butterworth_for_ECG_PreProcess(self.OrgBCG,
orgbcg_freq,
'lowpass', low_cut=0.7, order=3)
'lowpass', low_cut=0.5, order=3)
self.artifact_label = zeros(len(self.event_label_origin))
@ -486,6 +488,7 @@ class Data:
self.artifact_label[start:end] = artifact_type
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.PREPROCESS_FAILURE +
Constants.FAILURE_REASON["Preprocess_Exception"] + "\n" + format_exc())
@ -539,6 +542,7 @@ class Data:
del self.Stage
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
@ -551,10 +555,13 @@ class Data:
try:
self.df_revised.to_csv(self.config["Path"]["SA_Label_Revised"], mode='w', index=None, encoding="gbk")
except PermissionError as e:
traceback.print_exc()
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
traceback.print_exc()
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.SAVE_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -619,6 +626,7 @@ class DataFrameModel(QAbstractTableModel):
return QColor(0, 0, 0)
except Exception as e:
traceback.print_exc()
return None
return None
@ -959,6 +967,7 @@ class MainWindow_SA_label(QMainWindow):
self.set_tableview_column_width_by_ratio(self.ui.tableView_label_revised, [1, 3, 1, 2, 2])
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.UPDATE_FAILURE +
Constants.FAILURE_REASON["Update_tableWidget_Exception"] + "\n" + format_exc())
@ -1383,6 +1392,7 @@ class MainWindow_SA_label(QMainWindow):
self.data.df_revised = self.data.df_revised[~mask].reset_index(drop=True)
self.data.df_revised.to_csv(self.config["Path"]["SA_Label_Revised"], index=False, encoding="gbk")
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.SAVE_FAILURE +
Constants.FAILURE_REASON["Save_revised_csv_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.SAVE_FINISHED)
@ -2022,6 +2032,7 @@ class MainWindow_SA_label(QMainWindow):
self.ax0.set_xlim(self.check_start_end(self.config["WindowStartSecond"], 0))
self.canvas.draw()
except Exception as e:
traceback.print_exc()
return Result().failure(info=Constants.DRAW_FAILURE + "\n" + format_exc())
return Result().success(info=Constants.DRAW_FINISHED)