#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author:Marques
@file:Main_Quality_Relabel.py
@email:admin@marques22.com
@email:2021022362@m.scnu.edu.cn
@time:2022/03/28
"""
import argparse
from pathlib import Path
from utils.Quality_Relabel import Quality_Relabel

# start-----一般不用修改------
# 绘图时的采样率
frequency = 100
# 心晓数据采样率
bcg_frequency = 1000
# PSG_Data_Path = Path("Data/PSG/")
# PSG_Label_Path = Path("Data/PSG_label/")
# BCG_Data_Path = Path("Data/BCG/")
# BCG_Label_Path = Path("Data/BCG_label/")
PSG_Data_Path = Path("I:/CXH/Quality_Relabel/Data/PSG/")
PSG_Label_Path = Path("I:/CXH/Quality_Relabel/Data/PSG_label/")
BCG_Data_Path = Path("I:/CXH/Quality_Relabel/Data/BCG/")
BCG_Label_Path = Path("I:/CXH/Quality_Relabel/Data/BCG_label/")
Artifact_Label_Path = Path("I:/CXH/Quality_Relabel/Data/Artifact_label/")
Artifact_Offset_Path = Path("I:/CXH/Quality_Relabel/Data/Artifact_label/20220421Artifact_offset_value.xlsx")
all_path = [PSG_Data_Path, PSG_Label_Path, BCG_Data_Path, BCG_Label_Path, Artifact_Label_Path, Artifact_Offset_Path]
# end-----一般不用修改------

# 要遍历的事件
# 可选一个或多个 "Hypopnea" "Central apnea" "Obstructive apnea" "Mixed apnea"
focus_event_list = ["OSA"]
# 信号显示事件前多少秒
front_add_second = 60
# 信号显示事件后多少秒
back_add_second = 60

# 样本编号
sampNo = 670
# 从第几个心晓事件数量开始
start_bcg_index = 1

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--sampNo', nargs='?', type=int, default=sampNo, help='samp number')
    parser.add_argument('-e', '--event', nargs='*', type=str, default=focus_event_list,
                        choices=['OSA', 'CSA', 'MSA', 'HPY'],
                        help='focus_event')
    parser.add_argument('-i', '--start_bcg_index', nargs='?', type=int, default=start_bcg_index, help='samp number')
    parser.add_argument('-f', '--front_add_second', nargs='?', type=int, default=front_add_second,
                        help='Add x second signal in front of the event')
    parser.add_argument('-b', '--back_add_second', nargs='?', type=int, default=back_add_second,
                        help='Add x second signal after the event')
    opt = parser.parse_args()

    focus_event_list = []
    if 'OSA' in opt.event:
        focus_event_list.append("Obstructive apnea")
    if 'CSA' in opt.event:
        focus_event_list.append("Central apnea")
    if 'MSA' in opt.event:
        focus_event_list.append("Mixed apnea")
    if 'HPY' in opt.event:
        focus_event_list.append("Hypopnea")

    qualityRelabel = Quality_Relabel(all_path=all_path, sampNo=opt.sampNo, frequency=frequency,
                                     bcg_frequency=bcg_frequency,
                                     focus_event_list=focus_event_list)

    qualityRelabel.show_all_event(start_bcg_index=opt.start_bcg_index - 1,
                                  front_add_second=opt.front_add_second,
                                  back_add_second=opt.back_add_second)
