优化数据处理逻辑,确保在无体动情况下仍能正确读取和标记数据
This commit is contained in:
@ -334,6 +334,8 @@ class MainWindow_SA_label(QMainWindow):
|
||||
self.ax6.grid(True)
|
||||
self.ax6.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
|
||||
|
||||
|
||||
PublicFunc.__resetAllButton__(self, ButtonState)
|
||||
|
||||
self.ui.tableWidget_label.setHorizontalHeaderLabels(['原事件类型', '事件类型', '标签类型', '起始时间(s)', '终止时间(s)'])
|
||||
@ -1087,16 +1089,19 @@ class MainWindow_SA_label(QMainWindow):
|
||||
self.ax4.grid(True)
|
||||
self.ax4.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
self.ax4.tick_params(axis='x', colors=Constants.PLOT_COLOR_WHITE)
|
||||
|
||||
if self.ax5 is not None:
|
||||
self.ax5.clear()
|
||||
self.ax5.grid(True)
|
||||
self.ax5.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
self.ax5.tick_params(axis='x', colors=Constants.PLOT_COLOR_WHITE)
|
||||
|
||||
if self.ax6 is not None:
|
||||
self.ax6.clear()
|
||||
self.ax6.grid(True)
|
||||
self.ax6.xaxis.set_major_formatter(Params.FORMATTER)
|
||||
|
||||
|
||||
def on_xlim_change(self, event_ax):
|
||||
# 获取当前x轴范围
|
||||
left, right = event_ax.get_xlim()
|
||||
@ -1130,23 +1135,23 @@ class MainWindow_SA_label(QMainWindow):
|
||||
self.ui.spinBox_correctEnd.setValue(Config["BCG_EP"])
|
||||
self.ui.label_BCG_event.setText("Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)))
|
||||
self.ui.label_BCG_event_2.setText("Epoch:{} Duration:{}s".format(one_bcg_data["Epoch"], bcg_duration))
|
||||
self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="Flow T", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow P", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5],
|
||||
self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5],
|
||||
bcg_duration_new=bcg_duration_new, show_mode="one")
|
||||
self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False, bcg_duration_new=bcg_duration_new, show_mode="one")
|
||||
self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
|
||||
self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow T", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Flow P", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", bcg_duration_new=bcg_duration_new,
|
||||
show_mode="one")
|
||||
self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False,
|
||||
bcg_duration_new=bcg_duration_new, show_mode="one")
|
||||
self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False, bcg_duration_new=bcg_duration_new, show_mode="one")
|
||||
|
||||
self.ax0.callbacks.connect('xlim_changed', lambda ax: self.on_xlim_change(ax))
|
||||
|
||||
@ -1163,19 +1168,20 @@ class MainWindow_SA_label(QMainWindow):
|
||||
# 进行向两边延展
|
||||
bcg_SP = bcg_SP - Config["AddSecond"]["Front"] + time_move_count
|
||||
bcg_EP = bcg_EP + Config["AddSecond"]["Back"] + time_move_count
|
||||
self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5], show_mode="new")
|
||||
self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow T", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Flow P", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", show_mode="new")
|
||||
|
||||
self.plt_channel(plt_=self.ax0, SP=bcg_SP, EP=bcg_EP, channel="Flow T", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax1, SP=bcg_SP, EP=bcg_EP, channel="Flow P", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax2, SP=bcg_SP, EP=bcg_EP, channel="Effort Tho", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax3, SP=bcg_SP, EP=bcg_EP, channel="Effort Abd", show_mode="new")
|
||||
self.plt_channel(plt_=self.ax4, SP=bcg_SP, EP=bcg_EP, channel="SpO2", event_code=[5], show_mode="new")
|
||||
self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False, show_mode="new")
|
||||
self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
|
||||
self.plt_channel(plt_=self.ax5, SP=bcg_SP, EP=bcg_EP, channel="0.7lowpass_resp",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False,
|
||||
show_mode="new")
|
||||
self.plt_channel(plt_=self.ax6, SP=bcg_SP, EP=bcg_EP, channel="orgdata",
|
||||
event_code=[6, 7, 8, 9, 10, 1, 2, 3, 4],
|
||||
event_show_under=False, show_mode="new")
|
||||
|
||||
|
||||
self.ui.label_BCG_event.setText(
|
||||
"Index:{}/{}".format((Config["PlotEventIndex"] + 1), len(self.data.df_corrected)))
|
||||
@ -1380,11 +1386,14 @@ class Data:
|
||||
Config["InputConfig"]["SpO2Freq"] = result.data["freq"]
|
||||
else:
|
||||
return result
|
||||
result = PublicFunc.examine_file(Config["Path"]["Input_Artifact"], Filename.ARTIFACT_A, Params.ENDSWITH_TXT)
|
||||
if result.status:
|
||||
|
||||
# 没有体动也能打标
|
||||
artifact_result = PublicFunc.examine_file(Config["Path"]["Input_Artifact"], Filename.ARTIFACT_A, Params.ENDSWITH_TXT)
|
||||
if artifact_result.status:
|
||||
Config["Path"]["Input_Artifact"] = result.data["path"]
|
||||
else:
|
||||
return result
|
||||
pass
|
||||
# return result
|
||||
|
||||
Config["Path"]["Input_Label"] = str(
|
||||
Path(Config["Path"]["Input_Label"]) / Path(Filename.SA_LABEL_SYNC + Params.ENDSWITH_CSV))
|
||||
@ -1393,11 +1402,20 @@ class Data:
|
||||
Config["Path"]["Save_2"] = str(
|
||||
Path(Config["Path"]["Save_2"]) / Path(Filename.SA_LABEL_ADD + Params.ENDSWITH_CSV))
|
||||
|
||||
if not Path(Config["Path"]["Input_Artifact"]).exists():
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + "\n" +
|
||||
if artifact_result.status:
|
||||
# return Result().failure(info=Constants.INPUT_FAILURE + "\n" +
|
||||
# Filename.ARTIFACT_A + ":" +
|
||||
# Config["Path"]["Input_Artifact"] +
|
||||
# Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
|
||||
PublicFunc.msgbox_output(self, Constants.INPUT_FAILURE + "\n" +
|
||||
Filename.ARTIFACT_A + ":" +
|
||||
Config["Path"]["Input_Artifact"] +
|
||||
Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
Constants.FAILURE_REASON["Path_Not_Exist"],
|
||||
Constants.MSGBOX_TYPE_WARNING)
|
||||
|
||||
Config["Path"]["Input_Artifact"] = None
|
||||
|
||||
if not Path(Config["Path"]["Input_Label"]).exists():
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + "\n" +
|
||||
Filename.SA_LABEL_SYNC + ":" +
|
||||
@ -1423,9 +1441,14 @@ class Data:
|
||||
self.SpO2 = read_csv(Config["Path"]["Input_SpO2"],
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
|
||||
if artifact_result.status:
|
||||
self.Artifact = read_csv(Config["Path"]["Input_Artifact"],
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
else:
|
||||
self.Artifact = array([])
|
||||
|
||||
self.event_label = zeros(len(self.OrgBCG) + (int(Config["AddSecond"]["Front"] + int(Config["AddSecond"]["Back"])) * Config["InputConfig"]["PlotFreq"]))
|
||||
except Exception as e:
|
||||
return Result().failure(info=Constants.INPUT_FAILURE +
|
||||
|
||||
Reference in New Issue
Block a user