From c6161e7dd5c24a6ea39a1693c5b3fdbadac9eaa2 Mon Sep 17 00:00:00 2001 From: marques Date: Wed, 17 Dec 2025 01:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96J=E5=B3=B0=E5=92=8CR=E5=B3=B0?= =?UTF-8?q?=E7=9A=84=E7=BB=98=E5=88=B6=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4BCG=E6=8F=90=E5=89=8D=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E5=B3=B0=E5=80=BC=E4=BD=8D=E7=BD=AE=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/Module_precisely_align.py | 76 +++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/func/Module_precisely_align.py b/func/Module_precisely_align.py index 6e3ee8e..674123a 100644 --- a/func/Module_precisely_align.py +++ b/func/Module_precisely_align.py @@ -483,27 +483,54 @@ class MainWindow_precisely_align(QMainWindow): Jpeak = self.data.Jpeak[:-2] Rpeak = self.data.Rpeak[:-2] self.ax0.set_title("JJIV") + self.ax1.set_title("RRIV") + + + if self.data.BCG_early: + Jpeak = Jpeak - self.data.approximately_align_pos + else: + Jpeak = Jpeak + self.data.approximately_align_pos + + # if self.data.BCG_early is True: + # self.ax0.stem(Jpeak, plot_element["JJIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_GREEN, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_JJIV) + # self.ax1.stem(Rpeak, plot_element["RRIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV) + # self.ax0.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", + # label="Start Line") + # self.ax1.axvline(x=0, color=Constants.PLOT_COLOR_BLACK, linestyle="--", label="Start Line") + + # elif self.data.BCG_early is False: + # Jpeak = Jpeak + self.data.approximately_align_pos + + # self.ax0.stem(Jpeak, plot_element["JJIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_GREEN, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_JJIV) + # self.ax1.stem(Rpeak, plot_element["RRIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV) + # self.ax0.axvline(x=0, color=Constants.PLOT_COLOR_BLACK, linestyle="--", label="Start Line") + # self.ax1.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", + # label="Start Line") + # else: + # self.ax0.stem(Jpeak, plot_element["JJIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_GREEN, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_JJIV) + # self.ax1.stem(Rpeak, plot_element["RRIVs"], + # markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE, + # label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV) + # self.ax0.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", + # label="Start Line") + # self.ax1.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", + # label="Start Line") self.ax0.stem(Jpeak, plot_element["JJIVs"], markerfmt="C0.", linefmt=Constants.PLOT_COLOR_GREEN, label=Constants.PRECISELY_ALIGN_PLOT_LABEL_JJIV) - self.ax1.set_title("RRIV") self.ax1.stem(Rpeak, plot_element["RRIVs"], markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE, label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV) - if self.data.BCG_early is True: - self.ax0.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", - label="Start Line") - self.ax1.axvline(x=0, color=Constants.PLOT_COLOR_BLACK, linestyle="--", label="Start Line") - elif self.data.BCG_early is False: - self.ax0.axvline(x=0, color=Constants.PLOT_COLOR_BLACK, linestyle="--", label="Start Line") - self.ax1.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", - label="Start Line") - else: - self.ax0.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", - label="Start Line") - self.ax1.axvline(x=self.data.approximately_align_pos, color=Constants.PLOT_COLOR_BLACK, linestyle="--", - label="Start Line") - self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT) self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT) self.canvas.draw() @@ -1392,6 +1419,14 @@ class MainWindow_precisely_align(QMainWindow): elif rect_right < 0: rect_left = 0 rect_right = 0 + + if self.data.BCG_early: + # 如果是提前BCG模式,J峰位置需要加上offset + rect_left += self.data.approximately_align_pos + rect_right += self.data.approximately_align_pos + else: + rect_left -= self.data.approximately_align_pos + rect_right -= self.data.approximately_align_pos indices = where((self.data.Jpeak[:-2] >= rect_left) & (self.data.Jpeak[:-2] <= rect_right))[0] if indices is None or len(indices) <= 0: if self.ui.radioButton_BCG_front.isChecked(): @@ -1674,7 +1709,7 @@ class Data: Filename.PRECISELY_ALIGN_INFO + Params.ENDSWITH_TXT)) Config["Path"]["Save_OrgBCG"] = str( Path(Config["Path"]["Save_OrgBCG"]) / Path( - Filename.ORGBCG_SYNC + str(Config["InputConfig"]["orgBcgFreq"]) + Params.ENDSWITH_TXT)) + Filename.ORGBCG_SYNC + str(Config["InputConfig"]["UseFreq"]) + Params.ENDSWITH_TXT)) result = PublicFunc.examine_file(Config["Path"]["Input_BCG"], Filename.BCG_FILTER, Params.ENDSWITH_TXT) if result.status: Config["Path"]["Input_BCG"] = result.data["path"] @@ -1992,6 +2027,7 @@ class Data: Config["frontcut_index_BCG"] -= Config["offset_anchor"] * Config["orgfs"] / Config["InputConfig"]["UseFreq"] datalen = np_min([len(self.cut_ECG), len(self.res_BCG)]) + print(f"datalen: {datalen} len cut_ECG: {len(self.cut_ECG)} len res_BCG: {len(self.res_BCG)}") self.cut_ECG = self.cut_ECG[:datalen] self.res_BCG = self.res_BCG[:datalen] self.res_orgBcg = self.res_orgBcg[:datalen] @@ -2135,10 +2171,10 @@ class Data: not Path(Config["Path"]["Save_OrgBCG"]).parent.is_dir()): Path(Config["Path"]["Save_OrgBCG"]).parent.mkdir(parents=True, exist_ok=True) - if Config["InputConfig"]["orgBcgFreq"] != Config["InputConfig"]["UseFreq"]: - self.res_orgBcg = ss_resample(self.res_orgBcg, - int(len(self.res_orgBcg) * - (Config["InputConfig"]["orgBcgFreq"] / Config["InputConfig"]["UseFreq"]))) + # if Config["InputConfig"]["orgBcgFreq"] != Config["InputConfig"]["UseFreq"]: + # self.res_orgBcg = ss_resample(self.res_orgBcg, + # int(len(self.res_orgBcg) * + # (Config["InputConfig"]["orgBcgFreq"] / Config["InputConfig"]["UseFreq"]))) if self.res_orgBcg is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE +