优化J峰和R峰的绘制逻辑,调整BCG提前模式下的峰值位置计算
This commit is contained in:
@ -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 +
|
||||
|
||||
Reference in New Issue
Block a user