优化<数据预处理>的代码
优化<BCG的J峰算法定位>的代码
This commit is contained in:
@ -316,7 +316,7 @@ class MainWindow_preprocess(QMainWindow):
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 数据预处理
|
||||
PublicFunc.progressbar_update(self, 1, 2, Constants.PREPROCESS_PROCESSING_DATA, 0)
|
||||
PublicFunc.progressbar_update(self, 1, 2, Constants.PREPROCESSING_DATA, 0)
|
||||
result = self.data.preprocess()
|
||||
if not result.status:
|
||||
PublicFunc.text_output(self.ui, "(1/2)" + result.info, Constants.TIPS_TYPE_ERROR)
|
||||
@ -388,8 +388,10 @@ class Data:
|
||||
def open_file(self):
|
||||
if Config["Mode"] == "BCG":
|
||||
signal = ConfigParams.ORGBCG_RAW
|
||||
save = ConfigParams.BCG_FILTER
|
||||
elif Config["Mode"] == "ECG":
|
||||
signal = ConfigParams.ECG_RAW
|
||||
save = ConfigParams.ECG_FILTER
|
||||
else:
|
||||
raise ValueError("模式不存在")
|
||||
if Path(Config["Path"]["Input"]).is_file():
|
||||
@ -398,31 +400,14 @@ class Data:
|
||||
if not Path(Config["Path"]["Input"]).exists():
|
||||
return Result().failure(info=Constants.INPUT_FAILURE + Constants.FAILURE_REASON["Path_Not_Exist"])
|
||||
|
||||
temp_path = list(
|
||||
Path(Config["Path"]["Input"]).glob(f"{signal}*"))
|
||||
if len(temp_path) == 0:
|
||||
return Result().failure(
|
||||
info=Constants.INPUT_FAILURE + "\n" +
|
||||
signal + ":" +
|
||||
Config["Path"]["Input"] +
|
||||
Constants.FAILURE_REASON["File_Not_Exist"])
|
||||
elif len(temp_path) > 1:
|
||||
return Result().failure(
|
||||
info=Constants.INPUT_FAILURE + "\n" +
|
||||
signal + ":" +
|
||||
Config["Path"]["Input"] +
|
||||
Constants.FAILURE_REASON["Data_File_More_Than_One"])
|
||||
result = PublicFunc.examine_file(Config["Path"]["Input"], signal)
|
||||
if result.status:
|
||||
Config["Path"]["Input"] = result.data["path"]
|
||||
Config["InputConfig"]["Freq"] = result.data["freq"]
|
||||
Config["Path"]["Save"] = str(
|
||||
Path(Config["Path"]["Save"]) / Path(save + str(Config["OutputConfig"]["Freq"]) + ConfigParams.ENDSWITH_TXT))
|
||||
else:
|
||||
path = temp_path[0]
|
||||
Config["Path"]["Input"] = str(path)
|
||||
freq = path.stem.split("_")[-1]
|
||||
# 验证是否为整数或是否存在
|
||||
if not freq.isdigit():
|
||||
return Result().failure(
|
||||
info=Constants.INPUT_FAILURE + "\n" +
|
||||
signal + ":" +
|
||||
Constants.FAILURE_REASON["Data_Frequency_Not_In_Filename"])
|
||||
Config["InputConfig"]["Freq"] = int(freq)
|
||||
return result
|
||||
|
||||
try:
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
|
||||
Reference in New Issue
Block a user