diff --git a/README.md b/README.md index b38f597..15e2934 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ 6、<呼吸可用性及间期标注>的体动显示做一个和一样的可以根据勾选来显示需要显示的体动 -7、各个模块中的检测父级文件夹是否存在的功能仍存在问题,无法正确创建文件夹 +~~7、各个模块中的检测父级文件夹是否存在的功能仍存在问题,无法正确创建文件夹~~ ## 1、主菜单 diff --git a/func/Module_SA_label.py b/func/Module_SA_label.py index a92237f..acc017f 100644 --- a/func/Module_SA_label.py +++ b/func/Module_SA_label.py @@ -1590,9 +1590,6 @@ class Data: return Result().success(info=Constants.RESAMPLE_FINISHED) def save(self): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if self.df_corrected is None: return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_approximately_align.py b/func/Module_approximately_align.py index b0b8a8f..8d4b482 100644 --- a/func/Module_approximately_align.py +++ b/func/Module_approximately_align.py @@ -964,8 +964,6 @@ class Data: return Result().success(info=Constants.INPUT_FINISHED) def save(self, epoch): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) try: pos = Config["pos"] ApplyFrequency = Config["ApplyFrequency"] diff --git a/func/Module_artifact_label.py b/func/Module_artifact_label.py index f092361..4c946ae 100644 --- a/func/Module_artifact_label.py +++ b/func/Module_artifact_label.py @@ -1378,13 +1378,6 @@ class Data: return Result().success(info=Constants.ARCHIVE_EXIST) def save(self, amount, duration): - if (not Path(Config["Path"]["Save_a"]).parent.exists()) or (not Path(Config["Path"]["Save_a"]).parent.is_dir()): - Path(Config["Path"]["Save_a"]).parent.mkdir(parents=True, exist_ok=True) - if (not Path(Config["Path"]["Save_b"]).parent.exists()) or (not Path(Config["Path"]["Save_b"]).parent.is_dir()): - Path(Config["Path"]["Save_b"]).parent.mkdir(parents=True, exist_ok=True) - if (not Path(Config["Path"]["Save_c"]).parent.exists()) or (not Path(Config["Path"]["Save_c"]).parent.is_dir()): - Path(Config["Path"]["Save_c"]).parent.mkdir(parents=True, exist_ok=True) - try: # Artifact_a.txt和Artifact_c.csv的内容遍历 output_lines = [] diff --git a/func/Module_bcg_quality_label.py b/func/Module_bcg_quality_label.py index e6f5217..e7deb72 100644 --- a/func/Module_bcg_quality_label.py +++ b/func/Module_bcg_quality_label.py @@ -1085,9 +1085,6 @@ class Data(): return Result().success(info=Constants.PREPROCESS_FINISHED) def save(self, label): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if self.df_label is None: return Result().failure(info=Filename.RESP_QUALITY_LABEL + Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_cut_PSG.py b/func/Module_cut_PSG.py index cedb1d6..1d43c64 100644 --- a/func/Module_cut_PSG.py +++ b/func/Module_cut_PSG.py @@ -323,9 +323,6 @@ class Data: return Result().success(info=Constants.CUT_PSG_ALIGN_LABEL_FINISHED) def save(self): - if (not Path(Config["Path"]["SaveFolder"]).exists()) or (not Path(Config["Path"]["SaveFolder"]).is_dir()): - Path(Config["Path"]["SaveFolder"]).mkdir(parents=True, exist_ok=True) - for raw in self.raw.values(): if len(raw) == 0: return Result().failure(info=Constants.SAVE_FAILURE + diff --git a/func/Module_detect_Jpeak.py b/func/Module_detect_Jpeak.py index de66a0d..11f36ff 100644 --- a/func/Module_detect_Jpeak.py +++ b/func/Module_detect_Jpeak.py @@ -460,9 +460,6 @@ class Data: return Result().success(info=Constants.DETECT_JPEAK_PREDICT_FINISHED) def save(self, chunk): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if self.peak is None: return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_detect_Rpeak.py b/func/Module_detect_Rpeak.py index 76d700e..f884eb4 100644 --- a/func/Module_detect_Rpeak.py +++ b/func/Module_detect_Rpeak.py @@ -452,9 +452,6 @@ class Data: return Result().success(info=Constants.DETECT_RPEAK_PREDICT_FINISHED) def save(self, chunk): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if self.peak is None: return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_label_check.py b/func/Module_label_check.py index 14d5517..55b1a43 100644 --- a/func/Module_label_check.py +++ b/func/Module_label_check.py @@ -960,9 +960,6 @@ class Data: return Result().success(info=Constants.INPUT_FINISHED) def get_archive(self): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if not Path(Config["Path"]["Save"]).exists(): self.corrected_peak = self.original_peak return Result().success(info=Constants.ARCHIVE_NOT_EXIST) diff --git a/func/Module_mainwindow.py b/func/Module_mainwindow.py index 3f62ec0..056972e 100644 --- a/func/Module_mainwindow.py +++ b/func/Module_mainwindow.py @@ -126,6 +126,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.approximately_align.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.approximately_align.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_preprocess__(self): self.preprocess = MainWindow_preprocess() @@ -146,6 +147,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.preprocess.show(mode, root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.preprocess.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_detect_Jpeak__(self): self.detect_Jpeak = MainWindow_detect_Jpeak() @@ -158,6 +160,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.detect_Jpeak.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.detect_Jpeak.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_detect_Rpeak__(self): self.detect_Rpeak = MainWindow_detect_Rpeak() @@ -170,6 +173,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.detect_Rpeak.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.detect_Rpeak.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_label_check__(self): self.label_check = MainWindow_label_check() @@ -192,6 +196,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.label_check.show(mode, root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.label_check.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_precisely_align__(self): self.precisely_align = MainWindow_precisely_align() @@ -204,6 +209,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.precisely_align.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.precisely_align.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_cut_PSG__(self): self.cut_PSG = MainWindow_cut_PSG() @@ -214,6 +220,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): if not self.check_sampID(): return self.cut_PSG.show(root_path, int(sampID)) + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_artifact_label__(self): self.artifact_label = MainWindow_artifact_label() @@ -226,6 +233,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.artifact_label.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.artifact_label.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_bcg_quality_label__(self): self.bcg_quality_label = MainWindow_bcg_quality_label() @@ -238,6 +246,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.bcg_quality_label.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.bcg_quality_label.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_resp_quality_label__(self): self.resp_quality_label = MainWindow_resp_quality_label() @@ -250,6 +259,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.resp_quality_label.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.resp_quality_label.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def __slot_btn_SA_label__(self): self.SA_label = MainWindow_SA_label() @@ -262,6 +272,7 @@ class MainWindow(QMainWindow, Ui_Signal_Label): self.SA_label.show(root_path, int(sampID)) # 默认最大化显示而非固定分辨率 self.SA_label.showMaximized() + self.check_save_path_and_mkdir(root_path, sampID) def seek_sampID(self, path): if not Path(path).exists(): @@ -271,7 +282,6 @@ class MainWindow(QMainWindow, Ui_Signal_Label): sub_folders = [item.name for item in Path(path).iterdir() if item.is_dir()] self.ui.comboBox_sampID.addItems(sub_folders) - def check_root_path(self): if self.ui.plainTextEdit_root_path.toPlainText() == Constants.STRING_IS_EMPTY: PublicFunc.msgbox_output(self, Constants.MAINWINDOW_ROOT_PATH_NOT_EXIST, Constants.MSGBOX_TYPE_ERROR) @@ -283,3 +293,16 @@ class MainWindow(QMainWindow, Ui_Signal_Label): PublicFunc.msgbox_output(self, Constants.MAINWINDOW_SAMPID_EMPTY, Constants.MSGBOX_TYPE_ERROR) return False return True + + def check_save_path_and_mkdir(self, root_path, sampID): + path_Label = Path(root_path) / Path(Filename.PATH_LABEL) / Path(str(sampID)) + path_OrgBCG_Aligned = Path(root_path) / Path(Filename.PATH_ORGBCG_ALIGNED) / Path(str(sampID)) + path_PSG_Aligned = Path(root_path) / Path(Filename.PATH_PSG_ALIGNED) / Path(str(sampID)) + path_OrgBCG_Text = Path(root_path) / Path(Filename.PATH_ORGBCG_TEXT) / Path(str(sampID)) + path_PSG_Text = Path(root_path) / Path(Filename.PATH_PSG_TEXT) / Path(str(sampID)) + + path_list = [path_Label, path_OrgBCG_Aligned, path_PSG_Aligned, path_OrgBCG_Text, path_PSG_Text] + + for path in path_list: + if not path.exists(): + path.mkdir(parents=True, exist_ok=True) \ No newline at end of file diff --git a/func/Module_precisely_align.py b/func/Module_precisely_align.py index 4093469..98934a6 100644 --- a/func/Module_precisely_align.py +++ b/func/Module_precisely_align.py @@ -1871,9 +1871,6 @@ class Data: return Result().success(info=info) def save_alignInfo(self): - if (not Path(Config["Path"]["Save_AlignInfo"]).parent.exists()) or (not Path(Config["Path"]["Save_AlignInfo"]).parent.is_dir()): - Path(Config["Path"]["Save_AlignInfo"]).parent.mkdir(parents=True, exist_ok=True) - try: save_data = { "front": { diff --git a/func/Module_preprocess.py b/func/Module_preprocess.py index f751ef5..f016e26 100644 --- a/func/Module_preprocess.py +++ b/func/Module_preprocess.py @@ -474,9 +474,6 @@ class Data: return Result().success(info=Constants.PREPROCESS_FINISHED) def save(self, chunk): - if (not Path(Config["Path"]["Save"]).parent.exists()) or (not Path(Config["Path"]["Save"]).parent.is_dir()): - Path(Config["Path"]["Save"]).parent.mkdir(parents=True, exist_ok=True) - if self.processed_data is None: return Result().failure(info=Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_resp_quality_label.py b/func/Module_resp_quality_label.py index e6ab281..7699227 100644 --- a/func/Module_resp_quality_label.py +++ b/func/Module_resp_quality_label.py @@ -1458,9 +1458,6 @@ class Data(): return BDR, band_low, band_high, bcg_spectrum, bcg_freq, tho_spectrum, tho_freq def save_resp_quality_label(self): - if (not Path(Config["Path"]["Save_Resp_quality_label"]).parent.exists()) or (not Path(Config["Path"]["Save_Resp_quality_label"]).parent.is_dir()): - Path(Config["Path"]["Save_Resp_quality_label"]).parent.mkdir(parents=True, exist_ok=True) - if self.resp_quality_label is None: return Result().failure(info=Filename.RESP_QUALITY_LABEL + Constants.SAVE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])