from markdown import markdown

from func.utils.ConfigParams import Filename, Params

markdown_text = f"""
# 文件命名规范

### 当一份数据被完整走完标注流程后，数据文件夹目录结构将会是：

    .../{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}
        |-{Filename.ARTIFACT_A}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.ARTIFACT_B}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.ARTIFACT_C}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_CSV}
        |-{Filename.SQ_LABEL_10S}{Params.ENDSWITH_CSV}
        |-{Filename.SQ_LABEL_30S}{Params.ENDSWITH_CSV}
        |-{Filename.RESP_QUALITY_LABEL}{Params.ENDSWITH_TXT}
        |-{Filename.THO_PEAK}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SA_LABEL_CORRECTED}{Params.ENDSWITH_CSV}
        |-{Filename.SA_LABEL_ADD}{Params.ENDSWITH_CSV}
        |-{Filename.PRECISELY_ALIGN_INFO}{Params.ENDSWITH_TXT}
        |-{Filename.APPROXIMATELY_ALIGN_INFO}{Params.ENDSWITH_CSV}
    .../{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}
        |-{Filename.BCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.ORGBCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.JPEAK_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
    .../{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}
        |-{Filename.ORGBCG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.BCG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.JPEAK_REVISE}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.JPEAK_REVISE_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
    .../{Filename.PATH_ORGBCG_ORIGIN}/{Filename.PATH_SAMPID}
        |-...
    .../{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}
        |-{Filename.ECG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.RPEAK_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FIVE_CLASS_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SA_LABEL_SYNC}{Params.ENDSWITH_CSV}
        |-{Filename.ABD_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.THO_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FLOWT_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FLOWP_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SNORE_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SPO2_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
    .../{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}
        |-{Filename.ECG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.ECG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.RPEAK_FINAL}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.RPEAK_FINAL_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FIVE_CLASS_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SA_LABEL_RAW}{Params.ENDSWITH_CSV}
        |-{Filename.ABD_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.THO_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FLOWT_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.FLOWP_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SNORE_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.SPO2_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}
        |-{Filename.STARTTIME_RAW}{Params.ENDSWITH_TXT}
    .../{Filename.PATH_PSG_ORIGIN}/{Filename.PATH_SAMPID}
        |-...
    .../{Filename.PATH_REVEIVE_ORIGIN}
        |-...
    .../{Filename.PATH_REPORT}
        |-...

### 1 数据粗同步

输入：

原始OrgBCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始Tho信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.THO_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始Abd信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ABD_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

粗同步后的位置索引：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.APPROXIMATELY_ALIGN_INFO}{Params.ENDSWITH_CSV}`

### 2 预处理

输入：

原始OrgBCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始ECG信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ECG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

滤波后的BCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.BCG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

滤波后的ECG信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ECG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

### 3 数据精同步

#### 3.1 算法定位

#### 3.1.1 R峰算法定位

输入：

滤波后的ECG信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ECG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

算法定位的R峰坐标：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.RPEAK_FINAL}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

#### 3.1.2 J峰算法定位

输入：

滤波后的BCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.BCG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

算法定位的J峰坐标：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.JPEAK_REVISE}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

#### 3.2 人工纠正

#### 3.2.1 R峰人工纠正

输入：

滤波后的ECG信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ECG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

算法定位的R峰坐标：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.RPEAK_FINAL}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

粗同步后的位置索引：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.APPROXIMATELY_ALIGN_INFO}{Params.ENDSWITH_CSV}`

输出：

人工纠正后的R峰坐标：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.RPEAK_FINAL_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

#### 3.2.2 J峰人工纠正*

输入：

滤波后的BCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.BCG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

算法定位的J峰坐标：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.JPEAK_REVISE}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

粗同步后的位置索引：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.APPROXIMATELY_ALIGN_INFO}{Params.ENDSWITH_CSV}`

输出：

人工纠正后的J峰坐标：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.JPEAK_REVISE_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

#### 3.3 数据片段起止对齐、数据采样率同步

输入：

滤波后的ECG信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ECG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

人工纠正后的R峰坐标：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.RPEAK_FINAL_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

滤波后的BCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.BCG_FILTER}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

人工纠正后的J峰坐标：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.JPEAK_REVISE_CORRECTED}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始OrgBCG信号：`./{Filename.PATH_ORGBCG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

粗同步后的位置索引：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.APPROXIMATELY_ALIGN_INFO}{Params.ENDSWITH_CSV}`

输出：

精同步对齐信息：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.PRECISELY_ALIGN_INFO}{Params.ENDSWITH_TXT}`

同步后的ECG信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ECG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的R峰坐标：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.RPEAK_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的BCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.BCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的OrgBCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的J峰坐标：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.JPEAK_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

#### 3.4、冗余数据切割、标签映射

输入：

精同步对齐信息：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.PRECISELY_ALIGN_INFO}{Params.ENDSWITH_TXT}`

原始的Flow T信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.FLOWT_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的Flow P信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.FLOWP_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的Tho信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.THO_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的Abd信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.ABD_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的SpO2信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.SPO2_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的Snore信号：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.SNORE_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的睡眠分期标签：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.FIVE_CLASS_RAW}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

原始的睡眠呼吸暂停事件标签：`./{Filename.PATH_PSG_TEXT}/{Filename.PATH_SAMPID}/{Filename.SA_LABEL_RAW}{Params.ENDSWITH_CSV}`

输出：

同步后的Flow T信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.FLOWT_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Flow P信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.FLOWP_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Tho信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.THO_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Abd信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ABD_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的SpO2信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.SPO2_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Snore信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.SNORE_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的睡眠分期标签：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.FIVE_CLASS_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的睡眠呼吸暂停事件标签：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.SA_LABEL_SYNC}{Params.ENDSWITH_CSV}`

### 4 体动标记

输入：

同步后的BCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.BCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的OrgBCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

txt格式的体动标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_A}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

体动标签类型数量统计：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_B}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

csv格式的体动标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_C}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_CSV}`

### 5 质量评估

输入：

同步后的BCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.BCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

txt格式的体动标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_A}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

质量标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.SQ_LABEL_10S}{Params.ENDSWITH_CSV}`或`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.SQ_LABEL_30S}{Params.ENDSWITH_CSV}`

### 6 呼吸提取

输入：

同步后的OrgBCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Tho信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.THO_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

txt格式的体动标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_A}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

输出：

呼吸可用性标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.RESP_QUALITY_LABEL}{Params.ENDSWITH_TXT}`

Tho信号呼吸间期标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.THO_PEAK}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

### 8 呼吸暂停事件标注

输入：

同步后的OrgBCG信号：`./{Filename.PATH_ORGBCG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ORGBCG_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

txt格式的体动标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.ARTIFACT_A}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Flow T信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.FLOWT_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Flow P信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.FLOWP_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Tho信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.THO_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的Abd信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.ABD_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的SpO2信号：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.SPO2_SYNC}{Filename.SUFFIX_FREQ}{Params.ENDSWITH_TXT}`

同步后的睡眠呼吸暂停事件标签：`./{Filename.PATH_PSG_ALIGNED}/{Filename.PATH_SAMPID}/{Filename.SA_LABEL_SYNC}{Params.ENDSWITH_CSV}`

输出：

修正后的呼吸暂停标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.SA_LABEL_CORRECTED}{Params.ENDSWITH_CSV}`

新增的呼吸暂停标签：`./{Filename.PATH_LABEL}/{Filename.PATH_SAMPID}/{Filename.SA_LABEL_ADD}{Params.ENDSWITH_CSV}`

"""

html = markdown(markdown_text)
with open('数据结构化输入和输出命名规范.html', 'w', encoding='utf-8') as file:
    file.write(html)
