1、完善命名规范
2、完成<冗余数据切割和标签映射>的全部代码
This commit is contained in:
@ -41,7 +41,6 @@ ButtonState = {
|
||||
class SettingWindow(QMainWindow):
|
||||
|
||||
def __init__(self, root_path, sampID):
|
||||
|
||||
super(SettingWindow, self).__init__()
|
||||
self.ui = Ui_MainWindow_detect_Rpeak_input_setting()
|
||||
self.ui.setupUi(self)
|
||||
@ -58,7 +57,6 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.pushButton_cancel.clicked.connect(self.close)
|
||||
|
||||
def __read_config__(self):
|
||||
|
||||
if not Path(ConfigParams.DETECT_RPEAK_CONFIG_FILE_PATH).exists():
|
||||
with open(ConfigParams.DETECT_RPEAK_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(ConfigParams.DETECT_RPEAK_CONFIG_NEW_CONTENT, f)
|
||||
@ -86,7 +84,6 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.plainTextEdit_file_path_save.setPlainText(Config["Path"]["Save"])
|
||||
|
||||
def __write_config__(self):
|
||||
|
||||
# 从界面写入配置
|
||||
Config["InputConfig"]["Freq"] = self.ui.spinBox_input_freq.value()
|
||||
Config["Path"]["Input"] = self.ui.plainTextEdit_file_path_input.toPlainText()
|
||||
@ -101,11 +98,9 @@ class SettingWindow(QMainWindow):
|
||||
self.close()
|
||||
|
||||
def __rollback_config__(self):
|
||||
|
||||
self.__read_config__()
|
||||
|
||||
def __update_ui__(self):
|
||||
|
||||
self.ui.plainTextEdit_file_path_input.setPlainText(
|
||||
str((Path(self.root_path) /
|
||||
ConfigParams.PUBLIC_PATH_PSG_TEXT /
|
||||
@ -118,7 +113,6 @@ class SettingWindow(QMainWindow):
|
||||
class MainWindow_detect_Rpeak(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
super(MainWindow_detect_Rpeak, self).__init__()
|
||||
self.ui = Ui_MainWindow_detect_Rpeak()
|
||||
self.ui.setupUi(self)
|
||||
@ -147,7 +141,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def show(self, root_path, sampID):
|
||||
|
||||
super().show()
|
||||
self.root_path = root_path
|
||||
self.sampID = sampID
|
||||
@ -190,7 +183,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def closeEvent(self, event):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
PublicFunc.statusbar_show_msg(self, PublicFunc.format_status_msg(Constants.SHUTTING_DOWN))
|
||||
@ -211,12 +203,10 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
|
||||
@staticmethod
|
||||
def __reset__():
|
||||
|
||||
ButtonState["Current"].update(ButtonState["Default"].copy())
|
||||
ButtonState["Current"]["pushButton_view"] = True
|
||||
|
||||
def __plot__(self):
|
||||
|
||||
# 清空画框
|
||||
self.reset_axes()
|
||||
|
||||
@ -247,14 +237,12 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
return status, info
|
||||
|
||||
def __update_config__(self):
|
||||
|
||||
Config["Filter"]["BandPassLow"] = self.ui.doubleSpinBox_bandPassLow.value()
|
||||
Config["Filter"]["BandPassHigh"] = self.ui.doubleSpinBox_bandPassHigh.value()
|
||||
Config["PeaksValue"] = self.ui.spinBox_peaksValue.value()
|
||||
Config["DetectMethod"] = self.ui.comboBox_method.currentText()
|
||||
|
||||
def __slot_btn_input__(self):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 清空画框
|
||||
@ -300,7 +288,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_view__(self):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 数据预处理
|
||||
@ -347,7 +334,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_save__(self):
|
||||
|
||||
reply = QMessageBox.question(self, Constants.QUESTION_TITLE,
|
||||
Constants.QUESTION_CONTENT + Config["Path"]["Save"],
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
@ -381,7 +367,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def reset_axes(self):
|
||||
|
||||
self.ax0.clear()
|
||||
self.ax1.clear()
|
||||
self.ax0.grid(True)
|
||||
@ -391,7 +376,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
self.ax1.xaxis.set_major_formatter(ConfigParams.FORMATTER)
|
||||
|
||||
def update_ui_comboBox_method(self, method_list):
|
||||
|
||||
self.ui.comboBox_method.clear()
|
||||
self.ui.comboBox_method.addItems(method_list)
|
||||
|
||||
@ -399,9 +383,6 @@ class MainWindow_detect_Rpeak(QMainWindow):
|
||||
class Data:
|
||||
|
||||
def __init__(self):
|
||||
self.file_path_input = Config["Path"]["Input"]
|
||||
self.file_path_save = Config["Path"]["Save"]
|
||||
|
||||
self.raw_data = None
|
||||
self.processed_data = None
|
||||
self.peak = None
|
||||
@ -409,21 +390,19 @@ class Data:
|
||||
self.RRIV = None
|
||||
|
||||
def open_file(self):
|
||||
|
||||
if not Path(Config["Path"]["Input"]).exists():
|
||||
return False, Constants.INPUT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Data_Path_Not_Exist"]
|
||||
|
||||
try:
|
||||
self.raw_data = read_csv(self.file_path_input,
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
return False, Constants.INPUT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Read_Data_Exception"]
|
||||
|
||||
return True, Constants.INPUT_FINISHED
|
||||
|
||||
def preprocess(self):
|
||||
|
||||
if self.raw_data is None:
|
||||
return False, Constants.DETECT_RPEAK_PROCESS_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Raw_Data_Not_Exist"]
|
||||
|
||||
@ -438,7 +417,6 @@ class Data:
|
||||
return True, Constants.DETECT_RPEAK_PROCESS_FINISHED
|
||||
|
||||
def predict_Rpeak(self):
|
||||
|
||||
if self.processed_data is None:
|
||||
return False, Constants.DETECT_RPEAK_PREDICT_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Processed_Data_Not_Exist"]
|
||||
|
||||
@ -453,12 +431,11 @@ class Data:
|
||||
return True, Constants.DETECT_RPEAK_PREDICT_FINISHED
|
||||
|
||||
def save(self, chunk):
|
||||
|
||||
if self.peak is None:
|
||||
return False, Constants.SAVING_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Peak_Not_Exist"]
|
||||
|
||||
try:
|
||||
chunk.to_csv(self.file_path_save, mode='a', index=False, header=False)
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False)
|
||||
except Exception:
|
||||
return False, Constants.SAVING_FAILURE + Constants.DETECT_RPEAK_FAILURE_REASON["Save_Exception"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user