1、完成了<数据精对齐>的所有代码

This commit is contained in:
2025-05-08 15:51:32 +08:00
parent b4c4e124f8
commit 6a250a64a0
12 changed files with 2662 additions and 480 deletions

View File

@ -142,11 +142,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
self.ax0 = None
self.ax1 = None
self.line_data = None
self.point_peak = None
self.line_interval = None
self.point_RRIV = None
self.msgBox = QMessageBox()
self.msgBox.setWindowTitle(Constants.MAINWINDOW_MSGBOX_TITLE)
@ -202,11 +197,8 @@ class MainWindow_detect_Rpeak(QMainWindow):
QApplication.processEvents()
# 清空画框
if self.line_data and self.point_peak:
del self.line_data
del self.point_peak
del self.line_interval
self.canvas.draw()
self.ax0.clear()
self.ax1.clear()
# 释放资源
del self.data
@ -226,28 +218,21 @@ class MainWindow_detect_Rpeak(QMainWindow):
def __plot__(self):
# 清空画框
if self.line_data and self.point_peak and self.line_interval and self.point_RRIV:
try:
self.line_data.remove()
self.point_peak.remove()
self.line_interval.remove()
self.point_RRIV.remove()
except ValueError:
pass
self.reset_axes()
sender = self.sender()
if sender == self.ui.pushButton_view:
self.point_RRIV, = self.ax0.plot(self.data.peak[2:], self.data.RRIV,
self.ax0.plot(self.data.peak[2:], self.data.RRIV,
'r.',
label=Constants.DETECT_RPEAK_PLOT_LABEL_RRIV)
self.line_data, = self.ax1.plot(self.data.processed_data,
self.ax1.plot(self.data.processed_data,
color=Constants.PLOT_COLOR_BLUE,
label=Constants.DETECT_RPEAK_PLOT_LABEL_ECG)
self.point_peak, = self.ax1.plot(self.data.peak, self.data.processed_data[self.data.peak],
self.ax1.plot(self.data.peak, self.data.processed_data[self.data.peak],
'r*',
label=Constants.DETECT_RPEAK_PLOT_LABEL_R_PEAKS)
self.line_interval, = self.ax1.plot(self.data.interval,
self.ax1.plot(self.data.interval,
color=Constants.PLOT_COLOR_GREEN,
label=Constants.DETECT_RPEAK_PLOT_LABEL_INTERVAL)
self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT)
@ -273,14 +258,7 @@ class MainWindow_detect_Rpeak(QMainWindow):
PublicFunc.__disableAllButton__(self, ButtonState)
# 清空画框
if self.line_data and self.point_peak and self.line_interval and self.point_RRIV:
try:
self.line_data.remove()
self.point_peak.remove()
self.line_interval.remove()
self.point_RRIV.remove()
except ValueError:
pass
self.reset_axes()
self.canvas.draw()
# 清空方法列表
@ -402,6 +380,16 @@ class MainWindow_detect_Rpeak(QMainWindow):
PublicFunc.finish_operation(self, ButtonState)
def reset_axes(self):
self.ax0.clear()
self.ax1.clear()
self.ax0.grid(True)
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
self.ax0.tick_params(axis='x', colors=Constants.PLOT_COLOR_WHITE)
self.ax1.grid(True)
self.ax1.xaxis.set_major_formatter(ConfigParams.FORMATTER)
def update_ui_comboBox_method(self, method_list):
self.ui.comboBox_method.clear()
@ -472,8 +460,7 @@ class Data:
try:
# DataFrame(self.processed_data.reshape(-1)).to_csv(self.file_path_save,
# index=False,
# header=False,
# float_format='%.4f')
# header=False)
chunk.to_csv(self.file_path_save, mode='a', index=False, header=False)
except Exception:
return False, Constants.SAVING_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Save_Exception"]