1、优化了<数据粗同步>的绘图

This commit is contained in:
2025-05-11 10:26:42 +08:00
parent b9f9122a65
commit f01e23f4bb
6 changed files with 272 additions and 281 deletions

View File

@ -2,8 +2,8 @@ from gc import collect
from pathlib import Path
import matplotlib.pyplot as plt
from PySide6.QtGui import QImage, QPixmap
from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication
from matplotlib.backends.backend_qt import NavigationToolbar2QT
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from numba import prange, njit
@ -223,6 +223,13 @@ class MainWindow_approximately_align(QMainWindow):
self.setting = SettingWindow(root_path, sampID)
self.fig = Figure(figsize=(12, 9), dpi=100)
self.fig.subplots_adjust(left=0.05, right=0.98, top=0.95, bottom=0.05)
self.canvas = FigureCanvas(self.fig)
self.figToolbar = NavigationToolbar2QT(self.canvas)
self.ui.verticalLayout_canvas.addWidget(self.canvas)
self.ui.verticalLayout_canvas.addWidget(self.figToolbar)
PublicFunc.__resetAllButton__(self, ButtonState)
self.ui.groupBox_align_position.setEnabled(False)
@ -257,7 +264,8 @@ class MainWindow_approximately_align(QMainWindow):
# 释放资源
del self.data
plt.close()
self.fig.clf()
plt.close(self.fig)
self.deleteLater()
collect()
self.canvas = None
@ -268,7 +276,8 @@ class MainWindow_approximately_align(QMainWindow):
def __reset__(self):
ButtonState["Current"].update(ButtonState["Default"].copy())
ButtonState["Current"]["pushButton_Standardize"] = True
self.ui.label_Pic.clear()
self.fig.clf()
self.fig.canvas.draw()
self.ui.spinBox_PSGPreA.setValue(0)
self.ui.spinBox_PSGPreCut.setValue(0)
self.ui.spinBox_PSGPostCut.setValue(0)
@ -292,48 +301,46 @@ class MainWindow_approximately_align(QMainWindow):
def __plot__(self, *args, **kwargs):
sender = self.sender()
result, buffer, width, height = None, None, None, None
self.fig.clf()
result = None
try:
if sender == self.ui.pushButton_Standardize:
result, buffer, width, height = self.data.DrawPicRawOverview()
result = self.DrawPicRawOverview()
elif sender == self.ui.pushButton_CutOff:
result, buffer, width, height = self.data.DrawPicOverviewWithCutOff()
result = self.DrawPicOverviewWithCutOff()
elif sender == self.ui.pushButton_GetPos:
result, buffer, width, height = self.data.DrawPicCorrelate(*args, **kwargs)
result = self.DrawPicCorrelate(*args, **kwargs)
elif sender == self.ui.radioButton_NTHO:
result, buffer, width, height = self.data.DrawPicTryAlign()
result = self.DrawPicTryAlign()
elif sender == self.ui.radioButton_NABD:
result, buffer, width, height = self.data.DrawPicTryAlign()
result = self.DrawPicTryAlign()
elif sender == self.ui.radioButton_PTHO:
result, buffer, width, height = self.data.DrawPicTryAlign()
result = self.DrawPicTryAlign()
elif sender == self.ui.radioButton_PABD:
result, buffer, width, height = self.data.DrawPicTryAlign()
result = self.DrawPicTryAlign()
elif sender == self.ui.radioButton_custom:
result, buffer, width, height = self.data.DrawPicTryAlign()
result = self.DrawPicTryAlign()
elif sender == self.ui.pushButton_JUMP:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EM1:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EM10:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EM100:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EP1:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EP10:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
elif sender == self.ui.pushButton_EP100:
result, buffer, width, height = self.data.DrawPicByEpoch(*args, **kwargs)
result = self.DrawPicByEpoch(*args, **kwargs)
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
if result is not None and buffer is not None and width is not None and height is not None:
# 显示到labelPic上
img = QImage(buffer, width, height, QImage.Format_RGBA8888)
self.ui.label_Pic.setPixmap(QPixmap(img))
return result
else:
if result is None:
return Result().failure(info=Constants.DRAWING_FAILURE)
else:
return result
def __slot_btn_input__(self):
PublicFunc.__disableAllButton__(self, ButtonState)
@ -644,6 +651,198 @@ class MainWindow_approximately_align(QMainWindow):
ButtonState["Current"]["pushButton_save"] = True
PublicFunc.finish_operation(self, ButtonState)
def DrawPicRawOverview(self):
try:
max_x = max(self.data.processed_Tho.shape[0], self.data.processed_Abd.shape[0], self.data.processed_orgBcg.shape[0])
ax1 = self.fig.add_subplot(311)
ax1.plot(self.data.processed_Tho, color='blue')
ax1.set_xlim(0, max_x)
ax1.set_title("THO")
ax2 = self.fig.add_subplot(312, sharex=ax1, sharey=ax1)
ax2.plot(self.data.processed_orgBcg, color='blue')
ax2.set_xlim(0, max_x)
ax2.set_title("orgBcg")
ax3 = self.fig.add_subplot(313, sharex=ax1, sharey=ax1)
ax3.plot(self.data.processed_Abd, color='blue')
ax3.set_xlim(0, max_x)
ax3.set_title("ABD")
self.fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED)
def DrawPicOverviewWithCutOff(self):
try:
max_x = max(self.data.processed_Tho.shape[0] + Config["PSGConfig"]["PreA"],
self.data.processed_orgBcg.shape[0] + Config["orgBcgConfig"]["PreA"])
min_x = min(Config["PSGConfig"]["PreA"], Config["orgBcgConfig"]["PreA"], 0)
ax1 = self.fig.add_subplot(311)
ax1.plot(
linspace(Config["PSGConfig"]["PreA"],
len(self.data.processed_Tho) + Config["PSGConfig"]["PreA"],
len(self.data.processed_Tho)), self.data.processed_Tho, color='blue')
# 绘制x = PreCut的线 和 x = PostCut的虚线
ax1.axvline(x=Config["PSGConfig"]["PreCut"] + Config["PSGConfig"]["PreA"], color='red',
linestyle='--')
ax1.axvline(
x=len(self.data.processed_Tho) - Config["PSGConfig"]["PostCut"] + Config["PSGConfig"]["PreA"],
color='red', linestyle='--')
ax1.set_xlim(min_x, max_x)
ax1.set_title("THO")
ax2 = self.fig.add_subplot(312, sharex=ax1, sharey=ax1)
ax2.plot(
linspace(Config["orgBcgConfig"]["PreA"], len(self.data.processed_orgBcg) + Config["orgBcgConfig"]["PreA"],
len(self.data.processed_orgBcg)), self.data.processed_orgBcg, color='blue')
ax2.axvline(x=Config["orgBcgConfig"]["PreCut"] + Config["orgBcgConfig"]["PreA"], color='red',
linestyle='--')
ax2.axvline(x=len(self.data.processed_orgBcg) - Config["orgBcgConfig"]["PostCut"] + Config["orgBcgConfig"]["PreA"],
color='red', linestyle='--')
ax2.set_xlim(min_x, max_x)
ax2.set_title("orgBcg")
ax3 = self.fig.add_subplot(313, sharex=ax1, sharey=ax1)
ax3.plot(
linspace(Config["PSGConfig"]["PreA"],
len(self.data.processed_Abd) + Config["PSGConfig"]["PreA"],
len(self.data.processed_Abd)), self.data.processed_Abd, color='blue')
ax3.axvline(x=Config["PSGConfig"]["PreCut"] + Config["PSGConfig"]["PreA"], color='red',
linestyle='--')
ax3.axvline(
x=len(self.data.processed_Tho) - Config["PSGConfig"]["PostCut"] + Config["PSGConfig"]["PreA"],
color='red', linestyle='--')
ax3.set_xlim(min_x, max_x)
ax3.set_title("ABD")
self.fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED)
def DrawPicCorrelate(self, tho_pxx, tho_nxx, abd_pxx, abd_nxx):
try:
ax1 = self.fig.add_subplot(221)
ax1.plot(tho_pxx, color='blue')
ax1.set_title("The Correlation of THO and orgBcg")
ax2 = self.fig.add_subplot(222, sharex=ax1, sharey=ax1)
ax2.plot(tho_nxx, color='blue')
ax2.set_title("The Correlation of THO and Reverse orgBcg")
ax3 = self.fig.add_subplot(223, sharex=ax1, sharey=ax1)
ax3.plot(abd_pxx, color='blue')
ax3.set_title("The Correlation of ABD and orgBcg")
ax4 = self.fig.add_subplot(224, sharex=ax1, sharey=ax1)
ax4.plot(abd_nxx, color='blue')
ax4.set_title("The Correlation of ABD and Reverse orgBcg")
self.fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED)
def DrawPicTryAlign(self):
try:
max_x = max(self.data.processed_Tho.shape[0],
self.data.processed_orgBcg.shape[0] + Config["pos"])
min_x = min(Config["PSGConfig"]["PreA"], Config["orgBcgConfig"]["PreA"] + Config["pos"], 0)
ax1 = self.fig.add_subplot(311)
ax1.plot(
linspace(0, len(self.data.processed_Tho),
len(self.data.processed_Tho)), self.data.processed_Tho, color='blue')
# 绘制x = PreCut的线 和 x = PostCut的虚线
ax1.set_xlim(min_x, max_x)
ax1.set_title("THO")
ax2 = self.fig.add_subplot(312, sharex=ax1, sharey=ax1)
ax2.plot(linspace(Config["pos"],
len(self.data.processed_orgBcg) + Config["pos"],
len(self.data.processed_orgBcg)), self.data.processed_orgBcg, color='blue')
ax2.set_xlim(min_x, max_x)
ax2.set_title("orgBcg")
ax3 = self.fig.add_subplot(313, sharex=ax1, sharey=ax1)
ax3.plot(
linspace(0, len(self.data.processed_Abd),
len(self.data.processed_Abd)), self.data.processed_Abd, color='blue')
ax3.set_xlim(min_x, max_x)
ax3.set_title("ABD")
self.fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED)
def DrawPicByEpoch(self, epoch):
try:
PSG_SP = epoch * 30 * Config["ApplyFrequency"]
PSG_EP = (epoch + 6) * 30 * Config["ApplyFrequency"]
orgBcg_SP = PSG_SP - Config["pos"]
orgBcg_EP = PSG_EP - Config["pos"]
tho_seg = self.data.processed_Tho[PSG_SP:PSG_EP]
orgBcg_seg = self.data.processed_orgBcg[orgBcg_SP:orgBcg_EP] * Config["orgBcg_reverse"]
abd_seg = self.data.processed_Abd[PSG_SP:PSG_EP]
# 根据PSG来和绘制
ax1 = self.fig.add_subplot(321)
ax1.plot(linspace(PSG_SP, PSG_EP, len(tho_seg)), tho_seg)
tho_peaks, _ = find_peaks(tho_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax1.plot(linspace(PSG_SP, PSG_EP, len(tho_seg))[tho_peaks], tho_seg[tho_peaks], "x")
ax3 = self.fig.add_subplot(323)
ax3.plot(linspace(orgBcg_SP, orgBcg_EP, len(orgBcg_seg)), orgBcg_seg)
orgBcg_peaks, _ = find_peaks(orgBcg_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax3.plot(linspace(orgBcg_SP, orgBcg_EP, len(orgBcg_seg))[orgBcg_peaks], orgBcg_seg[orgBcg_peaks], "x")
ax2 = self.fig.add_subplot(325)
ax2.plot(linspace(PSG_SP, PSG_EP, len(abd_seg)), abd_seg)
abd_peaks, _ = find_peaks(abd_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax2.plot(linspace(PSG_SP, PSG_EP, len(abd_seg))[abd_peaks], abd_seg[abd_peaks], "x")
# 绘制间期
ax4 = self.fig.add_subplot(322)
ax4.plot(linspace(PSG_SP, PSG_EP, len(diff(tho_peaks).repeat(Config["ApplyFrequency"]))),
diff(tho_peaks).repeat(Config["ApplyFrequency"]), alpha=0.5, label="tho")
ax4.plot(linspace(PSG_SP, PSG_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax4.set_title("tho_interval")
ax4.legend()
ax4.set_ylim((10, 50))
ax5 = self.fig.add_subplot(324)
ax5.plot(linspace(orgBcg_SP, orgBcg_EP, len(diff(tho_peaks).repeat(Config["ApplyFrequency"]))),
diff(tho_peaks).repeat(Config["ApplyFrequency"]))
ax5.plot(linspace(orgBcg_SP, orgBcg_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax5.set_title("resp_interval")
ax5.set_ylim((10, 50))
ax6 = self.fig.add_subplot(326)
ax6.plot(linspace(PSG_SP, PSG_EP, len(diff(abd_peaks).repeat(Config["ApplyFrequency"]))),
diff(abd_peaks).repeat(Config["ApplyFrequency"]))
ax6.plot(linspace(PSG_SP, PSG_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax6.set_title("abd_interval")
ax6.set_ylim((10, 50))
self.fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED)
class Data:
@ -876,213 +1075,6 @@ class Data:
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
def DrawPicRawOverview(self):
try:
fig = Figure(figsize=(12, 10), dpi=100)
canvas = FigureCanvas(fig)
max_x = max(self.processed_Tho.shape[0], self.processed_Abd.shape[0], self.processed_orgBcg.shape[0])
ax1 = fig.add_subplot(311)
ax1.plot(self.processed_Tho, color='blue')
ax1.set_xlim(0, max_x)
ax1.set_title("THO")
ax2 = fig.add_subplot(312)
ax2.plot(self.processed_orgBcg, color='blue')
ax2.set_xlim(0, max_x)
ax2.set_title("orgBcg")
ax3 = fig.add_subplot(313)
ax3.plot(self.processed_Abd, color='blue')
ax3.set_xlim(0, max_x)
ax3.set_title("ABD")
width, height = fig.figbbox.width, fig.figbbox.height
fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED), canvas.buffer_rgba(), width, height
def DrawPicOverviewWithCutOff(self):
try:
fig = Figure(figsize=(12, 10), dpi=100)
canvas = FigureCanvas(fig)
max_x = max(self.processed_Tho.shape[0] + Config["PSGConfig"]["PreA"],
self.processed_orgBcg.shape[0] + Config["orgBcgConfig"]["PreA"])
min_x = min(Config["PSGConfig"]["PreA"], Config["orgBcgConfig"]["PreA"], 0)
ax1 = fig.add_subplot(311)
ax1.plot(
linspace(Config["PSGConfig"]["PreA"],
len(self.processed_Tho) + Config["PSGConfig"]["PreA"],
len(self.processed_Tho)), self.processed_Tho, color='blue')
# 绘制x = PreCut的线 和 x = PostCut的虚线
ax1.axvline(x=Config["PSGConfig"]["PreCut"] + Config["PSGConfig"]["PreA"], color='red',
linestyle='--')
ax1.axvline(
x=len(self.processed_Tho) - Config["PSGConfig"]["PostCut"] + Config["PSGConfig"]["PreA"],
color='red', linestyle='--')
ax1.set_xlim(min_x, max_x)
ax1.set_title("THO")
ax2 = fig.add_subplot(312)
ax2.plot(
linspace(Config["orgBcgConfig"]["PreA"], len(self.processed_orgBcg) + Config["orgBcgConfig"]["PreA"],
len(self.processed_orgBcg)), self.processed_orgBcg, color='blue')
ax2.axvline(x=Config["orgBcgConfig"]["PreCut"] + Config["orgBcgConfig"]["PreA"], color='red',
linestyle='--')
ax2.axvline(x=len(self.processed_orgBcg) - Config["orgBcgConfig"]["PostCut"] + Config["orgBcgConfig"]["PreA"],
color='red', linestyle='--')
ax2.set_xlim(min_x, max_x)
ax2.set_title("orgBcg")
ax3 = fig.add_subplot(313)
ax3.plot(
linspace(Config["PSGConfig"]["PreA"],
len(self.processed_Abd) + Config["PSGConfig"]["PreA"],
len(self.processed_Abd)), self.processed_Abd, color='blue')
ax3.axvline(x=Config["PSGConfig"]["PreCut"] + Config["PSGConfig"]["PreA"], color='red',
linestyle='--')
ax3.axvline(
x=len(self.processed_Tho) - Config["PSGConfig"]["PostCut"] + Config["PSGConfig"]["PreA"],
color='red', linestyle='--')
ax3.set_xlim(min_x, max_x)
ax3.set_title("ABD")
width, height = fig.figbbox.width, fig.figbbox.height
fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED), canvas.buffer_rgba(), width, height
def DrawPicCorrelate(self, tho_pxx, tho_nxx, abd_pxx, abd_nxx):
try:
fig = Figure(figsize=(12, 10), dpi=100)
canvas = FigureCanvas(fig)
ax1 = fig.add_subplot(221)
ax1.plot(tho_pxx, color='blue')
ax1.set_title("The Correlation of THO and orgBcg")
ax2 = fig.add_subplot(222)
ax2.plot(tho_nxx, color='blue')
ax2.set_title("The Correlation of THO and Reverse orgBcg")
ax3 = fig.add_subplot(223)
ax3.plot(abd_pxx, color='blue')
ax3.set_title("The Correlation of ABD and orgBcg")
ax4 = fig.add_subplot(224)
ax4.plot(abd_nxx, color='blue')
ax4.set_title("The Correlation of ABD and Reverse orgBcg")
width, height = fig.figbbox.width, fig.figbbox.height
fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED), canvas.buffer_rgba(), width, height
def DrawPicTryAlign(self):
try:
fig = Figure(figsize=(12, 10), dpi=100)
canvas = FigureCanvas(fig)
max_x = max(self.processed_Tho.shape[0],
self.processed_orgBcg.shape[0] + Config["pos"])
min_x = min(Config["PSGConfig"]["PreA"], Config["orgBcgConfig"]["PreA"] + Config["pos"], 0)
ax1 = fig.add_subplot(311)
ax1.plot(
linspace(0, len(self.processed_Tho),
len(self.processed_Tho)), self.processed_Tho, color='blue')
# 绘制x = PreCut的线 和 x = PostCut的虚线
ax1.set_xlim(min_x, max_x)
ax1.set_title("THO")
ax2 = fig.add_subplot(312)
ax2.plot(linspace(Config["pos"],
len(self.processed_orgBcg) + Config["pos"],
len(self.processed_orgBcg)), self.processed_orgBcg, color='blue')
ax2.set_xlim(min_x, max_x)
ax2.set_title("orgBcg")
ax3 = fig.add_subplot(313)
ax3.plot(
linspace(0, len(self.processed_Abd),
len(self.processed_Abd)), self.processed_Abd, color='blue')
ax3.set_xlim(min_x, max_x)
ax3.set_title("ABD")
width, height = fig.figbbox.width, fig.figbbox.height
fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED), canvas.buffer_rgba(), width, height
def DrawPicByEpoch(self, epoch):
try:
PSG_SP = epoch * 30 * Config["ApplyFrequency"]
PSG_EP = (epoch + 6) * 30 * Config["ApplyFrequency"]
orgBcg_SP = PSG_SP - Config["pos"]
orgBcg_EP = PSG_EP - Config["pos"]
tho_seg = self.processed_Tho[PSG_SP:PSG_EP]
orgBcg_seg = self.processed_orgBcg[orgBcg_SP:orgBcg_EP] * Config["orgBcg_reverse"]
abd_seg = self.processed_Abd[PSG_SP:PSG_EP]
fig = Figure(figsize=(12, 10), dpi=100)
canvas = FigureCanvas(fig)
# 根据PSG来和绘制
ax1 = fig.add_subplot(321)
ax1.plot(linspace(PSG_SP, PSG_EP, len(tho_seg)), tho_seg)
tho_peaks, _ = find_peaks(tho_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax1.plot(linspace(PSG_SP, PSG_EP, len(tho_seg))[tho_peaks], tho_seg[tho_peaks], "x")
ax3 = fig.add_subplot(323)
ax3.plot(linspace(orgBcg_SP, orgBcg_EP, len(orgBcg_seg)), orgBcg_seg)
orgBcg_peaks, _ = find_peaks(orgBcg_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax3.plot(linspace(orgBcg_SP, orgBcg_EP, len(orgBcg_seg))[orgBcg_peaks], orgBcg_seg[orgBcg_peaks], "x")
ax2 = fig.add_subplot(325)
ax2.plot(linspace(PSG_SP, PSG_EP, len(abd_seg)), abd_seg)
abd_peaks, _ = find_peaks(abd_seg, prominence=0, distance=3 * Config["ApplyFrequency"])
ax2.plot(linspace(PSG_SP, PSG_EP, len(abd_seg))[abd_peaks], abd_seg[abd_peaks], "x")
# 绘制间期
ax4 = fig.add_subplot(322)
ax4.plot(linspace(PSG_SP, PSG_EP, len(diff(tho_peaks).repeat(Config["ApplyFrequency"]))),
diff(tho_peaks).repeat(Config["ApplyFrequency"]), alpha=0.5, label="tho")
ax4.plot(linspace(PSG_SP, PSG_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax4.set_title("tho_interval")
ax4.legend()
ax4.set_ylim((10, 50))
ax5 = fig.add_subplot(324)
ax5.plot(linspace(orgBcg_SP, orgBcg_EP, len(diff(tho_peaks).repeat(Config["ApplyFrequency"]))),
diff(tho_peaks).repeat(Config["ApplyFrequency"]))
ax5.plot(linspace(orgBcg_SP, orgBcg_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax5.set_title("resp_interval")
ax5.set_ylim((10, 50))
ax6 = fig.add_subplot(326)
ax6.plot(linspace(PSG_SP, PSG_EP, len(diff(abd_peaks).repeat(Config["ApplyFrequency"]))),
diff(abd_peaks).repeat(Config["ApplyFrequency"]))
ax6.plot(linspace(PSG_SP, PSG_EP, len(diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]))),
diff(orgBcg_peaks).repeat(Config["ApplyFrequency"]), label="resp")
ax6.set_title("abd_interval")
ax6.set_ylim((10, 50))
width, height = fig.figbbox.width, fig.figbbox.height
fig.canvas.draw()
except Exception:
return Result().failure(info=Constants.DRAWING_FAILURE)
# 返回图片以便存到QPixImage
return Result().success(info=Constants.DRAWING_FINISHED), canvas.buffer_rgba(), width, height
@staticmethod
@njit("int64[:](int64[:],int64[:], int32[:])", nogil=True, parallel=True)
def get_Correlate(a, v, between):

View File

@ -33,6 +33,8 @@ class MainWindow(QMainWindow, Ui_Signal_Label):
self.ui = Ui_Signal_Label()
self.ui.setupUi(self)
self.setFixedSize(720, 1080) # 设置固定大小,禁止缩放
# 消息弹窗初始化
self.msgBox = QMessageBox()
self.msgBox.setWindowTitle(Constants.MAINWINDOW_MSGBOX_TITLE)