新增脚本filename_regulation_generator.py,有命名规范需要修改时,只需要修改ConfigParams.py的Filename类里面的变量的值,之后直接运行脚本filename_regulation_generator.py即可获取最新版本的数据结构化输入和输出命名规范.html
This commit is contained in:
@ -10,8 +10,9 @@ from overrides import overrides
|
||||
from pandas import read_csv, DataFrame
|
||||
from yaml import dump, load, FullLoader
|
||||
|
||||
from func.utils.ConfigParams import Filename, Params
|
||||
from func.utils.PublicFunc import PublicFunc
|
||||
from func.utils.Constants import Constants, ConfigParams
|
||||
from func.utils.Constants import Constants
|
||||
from func.utils.Result import Result
|
||||
|
||||
from ui.MainWindow.MainWindow_cut_PSG import Ui_MainWindow_cut_PSG
|
||||
@ -62,9 +63,9 @@ class MainWindow_cut_PSG(QMainWindow):
|
||||
|
||||
Config.update({
|
||||
"Path": {
|
||||
"InputFolder": str(Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / Path(str(self.sampID))),
|
||||
"SaveFolder": str(Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_ALIGNED / Path(str(self.sampID))),
|
||||
"InputAlignInfo": str(Path(self.root_path) / ConfigParams.PUBLIC_PATH_LABEL / Path(str(self.sampID)))
|
||||
"InputFolder": str(Path(self.root_path) / Filename.PATH_PSG_TEXT / Path(str(self.sampID))),
|
||||
"SaveFolder": str(Path(self.root_path) / Filename.PATH_PSG_ALIGNED / Path(str(self.sampID))),
|
||||
"InputAlignInfo": str(Path(self.root_path) / Filename.PATH_LABEL / Path(str(self.sampID)))
|
||||
}
|
||||
})
|
||||
|
||||
@ -94,11 +95,11 @@ class MainWindow_cut_PSG(QMainWindow):
|
||||
ButtonState["Current"].update(ButtonState["Default"].copy())
|
||||
|
||||
def __read_config__(self):
|
||||
if not Path(ConfigParams.CUT_PSG_CONFIG_FILE_PATH).exists():
|
||||
with open(ConfigParams.CUT_PSG_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(ConfigParams.CUT_PSG_CONFIG_NEW_CONTENT, f)
|
||||
if not Path(Params.CUT_PSG_CONFIG_FILE_PATH).exists():
|
||||
with open(Params.CUT_PSG_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(Params.CUT_PSG_CONFIG_NEW_CONTENT, f)
|
||||
|
||||
with open(ConfigParams.CUT_PSG_CONFIG_FILE_PATH, "r") as f:
|
||||
with open(Params.CUT_PSG_CONFIG_FILE_PATH, "r") as f:
|
||||
file_config = load(f.read(), Loader=FullLoader)
|
||||
Config.update(file_config)
|
||||
|
||||
@ -231,9 +232,9 @@ class Data:
|
||||
return Result().success(info=Constants.CUT_PSG_GET_FILE_AND_FREQ_FINISHED)
|
||||
|
||||
def open_file(self):
|
||||
path = str(Path(self.root_path) / ConfigParams.PUBLIC_PATH_PSG_TEXT / Path(str(self.sampID)))
|
||||
path = str(Path(self.root_path) / Filename.PATH_PSG_TEXT / Path(str(self.sampID)))
|
||||
for value in Config["ChannelInput"].values():
|
||||
result = PublicFunc.examine_file(path, value, ConfigParams.ENDSWITH_TXT)
|
||||
result = PublicFunc.examine_file(path, value, Params.ENDSWITH_TXT)
|
||||
if not result.status:
|
||||
return result
|
||||
|
||||
@ -242,20 +243,20 @@ class Data:
|
||||
|
||||
Config["Path"]["InputAlignInfo"] = str(
|
||||
Path(Config["Path"]["InputAlignInfo"]) / Path(
|
||||
ConfigParams.PRECISELY_ALIGN_INFO + ConfigParams.ENDSWITH_TXT))
|
||||
Filename.PRECISELY_ALIGN_INFO + Params.ENDSWITH_TXT))
|
||||
|
||||
try:
|
||||
for key in Config["ChannelInput"].keys():
|
||||
self.raw[key] = read_csv(Path(Config["Path"]["InputFolder"]) / Path((Config["ChannelInput"][key] + str(self.freq[key]) + Config["EndWith"][key])),
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.SALabel = read_csv(Path(Config["Path"]["InputFolder"]) / Path((Config["LabelInput"]["SA Label"] + Config["EndWith"]["SA Label"])),
|
||||
encoding=ConfigParams.GBK_ENCODING)
|
||||
encoding=Params.GBK_ENCODING)
|
||||
self.startTime = read_csv(Path(Config["Path"]["InputFolder"]) / Path((Config["StartTime"] + Config["EndWith"]["StartTime"])),
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.alignInfo = read_csv(Path(Config["Path"]["InputAlignInfo"]),
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
encoding=Params.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.alignInfo = literal_eval(self.alignInfo[0])
|
||||
except Exception as e:
|
||||
@ -290,7 +291,7 @@ class Data:
|
||||
try:
|
||||
# 读取SA标签
|
||||
self.SALabel = self.SALabel.loc[:, ~self.SALabel.columns.str.contains("^Unnamed")]
|
||||
self.SALabel = self.SALabel[self.SALabel["Event type"].isin(ConfigParams.CUT_PSG_SALABEL_EVENT)]
|
||||
self.SALabel = self.SALabel[self.SALabel["Event type"].isin(Params.CUT_PSG_SALABEL_EVENT)]
|
||||
self.SALabel["Duration"] = self.SALabel["Duration"].astype(str)
|
||||
self.SALabel["Duration"] = self.SALabel["Duration"].str.replace(r' \(.*?\)', '', regex=True)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user