优化<数据粗同步>的代码
This commit is contained in:
@ -115,7 +115,7 @@ class SettingWindow(QMainWindow):
|
|||||||
"Input_Abd": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
"Input_Abd": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||||
Path(str(self.sampID)))),
|
Path(str(self.sampID)))),
|
||||||
"Save": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
"Save": str((Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||||
Path(str(self.sampID)) / Path(ConfigParams.APPROXIMATELY_ALIGN_SAVE_FILENAME +
|
Path(str(self.sampID)) / Path(ConfigParams.APPROXIMATELY_ALIGN_INFO +
|
||||||
ConfigParams.ENDSWITH_CSV)))
|
ConfigParams.ENDSWITH_CSV)))
|
||||||
},
|
},
|
||||||
"orgBcgConfig": {},
|
"orgBcgConfig": {},
|
||||||
@ -171,28 +171,28 @@ class SettingWindow(QMainWindow):
|
|||||||
str((Path(self.root_path) /
|
str((Path(self.root_path) /
|
||||||
ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
||||||
Path(str(self.sampID)) /
|
Path(str(self.sampID)) /
|
||||||
Path(ConfigParams.APPROXIMATELY_ALIGN_INPUT_ORGBCG_FILENAME +
|
Path(ConfigParams.ORGBCG_RAW +
|
||||||
str(self.ui.spinBox_input_orgBcg_freq.value()) +
|
str(self.ui.spinBox_input_orgBcg_freq.value()) +
|
||||||
ConfigParams.ENDSWITH_TXT))))
|
ConfigParams.ENDSWITH_TXT))))
|
||||||
self.ui.plainTextEdit_file_path_input_Tho.setPlainText(
|
self.ui.plainTextEdit_file_path_input_Tho.setPlainText(
|
||||||
str((Path(self.root_path) /
|
str((Path(self.root_path) /
|
||||||
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||||
Path(str(self.sampID)) /
|
Path(str(self.sampID)) /
|
||||||
Path(ConfigParams.APPROXIMATELY_ALIGN_INPUT_THO_FILENAME +
|
Path(ConfigParams.THO_RAW +
|
||||||
str(self.ui.spinBox_input_Tho_freq.value()) +
|
str(self.ui.spinBox_input_Tho_freq.value()) +
|
||||||
ConfigParams.ENDSWITH_TXT))))
|
ConfigParams.ENDSWITH_TXT))))
|
||||||
self.ui.plainTextEdit_file_path_input_Abd.setPlainText(
|
self.ui.plainTextEdit_file_path_input_Abd.setPlainText(
|
||||||
str((Path(self.root_path) /
|
str((Path(self.root_path) /
|
||||||
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||||
Path(str(self.sampID)) /
|
Path(str(self.sampID)) /
|
||||||
Path(ConfigParams.APPROXIMATELY_ALIGN_INPUT_ABD_FILENAME +
|
Path(ConfigParams.ABD_RAW +
|
||||||
str(self.ui.spinBox_input_Abd_freq.value()) +
|
str(self.ui.spinBox_input_Abd_freq.value()) +
|
||||||
ConfigParams.ENDSWITH_TXT))))
|
ConfigParams.ENDSWITH_TXT))))
|
||||||
self.ui.plainTextEdit_file_path_save.setPlainText(
|
self.ui.plainTextEdit_file_path_save.setPlainText(
|
||||||
str((Path(self.root_path) /
|
str((Path(self.root_path) /
|
||||||
ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
ConfigParams.PUBLIC_PATH_ORGBCG_TEXT /
|
||||||
Path(str(self.sampID)) /
|
Path(str(self.sampID)) /
|
||||||
Path(ConfigParams.APPROXIMATELY_ALIGN_SAVE_FILENAME +
|
Path(ConfigParams.APPROXIMATELY_ALIGN_INFO +
|
||||||
ConfigParams.ENDSWITH_CSV))))
|
ConfigParams.ENDSWITH_CSV))))
|
||||||
|
|
||||||
|
|
||||||
@ -928,87 +928,29 @@ class Data:
|
|||||||
def open_file(self):
|
def open_file(self):
|
||||||
if Path(Config["Path"]["Input_orgBcg"]).is_file():
|
if Path(Config["Path"]["Input_orgBcg"]).is_file():
|
||||||
Config["Path"]["Input_orgBcg"] = str(Path(Config["Path"]["Input_orgBcg"]).parent)
|
Config["Path"]["Input_orgBcg"] = str(Path(Config["Path"]["Input_orgBcg"]).parent)
|
||||||
|
|
||||||
if not Path(Config["Path"]["Input_orgBcg"]).exists():
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "orgBcg: " + Config["Path"]["Input_orgBcg"] + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_Path_Not_Exist"])
|
|
||||||
temp_orgBcg_path = list(
|
|
||||||
Path(Config["Path"]["Input_orgBcg"]).glob(f"{ConfigParams.APPROXIMATELY_ALIGN_INPUT_ORGBCG_FILENAME}*"))
|
|
||||||
if len(temp_orgBcg_path) == 0:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "orgBcg: " + Config["Path"]["Input_orgBcg"] + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_Not_Exist"])
|
|
||||||
elif len(temp_orgBcg_path) > 1:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_More_Than_One"])
|
|
||||||
else:
|
|
||||||
orgBcg_path = temp_orgBcg_path[0]
|
|
||||||
Config["Path"]["Input_orgBcg"] = str(orgBcg_path)
|
|
||||||
orgBcg_freq = orgBcg_path.stem.split("_")[-1]
|
|
||||||
# 验证是否为整数或是否存在
|
|
||||||
if not orgBcg_freq.isdigit():
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_Frequency_Not_In_Filename"])
|
|
||||||
Config["InputConfig"]["orgBcgFreq"] = int(orgBcg_freq)
|
|
||||||
if Path(Config["Path"]["Input_Tho"]).is_file():
|
if Path(Config["Path"]["Input_Tho"]).is_file():
|
||||||
Config["Path"]["Input_Tho"] = str(Path(Config["Path"]["Input_Tho"]).parent)
|
Config["Path"]["Input_Tho"] = str(Path(Config["Path"]["Input_Tho"]).parent)
|
||||||
|
|
||||||
if not Path(Config["Path"]["Input_Tho"]).exists():
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Tho: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_Path_Not_Exist"])
|
|
||||||
temp_Tho_path = list(
|
|
||||||
Path(Config["Path"]["Input_Tho"]).glob(f"{ConfigParams.APPROXIMATELY_ALIGN_INPUT_THO_FILENAME}*"))
|
|
||||||
if len(temp_Tho_path) == 0:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Tho: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_Not_Exist"])
|
|
||||||
elif len(temp_Tho_path) > 1:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Tho: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_More_Than_One"])
|
|
||||||
else:
|
|
||||||
tho_path = temp_Tho_path[0]
|
|
||||||
Config["Path"]["Input_Tho"] = str(tho_path)
|
|
||||||
tho_freq = tho_path.stem.split("_")[-1]
|
|
||||||
# 验证是否为整数或是否存在
|
|
||||||
if not tho_freq.isdigit():
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Tho: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_Frequency_Not_In_Filename"])
|
|
||||||
Config["InputConfig"]["ThoFreq"] = int(tho_freq)
|
|
||||||
|
|
||||||
if Path(Config["Path"]["Input_Abd"]).is_file():
|
if Path(Config["Path"]["Input_Abd"]).is_file():
|
||||||
Config["Path"]["Input_Abd"] = str(Path(Config["Path"]["Input_Abd"]).parent)
|
Config["Path"]["Input_Abd"] = str(Path(Config["Path"]["Input_Abd"]).parent)
|
||||||
|
|
||||||
if not Path(Config["Path"]["Input_Abd"]).exists():
|
result = PublicFunc.examine_file(Config["Path"]["Input_orgBcg"], ConfigParams.ORGBCG_RAW)
|
||||||
return Result().failure(
|
if result.status:
|
||||||
info=Constants.INPUT_FAILURE + "Abd: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
Config["Path"]["Input_orgBcg"] = result.data["path"]
|
||||||
"Data_Path_Not_Exist"])
|
Config["InputConfig"]["orgBcgFreq"] = result.data["freq"]
|
||||||
|
|
||||||
temp_Abd_path = list(
|
|
||||||
Path(Config["Path"]["Input_Abd"]).glob(f"{ConfigParams.APPROXIMATELY_ALIGN_INPUT_ABD_FILENAME}*"))
|
|
||||||
if len(temp_Abd_path) == 0:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Abd: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_Not_Exist"])
|
|
||||||
elif len(temp_Abd_path) > 1:
|
|
||||||
return Result().failure(
|
|
||||||
info=Constants.INPUT_FAILURE + "Abd: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
|
||||||
"Data_File_More_Than_One"])
|
|
||||||
else:
|
else:
|
||||||
abd_path = temp_Abd_path[0]
|
return result
|
||||||
Config["Path"]["Input_Abd"] = str(abd_path)
|
result = PublicFunc.examine_file(Config["Path"]["Input_Tho"], ConfigParams.THO_RAW)
|
||||||
abd_freq = abd_path.stem.split("_")[-1]
|
if result.status:
|
||||||
# 验证是否为整数或是否存在
|
Config["Path"]["Input_Tho"] = result.data["path"]
|
||||||
if not abd_freq.isdigit():
|
Config["InputConfig"]["ThoFreq"] = result.data["freq"]
|
||||||
return Result().failure(
|
else:
|
||||||
info=Constants.INPUT_FAILURE + "Abd: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
return result
|
||||||
"Data_Frequency_Not_In_Filename"])
|
result = PublicFunc.examine_file(Config["Path"]["Input_Abd"], ConfigParams.ABD_RAW)
|
||||||
Config["InputConfig"]["AbdFreq"] = int(abd_freq)
|
if result.status:
|
||||||
|
Config["Path"]["Input_Abd"] = result.data["path"]
|
||||||
|
Config["InputConfig"]["AbdFreq"] = result.data["freq"]
|
||||||
|
else:
|
||||||
|
return result
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.raw_orgBcg = read_csv(Config["Path"]["Input_orgBcg"],
|
self.raw_orgBcg = read_csv(Config["Path"]["Input_orgBcg"],
|
||||||
@ -1021,8 +963,8 @@ class Data:
|
|||||||
encoding=ConfigParams.UTF8_ENCODING,
|
encoding=ConfigParams.UTF8_ENCODING,
|
||||||
header=None).to_numpy().reshape(-1)
|
header=None).to_numpy().reshape(-1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Read_Data_Exception"] + "\n" + format_exc())
|
"Open_Data_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.INPUT_FINISHED)
|
return Result().success(info=Constants.INPUT_FINISHED)
|
||||||
|
|
||||||
@ -1034,7 +976,7 @@ class Data:
|
|||||||
df = DataFrame({"pos": [pos], "epoch": [epoch], "ApplyFrequency": [ApplyFrequency]})
|
df = DataFrame({"pos": [pos], "epoch": [epoch], "ApplyFrequency": [ApplyFrequency]})
|
||||||
df.to_csv(Path(Config["Path"]["Save"]), mode="w", header=True, index=False)
|
df.to_csv(Path(Config["Path"]["Save"]), mode="w", header=True, index=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(info=Constants.SAVING_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
return Result().failure(info=Constants.SAVING_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Save_Exception"] + "\n" + format_exc())
|
"Save_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.SAVING_FINISHED)
|
return Result().success(info=Constants.SAVING_FINISHED)
|
||||||
@ -1043,8 +985,8 @@ class Data:
|
|||||||
# 仅重采样
|
# 仅重采样
|
||||||
if self.raw_orgBcg is None or self.raw_Tho is None or self.raw_Abd is None:
|
if self.raw_orgBcg is None or self.raw_Tho is None or self.raw_Abd is None:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Raw_Data_Not_Exist"])
|
"Data_Not_Exist"])
|
||||||
try:
|
try:
|
||||||
# 按照秒数进行截断
|
# 按照秒数进行截断
|
||||||
self.raw_orgBcg = self.raw_orgBcg[:int(Config["orgBcg_seconds"] * Config["InputConfig"]["orgBcgFreq"])]
|
self.raw_orgBcg = self.raw_orgBcg[:int(Config["orgBcg_seconds"] * Config["InputConfig"]["orgBcgFreq"])]
|
||||||
@ -1057,7 +999,7 @@ class Data:
|
|||||||
self.processed_Abd = resample(self.raw_Abd, int(Config["PSG_seconds"] * Config["ApplyFrequency"]))
|
self.processed_Abd = resample(self.raw_Abd, int(Config["PSG_seconds"] * Config["ApplyFrequency"]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Only_Resample_Exception"] + "\n" + format_exc())
|
"Only_Resample_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FINISHED)
|
||||||
@ -1072,8 +1014,8 @@ class Data:
|
|||||||
|
|
||||||
if self.raw_orgBcg is None or self.raw_Tho is None or self.raw_Abd is None:
|
if self.raw_orgBcg is None or self.raw_Tho is None or self.raw_Abd is None:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Raw_Data_Not_Exist"])
|
"Data_Not_Exist"])
|
||||||
try:
|
try:
|
||||||
# 滤波
|
# 滤波
|
||||||
self.processed_orgBcg = butter_bandpass_filter(
|
self.processed_orgBcg = butter_bandpass_filter(
|
||||||
@ -1093,7 +1035,7 @@ class Data:
|
|||||||
Config["Filter"]["BandPassOrder"])
|
Config["Filter"]["BandPassOrder"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_RESP_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_RESP_GET_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Resp_Get_Exception"] + "\n" + format_exc())
|
"Resp_Get_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_RESP_GET_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_RESP_GET_FINISHED)
|
||||||
@ -1118,7 +1060,7 @@ class Data:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Pre_Resample_Exception"] + "\n" + format_exc())
|
"Pre_Resample_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_PRE_ALIGN_RESAMPLE_FINISHED)
|
||||||
@ -1138,7 +1080,7 @@ class Data:
|
|||||||
self.processed_orgBcg, ones(int(4 * temp_frequency)) / int(4 * temp_frequency), mode='same')
|
self.processed_orgBcg, ones(int(4 * temp_frequency)) / int(4 * temp_frequency), mode='same')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_DELETE_BASE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_DELETE_BASE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Delete_Base_Exception"] + "\n" + format_exc())
|
"Delete_Base_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_DELETE_BASE_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_DELETE_BASE_FINISHED)
|
||||||
@ -1155,7 +1097,7 @@ class Data:
|
|||||||
self.processed_orgBcg)
|
self.processed_orgBcg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_STANDARDIZE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_STANDARDIZE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Standardize_Exception"] + "\n" + format_exc())
|
"Standardize_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_STANDARDIZE_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_STANDARDIZE_FINISHED)
|
||||||
@ -1170,7 +1112,7 @@ class Data:
|
|||||||
self.processed_downsample_orgBcg = self.processed_orgBcg[::int(temp_frequency / Config["ApplyFrequency"])]
|
self.processed_downsample_orgBcg = self.processed_orgBcg[::int(temp_frequency / Config["ApplyFrequency"])]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Resample_Exception"] + "\n" + format_exc())
|
"Resample_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FINISHED)
|
return Result().success(info=Constants.APPROXIMATELY_ALIGN_RESAMPLE_FINISHED)
|
||||||
@ -1197,7 +1139,7 @@ class Data:
|
|||||||
result = {"tho_relate": tho_relate, "tho_relate2": tho_relate2}
|
result = {"tho_relate": tho_relate, "tho_relate2": tho_relate2}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE +
|
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE +
|
||||||
Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
Constants.FAILURE_REASON[
|
||||||
"Calculate_Correlation1_Exception"] + "\n" + format_exc())
|
"Calculate_Correlation1_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FINISHED, data=result)
|
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE1_FINISHED, data=result)
|
||||||
@ -1222,7 +1164,7 @@ class Data:
|
|||||||
result = {"abd_relate": abd_relate, "abd_relate2": abd_relate2}
|
result = {"abd_relate": abd_relate, "abd_relate2": abd_relate2}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE +
|
return Result().failure(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE +
|
||||||
Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
Constants.FAILURE_REASON[
|
||||||
"Calculate_Correlation2_Exception"] + "\n" + format_exc())
|
"Calculate_Correlation2_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FINISHED, data=result)
|
return Result().success(info=Constants.APPROXIMATELY_CORRELATION_CALCULATE2_FINISHED, data=result)
|
||||||
@ -1241,7 +1183,7 @@ class Data:
|
|||||||
result = {"tho_max": tho_max, "tho_max2": tho_max2, "abd_max": abd_max, "abd_max2": abd_max2, "bias": bias}
|
result = {"tho_max": tho_max, "tho_max2": tho_max2, "abd_max": abd_max, "abd_max2": abd_max2, "bias": bias}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE +
|
return Result().failure(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE +
|
||||||
Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
Constants.FAILURE_REASON[
|
||||||
"Calculate_Maxvalue_Pos_Exception"] + "\n" + format_exc())
|
"Calculate_Maxvalue_Pos_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FINISHED, data=result)
|
return Result().success(info=Constants.APPROXIMATELY_MAXVALUE_POS_CALCULATE_FINISHED, data=result)
|
||||||
@ -1257,7 +1199,7 @@ class Data:
|
|||||||
result = {"epoch_min": epoch_min, "epoch_max": epoch_max}
|
result = {"epoch_min": epoch_min, "epoch_max": epoch_max}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Get_Epoch_Exception"] + "\n" + format_exc())
|
"Get_Epoch_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
|
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
|
||||||
@ -1307,7 +1249,7 @@ class Data:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Result().failure(
|
return Result().failure(
|
||||||
info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
|
info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.FAILURE_REASON[
|
||||||
"Get_Corr_By_Epoch"] + "\n" + format_exc())
|
"Get_Corr_By_Epoch_Exception"] + "\n" + format_exc())
|
||||||
|
|
||||||
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
|
return Result().success(info=Constants.APPROXIMATELY_EPOCH_GET_FINISHED, data=result)
|
||||||
|
|||||||
@ -29,6 +29,7 @@ class ConfigParams:
|
|||||||
ACTION_ZOOM_SHORTCUT_KEY: str = "C"
|
ACTION_ZOOM_SHORTCUT_KEY: str = "C"
|
||||||
FONT: str = "Microsoft YaHei UI"
|
FONT: str = "Microsoft YaHei UI"
|
||||||
|
|
||||||
|
# 文件命名
|
||||||
ORGBCG_RAW: str = "OrgBCG_Raw_"
|
ORGBCG_RAW: str = "OrgBCG_Raw_"
|
||||||
ECG_RAW: str = "ECG II_Raw_"
|
ECG_RAW: str = "ECG II_Raw_"
|
||||||
THO_RAW: str = "Effort Tho_Raw_"
|
THO_RAW: str = "Effort Tho_Raw_"
|
||||||
@ -38,6 +39,8 @@ class ConfigParams:
|
|||||||
SNORE_RAW: str = "Snore_Raw_"
|
SNORE_RAW: str = "Snore_Raw_"
|
||||||
SPO2_RAW: str = "SpO2_Raw_"
|
SPO2_RAW: str = "SpO2_Raw_"
|
||||||
FIVE_CLASS_RAW: str = "5_class_Raw_"
|
FIVE_CLASS_RAW: str = "5_class_Raw_"
|
||||||
|
STARTTIME_RAW: str = "StartTime_Raw_"
|
||||||
|
SA_LABEL_RAW: str = "SA Label_Raw_"
|
||||||
BCG_FILTER: str = "BCG_Filter_"
|
BCG_FILTER: str = "BCG_Filter_"
|
||||||
ECG_FILTER: str = "ECG_Filter_"
|
ECG_FILTER: str = "ECG_Filter_"
|
||||||
JPEAK_REVISE: str = "Jpeak_revise_"
|
JPEAK_REVISE: str = "Jpeak_revise_"
|
||||||
@ -46,8 +49,11 @@ class ConfigParams:
|
|||||||
RPEAK_FINAL_CORRECTED: str = "Rpeak_final_corrected_"
|
RPEAK_FINAL_CORRECTED: str = "Rpeak_final_corrected_"
|
||||||
APPROXIMATELY_ALIGN_INFO: str = "Approximately_Align_Info"
|
APPROXIMATELY_ALIGN_INFO: str = "Approximately_Align_Info"
|
||||||
PRECISELY_ALIGN_INFO: str = "Precisely_Align_Info"
|
PRECISELY_ALIGN_INFO: str = "Precisely_Align_Info"
|
||||||
ORGBCG_SYNC: str = "OrgBCG_Sync_"
|
BCG_SYNC: str = "BCG_Sync_"
|
||||||
ECG_SYNC: str = "ECG_Sync_"
|
ECG_SYNC: str = "ECG_Sync_"
|
||||||
|
JPEAK_SYNC: str = "Jpeak_Sync_"
|
||||||
|
RPEAK_SYNC: str = "Rpeak_Sync_"
|
||||||
|
ORGBCG_SYNC: str = "OrgBCG_Sync_"
|
||||||
THO_SYNC: str = "Effort Tho_Sync_"
|
THO_SYNC: str = "Effort Tho_Sync_"
|
||||||
ABD_SYNC: str = "Effort Abd_Sync_"
|
ABD_SYNC: str = "Effort Abd_Sync_"
|
||||||
FLOWT_SYNC: str = "Flow T_Sync_"
|
FLOWT_SYNC: str = "Flow T_Sync_"
|
||||||
@ -55,12 +61,7 @@ class ConfigParams:
|
|||||||
SNORE_SYNC: str = "Snore_Sync_"
|
SNORE_SYNC: str = "Snore_Sync_"
|
||||||
SPO2_SYNC: str = "SpO2_Sync_"
|
SPO2_SYNC: str = "SpO2_Sync_"
|
||||||
FIVE_CLASS_SYNC: str = "5_class_Sync_"
|
FIVE_CLASS_SYNC: str = "5_class_Sync_"
|
||||||
BCG_SYNC: str = "BCG_Sync_"
|
SA_LABEL_SYNC: str = "SA Label_Sync_"
|
||||||
ECG_SYNC: str = "ECG_Sync_"
|
|
||||||
JPEAK_SYNC: str = "Jpeak_Sync_"
|
|
||||||
RPEAK_SYNC: str = "Rpeak_Sync_"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 数据粗同步
|
# 数据粗同步
|
||||||
APPROXIMATELY_ALIGN_CONFIG_FILE_PATH: str = "./config/Config_approximately_align.yaml"
|
APPROXIMATELY_ALIGN_CONFIG_FILE_PATH: str = "./config/Config_approximately_align.yaml"
|
||||||
@ -83,10 +84,6 @@ class ConfigParams:
|
|||||||
"window_epoch": 6
|
"window_epoch": 6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
APPROXIMATELY_ALIGN_INPUT_ORGBCG_FILENAME: str = "OrgBCG_Raw_"
|
|
||||||
APPROXIMATELY_ALIGN_INPUT_THO_FILENAME: str = "Effort Tho_Raw_"
|
|
||||||
APPROXIMATELY_ALIGN_INPUT_ABD_FILENAME: str = "Effort Abd_Raw_"
|
|
||||||
APPROXIMATELY_ALIGN_SAVE_FILENAME: str = "Approximately_Align_Info"
|
|
||||||
|
|
||||||
# 预处理
|
# 预处理
|
||||||
PREPROCESS_CONFIG_FILE_PATH: str = "./config/Config_preprocess.yaml"
|
PREPROCESS_CONFIG_FILE_PATH: str = "./config/Config_preprocess.yaml"
|
||||||
@ -200,9 +197,9 @@ class ConfigParams:
|
|||||||
"5_class": FIVE_CLASS_RAW
|
"5_class": FIVE_CLASS_RAW
|
||||||
},
|
},
|
||||||
"LabelInput": {
|
"LabelInput": {
|
||||||
"SA Label": "SA Label_Raw"
|
"SA Label": SA_LABEL_RAW
|
||||||
},
|
},
|
||||||
"StartTime": "StartTime_Raw",
|
"StartTime": STARTTIME_RAW,
|
||||||
"ChannelSave": {
|
"ChannelSave": {
|
||||||
"Effort Tho": THO_SYNC,
|
"Effort Tho": THO_SYNC,
|
||||||
"Effort Abd": ABD_SYNC,
|
"Effort Abd": ABD_SYNC,
|
||||||
@ -213,7 +210,7 @@ class ConfigParams:
|
|||||||
"5_class": FIVE_CLASS_SYNC
|
"5_class": FIVE_CLASS_SYNC
|
||||||
},
|
},
|
||||||
"LabelSave": {
|
"LabelSave": {
|
||||||
"SA Label": "SA Label_Sync"
|
"SA Label": SA_LABEL_SYNC
|
||||||
},
|
},
|
||||||
"EndWith": {
|
"EndWith": {
|
||||||
"Effort Tho": ENDSWITH_TXT,
|
"Effort Tho": ENDSWITH_TXT,
|
||||||
@ -231,6 +228,9 @@ class ConfigParams:
|
|||||||
CUT_PSG_SALABEL_EVENT: list = ["Hypopnea", "Central apnea", "Obstructive apnea", "Mixed apnea"]
|
CUT_PSG_SALABEL_EVENT: list = ["Hypopnea", "Central apnea", "Obstructive apnea", "Mixed apnea"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 体动标注
|
# 体动标注
|
||||||
ARTIFACT_LABEL_CONFIG_FILE_PATH: str = "./config/Config_artifact_label.yaml"
|
ARTIFACT_LABEL_CONFIG_FILE_PATH: str = "./config/Config_artifact_label.yaml"
|
||||||
ARTIFACT_LABEL_CONFIG_NEW_CONTENT: dict = {
|
ARTIFACT_LABEL_CONFIG_NEW_CONTENT: dict = {
|
||||||
|
|||||||
@ -103,6 +103,17 @@ class Constants:
|
|||||||
"Process_Exception": "(处理异常)",
|
"Process_Exception": "(处理异常)",
|
||||||
"Preprocess_Exception": "(预处理异常)",
|
"Preprocess_Exception": "(预处理异常)",
|
||||||
"Save_Exception": "(保存异常)",
|
"Save_Exception": "(保存异常)",
|
||||||
|
"Only_Resample_Exception": "(仅重采样异常)",
|
||||||
|
"Resp_Get_Exception": "(呼吸提取异常)",
|
||||||
|
"Pre_Resample_Exception": "(预重采样异常)",
|
||||||
|
"Delete_Base_Exception": "(去基线异常)",
|
||||||
|
"Standardize_Exception": "(标准化异常)",
|
||||||
|
"Resample_Exception": "(重采样异常)",
|
||||||
|
"Calculate_Correlation1_Exception": "(计算互相关1/2异常)",
|
||||||
|
"Calculate_Correlation2_Exception": "(计算互相关2/2异常)",
|
||||||
|
"Calculate_Maxvalue_Pos_Exception": "(计算最大值位置异常)",
|
||||||
|
"Get_Epoch_Exception": "(获取epoch异常)",
|
||||||
|
"Get_Corr_By_Epoch_Exception": "(通过epoch获取相关性异常)",
|
||||||
"Predict_Exception": "(预测异常)",
|
"Predict_Exception": "(预测异常)",
|
||||||
"Read_Model_Exception": "(读取模型异常)",
|
"Read_Model_Exception": "(读取模型异常)",
|
||||||
"Calculate_Correlation_Value_Equal": "(计算相关性参数相同)",
|
"Calculate_Correlation_Value_Equal": "(计算相关性参数相同)",
|
||||||
@ -121,6 +132,47 @@ class Constants:
|
|||||||
"cut_Rpeak_Not_Exist": "(切割后R峰不存在)"
|
"cut_Rpeak_Not_Exist": "(切割后R峰不存在)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 数据粗同步
|
||||||
|
APPROXIMATELY_ONLY_ALIGN_RESAMPLING: str = "正在仅重采样"
|
||||||
|
APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FINISHED: str = "仅重采样完成"
|
||||||
|
APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE: str = "仅重采样失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_RESP_GETTING: str = "正在呼吸提取"
|
||||||
|
APPROXIMATELY_RESP_GET_FINISHED: str = "呼吸提取完成"
|
||||||
|
APPROXIMATELY_RESP_GET_FAILURE: str = "呼吸提取失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_PRE_ALIGN_RESAMPLING: str = "正在预重采样"
|
||||||
|
APPROXIMATELY_PRE_ALIGN_RESAMPLE_FINISHED: str = "预重采样完成"
|
||||||
|
APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE: str = "预重采样失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_DELETING_BASE: str = "正在去基线"
|
||||||
|
APPROXIMATELY_DELETE_BASE_FINISHED: str = "去基线完成"
|
||||||
|
APPROXIMATELY_DELETE_BASE_FAILURE: str = "去基线失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_STANDARDIZING: str = "正在标准化"
|
||||||
|
APPROXIMATELY_STANDARDIZE_FINISHED: str = "标准化完成"
|
||||||
|
APPROXIMATELY_STANDARDIZE_FAILURE: str = "标准化失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_ALIGN_RESAMPLING: str = "正在重采样"
|
||||||
|
APPROXIMATELY_ALIGN_RESAMPLE_FINISHED: str = "重采样完成"
|
||||||
|
APPROXIMATELY_ALIGN_RESAMPLE_FAILURE: str = "重采样失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATING1: str = "正在计算互相关1/2"
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATE1_FINISHED: str = "计算互相关1/2完成"
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE: str = "计算互相关1/2失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATING2: str = "正在计算互相关2/2"
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATE2_FINISHED: str = "计算互相关2/2完成"
|
||||||
|
APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE: str = "计算互相关2/2失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_MAXVALUE_POS_CALCULATING: str = "正在计算最大值位置"
|
||||||
|
APPROXIMATELY_MAXVALUE_POS_CALCULATE_FINISHED: str = "计算最大值位置完成"
|
||||||
|
APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE: str = "计算最大值位置失败"
|
||||||
|
|
||||||
|
APPROXIMATELY_EPOCH_GETTING: str = "正在获取epoch"
|
||||||
|
APPROXIMATELY_EPOCH_GET_FINISHED: str = "获取epoch完成"
|
||||||
|
APPROXIMATELY_EPOCH_GET_FAILURE: str = "获取epoch失败"
|
||||||
|
|
||||||
# 预处理
|
# 预处理
|
||||||
PREPROCESS_PLOT_LABEL_ORIGINAL_DATA: str = "Original_Data"
|
PREPROCESS_PLOT_LABEL_ORIGINAL_DATA: str = "Original_Data"
|
||||||
PREPROCESS_PLOT_LABEL_PROCESSED_DATA: str = "Processed_Data"
|
PREPROCESS_PLOT_LABEL_PROCESSED_DATA: str = "Processed_Data"
|
||||||
@ -251,67 +303,7 @@ class Constants:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 数据粗同步
|
|
||||||
APPROXIMATELY_ONLY_ALIGN_RESAMPLING: str = "正在仅重采样"
|
|
||||||
APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FINISHED: str = "仅重采样完成"
|
|
||||||
APPROXIMATELY_ONLY_ALIGN_RESAMPLE_FAILURE: str = "仅重采样失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_RESP_GETTING: str = "正在呼吸提取"
|
|
||||||
APPROXIMATELY_RESP_GET_FINISHED: str = "呼吸提取完成"
|
|
||||||
APPROXIMATELY_RESP_GET_FAILURE: str = "呼吸提取失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_PRE_ALIGN_RESAMPLING: str = "正在预重采样"
|
|
||||||
APPROXIMATELY_PRE_ALIGN_RESAMPLE_FINISHED: str = "预重采样完成"
|
|
||||||
APPROXIMATELY_PRE_ALIGN_RESAMPLE_FAILURE: str = "预重采样失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_DELETING_BASE: str = "正在去基线"
|
|
||||||
APPROXIMATELY_DELETE_BASE_FINISHED: str = "去基线完成"
|
|
||||||
APPROXIMATELY_DELETE_BASE_FAILURE: str = "去基线失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_STANDARDIZING: str = "正在标准化"
|
|
||||||
APPROXIMATELY_STANDARDIZE_FINISHED: str = "标准化完成"
|
|
||||||
APPROXIMATELY_STANDARDIZE_FAILURE: str = "标准化失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_ALIGN_RESAMPLING: str = "正在重采样"
|
|
||||||
APPROXIMATELY_ALIGN_RESAMPLE_FINISHED: str = "重采样完成"
|
|
||||||
APPROXIMATELY_ALIGN_RESAMPLE_FAILURE: str = "重采样失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATING1: str = "正在计算互相关1/2"
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATE1_FINISHED: str = "计算互相关1/2完成"
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATE1_FAILURE: str = "计算互相关1/2失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATING2: str = "正在计算互相关2/2"
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATE2_FINISHED: str = "计算互相关2/2完成"
|
|
||||||
APPROXIMATELY_CORRELATION_CALCULATE2_FAILURE: str = "计算互相关2/2失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_MAXVALUE_POS_CALCULATING: str = "正在计算最大值位置"
|
|
||||||
APPROXIMATELY_MAXVALUE_POS_CALCULATE_FINISHED: str = "计算最大值位置完成"
|
|
||||||
APPROXIMATELY_MAXVALUE_POS_CALCULATE_FAILURE: str = "计算最大值位置失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_EPOCH_GETTING: str = "正在获取epoch"
|
|
||||||
APPROXIMATELY_EPOCH_GET_FINISHED: str = "获取epoch完成"
|
|
||||||
APPROXIMATELY_EPOCH_GET_FAILURE: str = "获取epoch失败"
|
|
||||||
|
|
||||||
APPROXIMATELY_ALIGN_FAILURE_REASON = {
|
|
||||||
"Data_Path_Not_Exist": "(路径不存在)",
|
|
||||||
"Data_File_Not_Exist": "(数据文件不存在)",
|
|
||||||
"Data_File_More_Than_One": "(数据文件超过一个)",
|
|
||||||
"Data_Frequency_Not_In_Filename": "(数据频率不在文件名中)",
|
|
||||||
"Read_Data_Exception": "(读取数据异常)",
|
|
||||||
"Raw_Data_Not_Exist": "(原始数据不存在)",
|
|
||||||
"Only_Resample_Exception": "(仅重采样异常)",
|
|
||||||
"Resp_Get_Exception": "(呼吸提取异常)",
|
|
||||||
"Pre_Resample_Exception": "(预重采样异常)",
|
|
||||||
"Delete_Base_Exception": "(去基线异常)",
|
|
||||||
"Standardize_Exception": "(标准化异常)",
|
|
||||||
"Resample_Exception": "(重采样异常)",
|
|
||||||
"Calculate_Correlation1_Exception": "(计算互相关1/2异常)",
|
|
||||||
"Calculate_Correlation2_Exception": "(计算互相关2/2异常)",
|
|
||||||
"Calculate_Maxvalue_Pos_Exception": "(计算最大值位置异常)",
|
|
||||||
"Get_Epoch_Exception": "(获取epoch异常)",
|
|
||||||
"Processed_Data_Not_Exist": "(处理后数据不存在)",
|
|
||||||
"Save_Exception": "(保存异常)"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 体动标注
|
# 体动标注
|
||||||
ARTIFACT_LABEL_LOADING_ARCHIVE: str = "正在获取历史存档"
|
ARTIFACT_LABEL_LOADING_ARCHIVE: str = "正在获取历史存档"
|
||||||
|
|||||||
Reference in New Issue
Block a user