From 6215399cf7bbca962c0dc9a99d16d5a57b8e3820 Mon Sep 17 00:00:00 2001 From: Yorusora <2944763079@qq.com> Date: Tue, 20 May 2025 21:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/Module_approximately_align.py | 2 ++ func/Module_cut_PSG.py | 3 +++ func/Module_detect_Jpeak.py | 3 +++ func/Module_detect_Rpeak.py | 3 +++ func/Module_label_check.py | 3 +++ func/Module_precisely_align.py | 18 ++++++++++++++++++ func/Module_preprocess.py | 3 +++ 7 files changed, 35 insertions(+) diff --git a/func/Module_approximately_align.py b/func/Module_approximately_align.py index adb71f4..cfdfc94 100644 --- a/func/Module_approximately_align.py +++ b/func/Module_approximately_align.py @@ -969,6 +969,8 @@ 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_cut_PSG.py b/func/Module_cut_PSG.py index 890cc3c..e7a73d0 100644 --- a/func/Module_cut_PSG.py +++ b/func/Module_cut_PSG.py @@ -322,6 +322,9 @@ 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.SAVING_FAILURE + diff --git a/func/Module_detect_Jpeak.py b/func/Module_detect_Jpeak.py index 61652c3..a033cd2 100644 --- a/func/Module_detect_Jpeak.py +++ b/func/Module_detect_Jpeak.py @@ -461,6 +461,9 @@ 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.SAVING_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_detect_Rpeak.py b/func/Module_detect_Rpeak.py index c2bcd02..2eb9865 100644 --- a/func/Module_detect_Rpeak.py +++ b/func/Module_detect_Rpeak.py @@ -452,6 +452,9 @@ 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.SAVING_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_label_check.py b/func/Module_label_check.py index 87d5548..0293518 100644 --- a/func/Module_label_check.py +++ b/func/Module_label_check.py @@ -1011,6 +1011,9 @@ 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.corrected_peak is None: return Result().failure(info=Constants.SAVING_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"]) diff --git a/func/Module_precisely_align.py b/func/Module_precisely_align.py index 34766e6..5d558db 100644 --- a/func/Module_precisely_align.py +++ b/func/Module_precisely_align.py @@ -1827,6 +1827,9 @@ 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": { @@ -1867,6 +1870,9 @@ class Data: return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_ALIGNINFO_FINISHED) def save_res_orgBcg(self, chunk): + if (not Path(Config["Path"]["Save_OrgBCG"]).parent.exists()) or (not Path(Config["Path"]["Save_OrgBCG"]).parent.is_dir()): + Path(Config["Path"]["Save_OrgBCG"]).parent.mkdir(parents=True, exist_ok=True) + if self.res_orgBcg is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FAILURE + Constants.FAILURE_REASON["res_orgBcg_Not_Exist"]) @@ -1880,6 +1886,9 @@ class Data: return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_ORGBCG_FINISHED) def save_res_BCG(self, chunk): + if (not Path(Config["Path"]["Save_BCG"]).parent.exists()) or (not Path(Config["Path"]["Save_BCG"]).parent.is_dir()): + Path(Config["Path"]["Save_BCG"]).parent.mkdir(parents=True, exist_ok=True) + if self.res_BCG is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FAILURE + Constants.FAILURE_REASON["res_BCG_Not_Exist"]) @@ -1893,6 +1902,9 @@ class Data: return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_RES_BCG_FINISHED) def save_cut_ECG(self, chunk): + if (not Path(Config["Path"]["Save_ECG"]).parent.exists()) or (not Path(Config["Path"]["Save_ECG"]).parent.is_dir()): + Path(Config["Path"]["Save_ECG"]).parent.mkdir(parents=True, exist_ok=True) + if self.cut_ECG is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FAILURE + Constants.FAILURE_REASON["cut_ECG_Not_Exist"]) @@ -1906,6 +1918,9 @@ class Data: return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_ECG_FINISHED) def save_Jpeak(self, chunk): + if (not Path(Config["Path"]["Save_ECG"]).parent.exists()) or (not Path(Config["Path"]["Save_ECG"]).parent.is_dir()): + Path(Config["Path"]["Save_ECG"]).parent.mkdir(parents=True, exist_ok=True) + if self.cut_Jpeak is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FAILURE + Constants.FAILURE_REASON["cut_Jpeak_Not_Exist"]) @@ -1919,6 +1934,9 @@ class Data: return Result().success(info=Constants.PRECISELY_ALIGN_SAVING_CUT_JPEAK_FINISHED) def save_Rpeak(self, chunk): + if (not Path(Config["Path"]["Save_Rpeak"]).parent.exists()) or (not Path(Config["Path"]["Save_Rpeak"]).parent.is_dir()): + Path(Config["Path"]["Save_Rpeak"]).parent.mkdir(parents=True, exist_ok=True) + if self.cut_Rpeak is None: return Result().failure(info=Constants.PRECISELY_ALIGN_SAVING_CUT_RPEAK_FAILURE + Constants.FAILURE_REASON["cut_Rpeak_Not_Exist"]) diff --git a/func/Module_preprocess.py b/func/Module_preprocess.py index 30d441d..f706fc2 100644 --- a/func/Module_preprocess.py +++ b/func/Module_preprocess.py @@ -449,6 +449,9 @@ 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.SAVING_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])