From 6494dc84788fa5ab81dbf09b887bd8b396ed1d79 Mon Sep 17 00:00:00 2001 From: Yorusora Date: Thu, 29 May 2025 21:30:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86<=E5=91=BC=E5=90=B8?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E6=80=A7=E5=8F=8A=E9=97=B4=E6=9C=9F=E6=A0=87?= =?UTF-8?q?=E6=B3=A8>=E7=9A=84=E4=BD=93=E5=8A=A8=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/Module_resp_quality_label.py | 92 ++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/func/Module_resp_quality_label.py b/func/Module_resp_quality_label.py index 7699227..54c9577 100644 --- a/func/Module_resp_quality_label.py +++ b/func/Module_resp_quality_label.py @@ -285,6 +285,12 @@ class MainWindow_resp_quality_label(QMainWindow): self.ui.pushButton_reset.clicked.connect(self.__slot_btn_label__) self.ui.lineEdit_filter_labeled.textChanged.connect(self.__slot_lineEdit_filter__) self.ui.lineEdit_filter_tobelabeled.textChanged.connect(self.__slot_lineEdit_filter__) + self.ui.checkBox_allin.clicked.connect(self.__slot_checkBox__) + self.ui.checkBox_type1.clicked.connect(self.__slot_checkBox__) + self.ui.checkBox_type2.clicked.connect(self.__slot_checkBox__) + self.ui.checkBox_type3.clicked.connect(self.__slot_checkBox__) + self.ui.checkBox_type4.clicked.connect(self.__slot_checkBox__) + self.ui.checkBox_type5.clicked.connect(self.__slot_checkBox__) self.ui.doubleSpinBox_quality_threshold1.valueChanged.connect(self.update_config) self.ui.doubleSpinBox_quality_threshold2.valueChanged.connect(self.update_config) self.ui.doubleSpinBox_findpeaks_min_interval.valueChanged.connect(self.update_config) @@ -349,7 +355,13 @@ class MainWindow_resp_quality_label(QMainWindow): sender == self.ui.pushButton_prev or sender == self.ui.pushButton_next or sender == self.ui.tableWidget_labeled or - sender == self.ui.tableWidget_tobelabeled): + sender == self.ui.tableWidget_tobelabeled or + sender == self.ui.checkBox_allin or + sender == self.ui.checkBox_type1 or + sender == self.ui.checkBox_type2 or + sender == self.ui.checkBox_type3 or + sender == self.ui.checkBox_type4 or + sender == self.ui.checkBox_type5): try: if Config["CurrentPartNum"] != Config["DataPartNum"]: begin_OrgBCG = Config["CurrentOrgBCGIndex"] @@ -385,15 +397,34 @@ class MainWindow_resp_quality_label(QMainWindow): [self.data.Tho_peak_y[x] for x in [index for index, value in enumerate(self.data.Tho_peak) if begin_Tho <= value <= end_Tho]], 'ro', label=Constants.RESP_QUALITY_LABEL_PLOT_LABEL_THO_PEAKS) + + # 绘制体动 + artifact_type_seq = array([]) + artifact_type_seq = artifact_type_seq.astype(int64) + if self.ui.checkBox_type1.isChecked(): + artifact_type_seq = append(artifact_type_seq, 1) + if self.ui.checkBox_type2.isChecked(): + artifact_type_seq = append(artifact_type_seq, 2) + if self.ui.checkBox_type3.isChecked(): + artifact_type_seq = append(artifact_type_seq, 3) + if self.ui.checkBox_type4.isChecked(): + artifact_type_seq = append(artifact_type_seq, 4) + if self.ui.checkBox_type5.isChecked(): + artifact_type_seq = append(artifact_type_seq, 5) + length = Config["InputConfig"]["OrgBCGUseFreq"] * Params.RESP_QUALITY_LABEL_PARTS_TIME_SEC + mask = array([arange(length), arange(length), arange(length), arange(length), arange(length), arange(length)]) + mask = mask.astype(float64) + for i in artifact_type_seq: + mask[i] = self.data.artifact_mask[begin_OrgBCG:end_OrgBCG] == i + mask[i] = (BDR[begin_OrgBCG:end_OrgBCG] * mask[i]).astype(float64) + place(mask[i], mask[i] == 0, nan) + self.ax0.plot(arange(begin_OrgBCG, end_OrgBCG), mask[i], + label=f"{Constants.RESP_QUALITY_LABEL_PLOT_LABEL_ARTIFACT}{i}", color=Constants.PLOT_COLOR_RED, + linestyle="-") + self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT) self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT) - # 绘制体动 - mask = self.data.artifact_mask[begin_OrgBCG: end_OrgBCG] == 1 - mask = (BDR * mask).astype(float64) - place(mask, mask == 0, nan) - self.ax0.plot(arange(begin_OrgBCG, end_OrgBCG), mask, - label=f"{Constants.RESP_QUALITY_LABEL_PLOT_LABEL_ARTIFACT}", - color=Constants.PLOT_COLOR_PINK, linestyle="-") + # 绘制频谱 self.ax0_spectrum.plot(bcg_freq, bcg_spectrum, label=Constants.RESP_QUALITY_LABEL_SPECTRUM_ORGBCG_LABEL, @@ -952,6 +983,40 @@ class MainWindow_resp_quality_label(QMainWindow): else: raise ValueError("发生信号不存在") + def __slot_checkBox__(self): + sender = self.sender() + + if sender == self.ui.checkBox_allin: + if self.ui.checkBox_allin.isChecked(): + self.ui.checkBox_type1.setChecked(True) + self.ui.checkBox_type2.setChecked(True) + self.ui.checkBox_type3.setChecked(True) + self.ui.checkBox_type4.setChecked(True) + self.ui.checkBox_type5.setChecked(True) + else: + self.ui.checkBox_type1.setChecked(False) + self.ui.checkBox_type2.setChecked(False) + self.ui.checkBox_type3.setChecked(False) + self.ui.checkBox_type4.setChecked(False) + self.ui.checkBox_type5.setChecked(False) + elif (sender == self.ui.checkBox_type1 or + sender == self.ui.checkBox_type2 or + sender == self.ui.checkBox_type3 or + sender == self.ui.checkBox_type4 or + sender == self.ui.checkBox_type5): + if (self.ui.checkBox_type1.isChecked() and + self.ui.checkBox_type2.isChecked() and + self.ui.checkBox_type3.isChecked() and + self.ui.checkBox_type4.isChecked() and + self.ui.checkBox_type5.isChecked()): + self.ui.checkBox_allin.setChecked(True) + else: + self.ui.checkBox_allin.setChecked(False) + else: + raise ValueError("发射信号不存在") + + self.__plot__() + def reset_axes(self): if self.ax0 is not None: self.ax0.clear() @@ -1372,7 +1437,16 @@ class Data(): artifact_end = append(artifact_end, self.Artifact_a[i]) self.artifact_mask = zeros(len(self.OrgBCG)) for i in range(0, len(self.artifact_number)): - self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 1 + if self.artifact_type[i] == 1: + self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 1 + elif self.artifact_type[i] == 2: + self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 2 + elif self.artifact_type[i] == 3: + self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 3 + elif self.artifact_type[i] == 4: + self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 4 + elif self.artifact_type[i] == 5: + self.artifact_mask[artifact_start[i]: artifact_end[i] + 1] = 5 except Exception as e: return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON["Get_Artifact_Format_Exception"] + "\n" + format_exc())