1、优化了异常处理
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from gc import collect
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication
|
||||
@ -334,8 +335,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
result = self.DrawPicByEpoch(*args, **kwargs)
|
||||
elif sender == self.ui.pushButton_EP100:
|
||||
result = self.DrawPicByEpoch(*args, **kwargs)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
|
||||
if result is None:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
@ -670,8 +671,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
ax3.set_title("ABD")
|
||||
|
||||
self.fig.canvas.draw()
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
# 返回图片以便存到QPixImage
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
|
||||
@ -720,8 +721,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
ax3.set_title("ABD")
|
||||
|
||||
self.fig.canvas.draw()
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
# 返回图片以便存到QPixImage
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
|
||||
@ -744,8 +745,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
ax4.set_title("The Correlation of ABD and Reverse orgBcg")
|
||||
|
||||
self.fig.canvas.draw()
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
# 返回图片以便存到QPixImage
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
|
||||
@ -778,8 +779,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
ax3.set_title("ABD")
|
||||
|
||||
self.fig.canvas.draw()
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
# 返回图片以便存到QPixImage
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
|
||||
@ -838,8 +839,8 @@ class MainWindow_approximately_align(QMainWindow):
|
||||
ax6.set_ylim((10, 50))
|
||||
|
||||
self.fig.canvas.draw()
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
# 返回图片以便存到QPixImage
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
|
||||
@ -870,8 +871,8 @@ class Data:
|
||||
self.raw_Abd = read_csv(Config["Path"]["Input_Abd"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
@ -882,8 +883,8 @@ class Data:
|
||||
# 保存到csv中
|
||||
df = DataFrame({"pos": [pos], "epoch": [epoch], "ApplyFrequency": [ApplyFrequency]})
|
||||
df.to_csv(Path(Config["Path"]["Save"]), mode="w", header=True, index=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.SAVING_FINISHED)
|
||||
|
||||
@ -895,8 +896,8 @@ class Data:
|
||||
self.processed_orgBcg = resample(self.raw_orgBcg, int(Config["orgBcg_minutes"] * 60 * Config["ApplyFrequency"]))
|
||||
self.processed_Tho = resample(self.raw_Tho, int(Config["PSG_minutes"] * 60 * Config["ApplyFrequency"]))
|
||||
self.processed_Abd = resample(self.raw_Abd, int(Config["PSG_minutes"] * 60 * Config["ApplyFrequency"]))
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Only_Resample_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Only_Resample_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FINISHED)
|
||||
|
||||
@ -923,8 +924,8 @@ class Data:
|
||||
Config["Filter"]["BandPassHigh"],
|
||||
Config["InputConfig"]["AbdFreq"],
|
||||
Config["Filter"]["BandPassOrder"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_RESP_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Resp_Get_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_RESP_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Resp_Get_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_RESP_GET_FINISHED)
|
||||
|
||||
@ -951,8 +952,8 @@ class Data:
|
||||
# 用repeat完成
|
||||
self.processed_orgBcg = repeat(self.processed_orgBcg, int(Config["TempFrequency"] / Config["InputConfig"]["orgBcgFreq"]), axis=0)
|
||||
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Pre_Resample_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Pre_Resample_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FINISHED)
|
||||
|
||||
@ -972,8 +973,8 @@ class Data:
|
||||
self.processed_orgBcg = self.processed_orgBcg - convolve(self.processed_orgBcg,
|
||||
ones(int(4 * temp_frequency)) / int(4 * temp_frequency),
|
||||
mode='same')
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_DELETE_BASE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Delete_Base_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_DELETE_BASE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Delete_Base_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_DELETE_BASE_FINISHED)
|
||||
|
||||
@ -986,8 +987,8 @@ class Data:
|
||||
self.processed_Abd = (self.processed_Abd - mean(self.processed_Abd)) / std(self.processed_Abd)
|
||||
if Config["orgBcgConfig"]["orgBcgZScore"]:
|
||||
self.processed_orgBcg = (self.processed_orgBcg - mean(self.processed_orgBcg)) / std(self.processed_orgBcg)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_STANDARDIZE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Standardize_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_STANDARDIZE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Standardize_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_STANDARDIZE_FINISHED)
|
||||
|
||||
@ -999,8 +1000,8 @@ class Data:
|
||||
self.processed_Tho = self.processed_Tho[::int(temp_frequency / Config["ApplyFrequency"])]
|
||||
self.processed_Abd = self.processed_Abd[::int(temp_frequency / Config["ApplyFrequency"])]
|
||||
self.processed_orgBcg = self.processed_orgBcg[::int(temp_frequency / Config["ApplyFrequency"])]
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Resample_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FINISHED)
|
||||
|
||||
@ -1024,8 +1025,8 @@ class Data:
|
||||
tho_relate2 = - tho_relate
|
||||
|
||||
result = {"tho_relate": tho_relate, "tho_relate2": tho_relate2}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Correlation1_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Correlation1_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FINISHED, data=result)
|
||||
|
||||
@ -1050,8 +1051,8 @@ class Data:
|
||||
abd_relate2 = - abd_relate
|
||||
|
||||
result = {"abd_relate": abd_relate, "abd_relate2": abd_relate2}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Correlation2_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Correlation2_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FINISHED, data=result)
|
||||
|
||||
@ -1067,8 +1068,8 @@ class Data:
|
||||
bias = pre - len(self.processed_orgBcg) + 1
|
||||
|
||||
result = {"tho_max": tho_max, "tho_max2": tho_max2, "abd_max": abd_max, "abd_max2": abd_max2, "bias": bias}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Maxvalue_Pos_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Calculate_Maxvalue_Pos_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FINISHED, data=result)
|
||||
|
||||
@ -1080,8 +1081,8 @@ class Data:
|
||||
(len(self.processed_orgBcg) + Config["pos"]) // 30 // Config["ApplyFrequency"] - 1)
|
||||
|
||||
result = {"epoch_min": epoch_min, "epoch_max": epoch_max}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Get_Epoch_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON["Get_Epoch_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ from ast import literal_eval
|
||||
from gc import collect
|
||||
from math import floor
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication
|
||||
from numpy import array
|
||||
@ -215,8 +216,8 @@ class Data:
|
||||
return Result().failure(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE + Constants.CUT_PSG_FAILURE_REASON["File_not_Exist"])
|
||||
if not Path(Config["Path"]["InputAlignInfo"]).exists():
|
||||
return Result().failure(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE + Constants.CUT_PSG_FAILURE_REASON["File_not_Exist"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE + Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE["Get_File_and_Freq_Excepetion"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE + Constants.CUT_PSG_GET_FILE_AND_FREQ_FAILURE["Get_File_and_Freq_Excepetion"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FINISHED)
|
||||
|
||||
@ -235,8 +236,8 @@ class Data:
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.alignInfo = literal_eval(self.alignInfo[0])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
@ -255,8 +256,8 @@ class Data:
|
||||
self.raw[key] = self.raw[key][start_index_cut:end_index_cut]
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.CUT_PSG_CUT_DATA_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Cut_Data_Length_not_Correct"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.CUT_PSG_CUT_DATA_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Cut_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.CUT_PSG_CUT_DATA_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Cut_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.CUT_PSG_CUT_DATA_FINISHED)
|
||||
|
||||
@ -288,8 +289,8 @@ class Data:
|
||||
self.SALabel.loc[self.SALabel["Start"] < 0, "Start"] = 0
|
||||
self.SALabel = self.SALabel[self.SALabel["Start"] < ECG_length]
|
||||
self.SALabel.loc[self.SALabel["End"] >= ECG_length, "End"] = ECG_length - 1
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.CUT_PSG_ALIGN_LABEL_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Align_Label_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.CUT_PSG_ALIGN_LABEL_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Align_Label_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.CUT_PSG_ALIGN_LABEL_FINISHED)
|
||||
|
||||
@ -305,8 +306,8 @@ class Data:
|
||||
self.SALabel.to_csv(Path(Config["Path"]["SaveFolder"]) / Path((Config["LabelSave"]["SA Label"] + Config["EndWith"]["SA Label"])),
|
||||
index=False,
|
||||
encoding="gbk")
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.CUT_PSG_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.SAVING_FINISHED)
|
||||
|
||||
|
||||
@ -396,8 +396,8 @@ class Data:
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
@ -411,8 +411,8 @@ class Data:
|
||||
Config["Filter"]["BandPassLow"],
|
||||
Config["Filter"]["BandPassHigh"],
|
||||
Config["AmpValue"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_PROCESS_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Filter_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_PROCESS_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Filter_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.DETECT_JPEAK_PROCESS_FINISHED)
|
||||
|
||||
@ -432,8 +432,8 @@ class Data:
|
||||
Config["IntervalLow"],
|
||||
Config["PeaksValue"],
|
||||
Config["UseCPU"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_PREDICT_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Predict_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_PREDICT_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Predict_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.DETECT_JPEAK_PREDICT_FINISHED)
|
||||
|
||||
@ -443,8 +443,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.SAVING_FINISHED)
|
||||
|
||||
@ -465,7 +465,7 @@ class Model:
|
||||
self.model_list = [file.name for file in Path(Config["ModelFolderPath"]).iterdir() if file.is_file()]
|
||||
if len(self.model_list) == 0:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_FAILURE_REASON["Model_File_Not_Exist"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_LOAD_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Read_Model_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DETECT_JPEAK_LOAD_FAILURE + Constants.DETECT_JPEAK_FAILURE_REASON["Read_Model_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.DETECT_JPEAK_LOAD_FINISHED)
|
||||
@ -1,5 +1,6 @@
|
||||
from gc import collect
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication
|
||||
@ -396,8 +397,8 @@ class Data:
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
@ -410,8 +411,8 @@ class Data:
|
||||
Config["InputConfig"]["Freq"],
|
||||
Config["Filter"]["BandPassLow"],
|
||||
Config["Filter"]["BandPassHigh"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DETECT_RPEAK_PROCESS_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Filter_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DETECT_RPEAK_PROCESS_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Filter_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.DETECT_RPEAK_PROCESS_FINISHED)
|
||||
|
||||
@ -424,8 +425,8 @@ class Data:
|
||||
Config["InputConfig"]["Freq"],
|
||||
Config["PeaksValue"],
|
||||
Config["DetectMethod"])
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DETECT_RPEAK_PREDICT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Predict_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DETECT_RPEAK_PREDICT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Predict_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.DETECT_RPEAK_PREDICT_FINISHED)
|
||||
|
||||
@ -436,7 +437,7 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.SAVING_FINISHED)
|
||||
@ -1,5 +1,6 @@
|
||||
from gc import collect
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from PySide6.QtCore import QTimer, QCoreApplication
|
||||
@ -387,8 +388,8 @@ class MainWindow_label_check(QMainWindow):
|
||||
self.ax1.callbacks.connect('xlim_changed', lambda ax: self.on_xlim_change(ax))
|
||||
self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT)
|
||||
self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.DRAWING_FAILURE + "\n" + format_exc())
|
||||
|
||||
self.canvas.draw()
|
||||
return Result().success(info=Constants.DRAWING_FINISHED)
|
||||
@ -415,8 +416,8 @@ class MainWindow_label_check(QMainWindow):
|
||||
item = QTableWidgetItem(str(value).strip())
|
||||
self.ui.tableWidget_peak_corrected.setItem(row, 0, item)
|
||||
return Result().success(info=Constants.UPDATING_FINISHED)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.UPDATING_FAILURE)
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.UPDATING_FAILURE + "\n" + format_exc())
|
||||
|
||||
def __update_config__(self):
|
||||
Config["FindPeaks"]["MinInterval"] = self.ui.doubleSpinBox_findpeaks_min_interval.value()
|
||||
@ -898,8 +899,8 @@ class Data:
|
||||
self.original_peak = read_csv(Config["Path"]["Input_Peak"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
try:
|
||||
df = read_csv(Config["Path"]["Input_Approximately_Align"])
|
||||
@ -952,8 +953,8 @@ class Data:
|
||||
raise ValueError("模式不存在")
|
||||
self.original_peak_y = [self.processed_data[x] for x in self.original_peak]
|
||||
self.corrected_peak_y = [self.processed_data[x] for x in self.corrected_peak]
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.LABEL_CHECK_PROCESS_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Filter_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.LABEL_CHECK_PROCESS_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Filter_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.LABEL_CHECK_PROCESS_FINISHED)
|
||||
|
||||
@ -963,8 +964,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.LABEL_CHECK_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.SAVING_FINISHED)
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from gc import collect
|
||||
from pathlib import Path
|
||||
from traceback import format_exc
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from PySide6.QtCore import QCoreApplication
|
||||
@ -1463,8 +1464,8 @@ class Data:
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.argmax_BCG = np_argmax(self.raw_BCG)
|
||||
self.argmax_ECG = np_argmax(self.raw_ECG)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
try:
|
||||
df = read_csv(Config["Path"]["Input_Approximately_Align"])
|
||||
@ -1494,8 +1495,8 @@ class Data:
|
||||
RRIVs = diff(self.RRIs)
|
||||
|
||||
result = {"JJIVs": JJIVs, "RRIVs": RRIVs}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_PROCESS_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Process_Data_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_PROCESS_FINISHED, data=result)
|
||||
|
||||
@ -1559,8 +1560,8 @@ class Data:
|
||||
"offset_interval_duration": offset_interval_duration
|
||||
}
|
||||
}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_FRONT + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_CALCULATE_FINISHED_FRONT, data=result)
|
||||
|
||||
@ -1624,8 +1625,8 @@ class Data:
|
||||
"offset_interval_duration": offset_interval_duration
|
||||
}
|
||||
}
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_CALCULATE_FAILURE_BACK + Constants.PRECISELY_ALIGN_FAILURE_REASON["Calculate_Correlation_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_CALCULATE_FINISHED_BACK, data=result)
|
||||
|
||||
@ -1708,8 +1709,8 @@ class Data:
|
||||
}
|
||||
else:
|
||||
raise ValueError("模式不存在")
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_ALIGN_CORRELATION_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Correlation_Align_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_ALIGN_CORRELATION_FINISHED, data=result)
|
||||
|
||||
@ -1763,8 +1764,8 @@ class Data:
|
||||
Config["backcut_index_BCG"] = backcut_index_BCG
|
||||
Config["frontcut_index_ECG"] = frontcut_index_ECG
|
||||
Config["backcut_index_ECG"] = backcut_index_ECG
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_POSTPROCESS_VIEW_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["PostProcess_Align_Exception"])
|
||||
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())
|
||||
|
||||
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)
|
||||
@ -1804,8 +1805,8 @@ class Data:
|
||||
save_data = [str(save_data)]
|
||||
DataFrame(save_data).to_csv(Config["Path"]["Save_BCG_AlignInfo"], index=False, header=False)
|
||||
DataFrame(save_data).to_csv(Config["Path"]["Save_ECG_AlignInfo"], index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FINISHED)
|
||||
|
||||
@ -1815,8 +1816,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save_orgBcg"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FINISHED)
|
||||
|
||||
@ -1826,8 +1827,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save_BCG"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FINISHED)
|
||||
|
||||
@ -1837,8 +1838,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save_ECG"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FINISHED)
|
||||
|
||||
@ -1848,8 +1849,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save_Jpeak"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FINISHED)
|
||||
|
||||
@ -1859,8 +1860,8 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save_Rpeak"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + Constants.PRECISELY_ALIGN_FAILURE_REASON["Save_Exception"])
|
||||
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().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FINISHED)
|
||||
|
||||
|
||||
@ -400,8 +400,8 @@ class Data:
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Read_Data_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Read_Data_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.INPUT_FINISHED)
|
||||
|
||||
@ -428,8 +428,8 @@ class Data:
|
||||
sample_rate=Config["OutputConfig"]["Freq"])
|
||||
else:
|
||||
raise ValueError("模式不存在")
|
||||
except Exception:
|
||||
Result().failure(info=Constants.PREPROCESS_PROCESS_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Filter_Exception"])
|
||||
except Exception as e:
|
||||
Result().failure(info=Constants.PREPROCESS_PROCESS_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Filter_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(info=Constants.PREPROCESS_PROCESS_FINISHED)
|
||||
|
||||
@ -440,7 +440,7 @@ class Data:
|
||||
|
||||
try:
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False, float_format='%.4f')
|
||||
except Exception:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Save_Exception"])
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
|
||||
|
||||
return Result().success(Constants.SAVING_FINISHED)
|
||||
Reference in New Issue
Block a user