Merge branch 'master' into cxh_dev

This commit is contained in:
marques
2025-06-05 00:27:59 +08:00
20 changed files with 367 additions and 232 deletions

View File

@ -254,41 +254,6 @@ class SettingWindow(QMainWindow):
Path(Filename.ECG_FILTER +
str(self.ui.spinBox_input_freq_ECG.value()) +
Params.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_save_orgBcg.setPlainText(
str((Path(self.root_path) /
Filename.PATH_ORGBCG_ALIGNED /
Path(str(self.sampID)) /
Path(Filename.ORGBCG_SYNC +
str(self.ui.spinBox_input_freq_orgBcg.value()) +
Params.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_save_BCG.setPlainText(
str((Path(self.root_path) /
Filename.PATH_ORGBCG_ALIGNED /
Path(str(self.sampID)) /
Path(Filename.BCG_SYNC +
str(self.ui.spinBox_input_freq_BCG.value()) +
Params.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_save_ECG.setPlainText(
str((Path(self.root_path) /
Filename.PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
Path(Filename.ECG_SYNC +
str(self.ui.spinBox_input_freq_ECG.value()) +
Params.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_save_Jpeak.setPlainText(
str((Path(self.root_path) /
Filename.PATH_ORGBCG_ALIGNED /
Path(str(self.sampID)) /
Path(Filename.JPEAK_SYNC +
str(self.ui.spinBox_input_freq_BCG.value()) +
Params.ENDSWITH_TXT))))
self.ui.plainTextEdit_file_path_save_Rpeak.setPlainText(
str((Path(self.root_path) /
Filename.PATH_PSG_ALIGNED /
Path(str(self.sampID)) /
Path(Filename.RPEAK_SYNC +
str(self.ui.spinBox_input_freq_ECG.value()) +
Params.ENDSWITH_TXT))))
class MainWindow_precisely_align(QMainWindow):
@ -860,14 +825,17 @@ class MainWindow_precisely_align(QMainWindow):
total_rows = len(DataFrame(self.data.res_orgBcg.reshape(-1)))
chunk_size = Params.PRECISELY_ALIGN_SAVE_CHUNK_SIZE
with open(Config["Path"]["Save_OrgBCG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.res_orgBcg.reshape(-1)).iloc[start:end]
result = self.data.save_res_orgBcg(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
try:
with open(Config["Path"]["Save_OrgBCG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.res_orgBcg.reshape(-1)).iloc[start:end]
result = self.data.save_res_orgBcg(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
except FileNotFoundError as e:
result = Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
if not result.status:
PublicFunc.text_output(self.ui, "(2/6)" + result.info, Constants.TIPS_TYPE_ERROR)
@ -882,14 +850,17 @@ class MainWindow_precisely_align(QMainWindow):
total_rows = len(DataFrame(self.data.res_BCG.reshape(-1)))
chunk_size = Params.PRECISELY_ALIGN_SAVE_CHUNK_SIZE
with open(Config["Path"]["Save_BCG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.res_BCG.reshape(-1)).iloc[start:end]
result = self.data.save_res_BCG(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
try:
with open(Config["Path"]["Save_BCG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.res_BCG.reshape(-1)).iloc[start:end]
result = self.data.save_res_BCG(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
except FileNotFoundError as e:
result = Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
if not result.status:
PublicFunc.text_output(self.ui, "(3/6)" + result.info, Constants.TIPS_TYPE_ERROR)
@ -904,14 +875,17 @@ class MainWindow_precisely_align(QMainWindow):
total_rows = len(DataFrame(self.data.cut_ECG.reshape(-1)))
chunk_size = Params.PRECISELY_ALIGN_SAVE_CHUNK_SIZE
with open(Config["Path"]["Save_ECG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_ECG.reshape(-1)).iloc[start:end]
result = self.data.save_cut_ECG(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
try:
with open(Config["Path"]["Save_ECG"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_ECG.reshape(-1)).iloc[start:end]
result = self.data.save_cut_ECG(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
except FileNotFoundError as e:
result = Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
if not result.status:
PublicFunc.text_output(self.ui, "(4/6)" + result.info, Constants.TIPS_TYPE_ERROR)
@ -926,14 +900,17 @@ class MainWindow_precisely_align(QMainWindow):
total_rows = len(DataFrame(self.data.cut_Jpeak.reshape(-1)))
chunk_size = Params.PRECISELY_ALIGN_SAVE_PEAK_CHUNK_SIZE
with open(Config["Path"]["Save_Jpeak"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_Jpeak.reshape(-1)).iloc[start:end]
result = self.data.save_Jpeak(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
try:
with open(Config["Path"]["Save_Jpeak"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_Jpeak.reshape(-1)).iloc[start:end]
result = self.data.save_Jpeak(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
except FileNotFoundError as e:
result = Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
if not result.status:
PublicFunc.text_output(self.ui, "(5/6)" + result.info, Constants.TIPS_TYPE_ERROR)
@ -948,14 +925,17 @@ class MainWindow_precisely_align(QMainWindow):
total_rows = len(DataFrame(self.data.cut_Rpeak.reshape(-1)))
chunk_size = Params.PRECISELY_ALIGN_SAVE_PEAK_CHUNK_SIZE
with open(Config["Path"]["Save_Rpeak"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_Rpeak.reshape(-1)).iloc[start:end]
result = self.data.save_Rpeak(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
try:
with open(Config["Path"]["Save_Rpeak"], 'w') as f:
for start in range(0, total_rows, chunk_size):
end = min(start + chunk_size, total_rows)
chunk = DataFrame(self.data.cut_Rpeak.reshape(-1)).iloc[start:end]
result = self.data.save_Rpeak(chunk)
progress = int((end / total_rows) * 100)
self.progressbar.setValue(progress)
QApplication.processEvents()
except FileNotFoundError as e:
result = Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
if not result.status:
PublicFunc.text_output(self.ui, "(6/6)" + result.info, Constants.TIPS_TYPE_ERROR)
@ -2065,8 +2045,6 @@ class Data:
DataFrame(save_data).to_csv(Config["Path"]["Save_AlignInfo"], index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -2091,8 +2069,6 @@ class Data:
chunk.to_csv(Config["Path"]["Save_OrgBCG"], mode='a', index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -2112,8 +2088,6 @@ class Data:
chunk.to_csv(Config["Path"]["Save_BCG"], mode='a', index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -2133,8 +2107,6 @@ class Data:
chunk.to_csv(Config["Path"]["Save_ECG"], mode='a', index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -2154,8 +2126,6 @@ class Data:
chunk.to_csv(Config["Path"]["Save_Jpeak"], mode='a', index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())
@ -2175,8 +2145,6 @@ class Data:
chunk.to_csv(Config["Path"]["Save_Rpeak"], mode='a', index=False, header=False)
except PermissionError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_Permission_Denied"])
except FileNotFoundError as e:
return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Save_File_Not_Found"])
except Exception as e:
return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE +
Constants.FAILURE_REASON["Save_Exception"] + "\n" + format_exc())