diff --git a/func/Module_approximately_align.py b/func/Module_approximately_align.py
index f48cea7..f90ec22 100644
--- a/func/Module_approximately_align.py
+++ b/func/Module_approximately_align.py
@@ -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):
diff --git a/func/Module_mainwindow.py b/func/Module_mainwindow.py
index f49ff8f..42c033c 100644
--- a/func/Module_mainwindow.py
+++ b/func/Module_mainwindow.py
@@ -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)
diff --git a/ui/MainWindow/MainWindow_approximately_align.py b/ui/MainWindow/MainWindow_approximately_align.py
index c216bdd..f73b8e1 100644
--- a/ui/MainWindow/MainWindow_approximately_align.py
+++ b/ui/MainWindow/MainWindow_approximately_align.py
@@ -479,11 +479,6 @@ class Ui_MainWindow_approximately_align(object):
self.verticalLayout_7.setObjectName(u"verticalLayout_7")
self.verticalLayout_canvas = QVBoxLayout()
self.verticalLayout_canvas.setObjectName(u"verticalLayout_canvas")
- self.label_Pic = QLabel(self.groupBox_canvas)
- self.label_Pic.setObjectName(u"label_Pic")
-
- self.verticalLayout_canvas.addWidget(self.label_Pic)
-
self.verticalLayout_7.addLayout(self.verticalLayout_canvas)
@@ -545,6 +540,5 @@ class Ui_MainWindow_approximately_align(object):
self.pushButton_save.setText(QCoreApplication.translate("MainWindow_approximately_align", u"\u4fdd\u5b58\u7ed3\u679c", None))
self.groupBox.setTitle(QCoreApplication.translate("MainWindow_approximately_align", u"\u65e5\u5fd7", None))
self.groupBox_canvas.setTitle(QCoreApplication.translate("MainWindow_approximately_align", u"\u7ed8\u56fe\u533a", None))
- self.label_Pic.setText("")
# retranslateUi
diff --git a/ui/MainWindow/MainWindow_approximately_align.ui b/ui/MainWindow/MainWindow_approximately_align.ui
index e052b07..54aa8a3 100644
--- a/ui/MainWindow/MainWindow_approximately_align.ui
+++ b/ui/MainWindow/MainWindow_approximately_align.ui
@@ -781,15 +781,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/ui/MainWindow/MainWindow_menu.py b/ui/MainWindow/MainWindow_menu.py
index eefa04f..5f7f1ff 100644
--- a/ui/MainWindow/MainWindow_menu.py
+++ b/ui/MainWindow/MainWindow_menu.py
@@ -24,7 +24,12 @@ class Ui_Signal_Label(object):
def setupUi(self, Signal_Label):
if not Signal_Label.objectName():
Signal_Label.setObjectName(u"Signal_Label")
- Signal_Label.resize(675, 1008)
+ Signal_Label.resize(720, 1080)
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(Signal_Label.sizePolicy().hasHeightForWidth())
+ Signal_Label.setSizePolicy(sizePolicy)
self.centralwidget = QWidget(Signal_Label)
self.centralwidget.setObjectName(u"centralwidget")
self.gridLayout = QGridLayout(self.centralwidget)
@@ -65,11 +70,11 @@ class Ui_Signal_Label(object):
self.pushButton_open = QPushButton(self.centralwidget)
self.pushButton_open.setObjectName(u"pushButton_open")
- sizePolicy = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.pushButton_open.sizePolicy().hasHeightForWidth())
- self.pushButton_open.setSizePolicy(sizePolicy)
+ sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Preferred)
+ sizePolicy1.setHorizontalStretch(0)
+ sizePolicy1.setVerticalStretch(0)
+ sizePolicy1.setHeightForWidth(self.pushButton_open.sizePolicy().hasHeightForWidth())
+ self.pushButton_open.setSizePolicy(sizePolicy1)
self.pushButton_open.setFont(font)
self.verticalLayout_2.addWidget(self.pushButton_open)
@@ -82,8 +87,8 @@ class Ui_Signal_Label(object):
self.pushButton_approximately_align = QPushButton(self.centralwidget)
self.pushButton_approximately_align.setObjectName(u"pushButton_approximately_align")
- sizePolicy.setHeightForWidth(self.pushButton_approximately_align.sizePolicy().hasHeightForWidth())
- self.pushButton_approximately_align.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_approximately_align.sizePolicy().hasHeightForWidth())
+ self.pushButton_approximately_align.setSizePolicy(sizePolicy1)
self.pushButton_approximately_align.setFont(font)
self.verticalLayout.addWidget(self.pushButton_approximately_align)
@@ -92,16 +97,16 @@ class Ui_Signal_Label(object):
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.pushButton_preprocess_BCG = QPushButton(self.centralwidget)
self.pushButton_preprocess_BCG.setObjectName(u"pushButton_preprocess_BCG")
- sizePolicy.setHeightForWidth(self.pushButton_preprocess_BCG.sizePolicy().hasHeightForWidth())
- self.pushButton_preprocess_BCG.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_preprocess_BCG.sizePolicy().hasHeightForWidth())
+ self.pushButton_preprocess_BCG.setSizePolicy(sizePolicy1)
self.pushButton_preprocess_BCG.setFont(font)
self.horizontalLayout_2.addWidget(self.pushButton_preprocess_BCG)
self.pushButton_preprocess_ECG = QPushButton(self.centralwidget)
self.pushButton_preprocess_ECG.setObjectName(u"pushButton_preprocess_ECG")
- sizePolicy.setHeightForWidth(self.pushButton_preprocess_ECG.sizePolicy().hasHeightForWidth())
- self.pushButton_preprocess_ECG.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_preprocess_ECG.sizePolicy().hasHeightForWidth())
+ self.pushButton_preprocess_ECG.setSizePolicy(sizePolicy1)
self.pushButton_preprocess_ECG.setFont(font)
self.horizontalLayout_2.addWidget(self.pushButton_preprocess_ECG)
@@ -113,16 +118,16 @@ class Ui_Signal_Label(object):
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
self.pushButton_detect_Jpeak = QPushButton(self.centralwidget)
self.pushButton_detect_Jpeak.setObjectName(u"pushButton_detect_Jpeak")
- sizePolicy.setHeightForWidth(self.pushButton_detect_Jpeak.sizePolicy().hasHeightForWidth())
- self.pushButton_detect_Jpeak.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_detect_Jpeak.sizePolicy().hasHeightForWidth())
+ self.pushButton_detect_Jpeak.setSizePolicy(sizePolicy1)
self.pushButton_detect_Jpeak.setFont(font)
self.horizontalLayout_3.addWidget(self.pushButton_detect_Jpeak)
self.pushButton_detect_Rpeak = QPushButton(self.centralwidget)
self.pushButton_detect_Rpeak.setObjectName(u"pushButton_detect_Rpeak")
- sizePolicy.setHeightForWidth(self.pushButton_detect_Rpeak.sizePolicy().hasHeightForWidth())
- self.pushButton_detect_Rpeak.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_detect_Rpeak.sizePolicy().hasHeightForWidth())
+ self.pushButton_detect_Rpeak.setSizePolicy(sizePolicy1)
self.pushButton_detect_Rpeak.setFont(font)
self.horizontalLayout_3.addWidget(self.pushButton_detect_Rpeak)
@@ -134,16 +139,16 @@ class Ui_Signal_Label(object):
self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
self.pushButton_label_check_BCG = QPushButton(self.centralwidget)
self.pushButton_label_check_BCG.setObjectName(u"pushButton_label_check_BCG")
- sizePolicy.setHeightForWidth(self.pushButton_label_check_BCG.sizePolicy().hasHeightForWidth())
- self.pushButton_label_check_BCG.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_label_check_BCG.sizePolicy().hasHeightForWidth())
+ self.pushButton_label_check_BCG.setSizePolicy(sizePolicy1)
self.pushButton_label_check_BCG.setFont(font)
self.horizontalLayout_6.addWidget(self.pushButton_label_check_BCG)
self.pushButton_label_check_ECG = QPushButton(self.centralwidget)
self.pushButton_label_check_ECG.setObjectName(u"pushButton_label_check_ECG")
- sizePolicy.setHeightForWidth(self.pushButton_label_check_ECG.sizePolicy().hasHeightForWidth())
- self.pushButton_label_check_ECG.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_label_check_ECG.sizePolicy().hasHeightForWidth())
+ self.pushButton_label_check_ECG.setSizePolicy(sizePolicy1)
self.pushButton_label_check_ECG.setFont(font)
self.horizontalLayout_6.addWidget(self.pushButton_label_check_ECG)
@@ -155,16 +160,16 @@ class Ui_Signal_Label(object):
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.pushButton_precisely_align = QPushButton(self.centralwidget)
self.pushButton_precisely_align.setObjectName(u"pushButton_precisely_align")
- sizePolicy.setHeightForWidth(self.pushButton_precisely_align.sizePolicy().hasHeightForWidth())
- self.pushButton_precisely_align.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_precisely_align.sizePolicy().hasHeightForWidth())
+ self.pushButton_precisely_align.setSizePolicy(sizePolicy1)
self.pushButton_precisely_align.setFont(font)
self.horizontalLayout_4.addWidget(self.pushButton_precisely_align)
self.pushButton_cut_PSG = QPushButton(self.centralwidget)
self.pushButton_cut_PSG.setObjectName(u"pushButton_cut_PSG")
- sizePolicy.setHeightForWidth(self.pushButton_cut_PSG.sizePolicy().hasHeightForWidth())
- self.pushButton_cut_PSG.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_cut_PSG.sizePolicy().hasHeightForWidth())
+ self.pushButton_cut_PSG.setSizePolicy(sizePolicy1)
self.pushButton_cut_PSG.setFont(font)
self.horizontalLayout_4.addWidget(self.pushButton_cut_PSG)
@@ -176,32 +181,32 @@ class Ui_Signal_Label(object):
self.pushButton_artifact_label = QPushButton(self.centralwidget)
self.pushButton_artifact_label.setObjectName(u"pushButton_artifact_label")
- sizePolicy.setHeightForWidth(self.pushButton_artifact_label.sizePolicy().hasHeightForWidth())
- self.pushButton_artifact_label.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_artifact_label.sizePolicy().hasHeightForWidth())
+ self.pushButton_artifact_label.setSizePolicy(sizePolicy1)
self.pushButton_artifact_label.setFont(font)
self.verticalLayout.addWidget(self.pushButton_artifact_label)
self.pushButton_bcg_quality_label = QPushButton(self.centralwidget)
self.pushButton_bcg_quality_label.setObjectName(u"pushButton_bcg_quality_label")
- sizePolicy.setHeightForWidth(self.pushButton_bcg_quality_label.sizePolicy().hasHeightForWidth())
- self.pushButton_bcg_quality_label.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_bcg_quality_label.sizePolicy().hasHeightForWidth())
+ self.pushButton_bcg_quality_label.setSizePolicy(sizePolicy1)
self.pushButton_bcg_quality_label.setFont(font)
self.verticalLayout.addWidget(self.pushButton_bcg_quality_label)
self.pushButton_resp_quality_label = QPushButton(self.centralwidget)
self.pushButton_resp_quality_label.setObjectName(u"pushButton_resp_quality_label")
- sizePolicy.setHeightForWidth(self.pushButton_resp_quality_label.sizePolicy().hasHeightForWidth())
- self.pushButton_resp_quality_label.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_resp_quality_label.sizePolicy().hasHeightForWidth())
+ self.pushButton_resp_quality_label.setSizePolicy(sizePolicy1)
self.pushButton_resp_quality_label.setFont(font)
self.verticalLayout.addWidget(self.pushButton_resp_quality_label)
self.pushButton_SA_label = QPushButton(self.centralwidget)
self.pushButton_SA_label.setObjectName(u"pushButton_SA_label")
- sizePolicy.setHeightForWidth(self.pushButton_SA_label.sizePolicy().hasHeightForWidth())
- self.pushButton_SA_label.setSizePolicy(sizePolicy)
+ sizePolicy1.setHeightForWidth(self.pushButton_SA_label.sizePolicy().hasHeightForWidth())
+ self.pushButton_SA_label.setSizePolicy(sizePolicy1)
self.pushButton_SA_label.setFont(font)
self.verticalLayout.addWidget(self.pushButton_SA_label)
diff --git a/ui/MainWindow/MainWindow_menu.ui b/ui/MainWindow/MainWindow_menu.ui
index 0ce6795..6189829 100644
--- a/ui/MainWindow/MainWindow_menu.ui
+++ b/ui/MainWindow/MainWindow_menu.ui
@@ -6,10 +6,16 @@
0
0
- 675
- 1008
+ 720
+ 1080
+
+
+ 0
+ 0
+
+
Signal_Label