Compare commits

...

3 Commits
V1.1 ... main

Author SHA1 Message Date
marques
6ee434686a 使用零相移滤波器 2024-05-11 10:56:57 +08:00
9f166a973d 修改readme 2023-11-01 09:44:29 +08:00
9e27545068 添加启动说明 2023-10-18 08:28:48 +08:00
2 changed files with 26 additions and 19 deletions

View File

@ -1,7 +1,13 @@
# 预对齐程序使用方法
![](https://pics-cloud.6277837.xyz/imgs/202310162118570.png)
## 1. 环境配置
### 1.1. 安装依赖
![](https://cdn.marques22.com/imgs/202310162118570.png)
## 1. 安装与启动
### 1.1 下载程序
下载地址:[RespCoarseAlignV1.0.exe](/attachments/a1a22506-3847-4f98-af75-0c2f8990c039)
下载后直接运行
### 1.2 从开发环境运行
安装依赖
```shell
pip install -r requirementsg.txt
```
@ -18,30 +24,30 @@ numba # 计算加速
```
## 2. 使用流程
### 2.1. 默认配置
### 2.1 默认配置
左上角点击默认配置选择Default Configuration
<img src="https://pics-cloud.6277837.xyz/imgs/202310162130140.png" align="center" height="30%" width="30%" >
<img src="https://cdn.marques22.com/imgs/202310162130140.png" align="center" height="30%" width="30%" >
主要修改`PSG文件夹`和`心晓文件夹`两个选项
<img src="https://pics-cloud.6277837.xyz/imgs/202310162130027.png" align="center" height="50%" width="50%" >
<img src="https://cdn.marques22.com/imgs/202310162130027.png" align="center" height="50%" width="50%" >
默认设置会保存在`config.yaml`文件中,下次打开程序会自动读取配置文件
### 2.2. 选择文件
### 2.2 选择文件
<img src="https://pics-cloud.6277837.xyz/imgs/202310162134748.png" align="center" height="30%" width="30%" alt="">
<img src="https://cdn.marques22.com/imgs/202310162134748.png" align="center" height="30%" width="30%" alt="">
点击`刷新`自动匹配同时有PSG和心晓数据的患者编号若仅存在与其中一个文件夹则会不可选中
点击打开,读取完成后会分别显示其对应的时长
<img src="https://pics-cloud.6277837.xyz/imgs/202310162137617.png" align="center" height="30%" width="30%" >
<img src="https://cdn.marques22.com/imgs/202310162137617.png" align="center" height="30%" width="30%" >
### 2.3 信号预处理/标准化
一般保持默认,直接点击`应用`
<img src="https://pics-cloud.6277837.xyz/imgs/202310162138825.png" align="center" height="30%" width="30%" >
<img src="https://cdn.marques22.com/imgs/202310162138825.png" align="center" height="30%" width="30%" >
### 2.4 信号手动对齐/截断
本步骤是为了当遇到较长或较不规则信号时进行手动预处理,一般不需要使用
<img src="https://pics-cloud.6277837.xyz/imgs/202310162145279.png" align="center" height="30%" width="30%" >
<img src="https://cdn.marques22.com/imgs/202310162145279.png" align="center" height="30%" width="30%" >
```shell
PSG_补零: 在PSG信道前面补充若干个零单位为点的个数对于计算无影响仅为了信号无法自动对齐时进行人眼粗略大体动对齐
心晓_补零: 在心晓信道前面补充若干个零,单位为点的个数,对于计算无影响,仅为了信号无法自动对齐时进行人眼粗略大体动对齐
@ -51,22 +57,22 @@ PSG_Post: 对PSG后端截断若干个点单位为点的个数仅计算信
心晓_Post: 对心晓后端截断若干个点,单位为点的个数,仅计算信号开始(截断开始)到截断点结束的部分的互相关取值
```
对`**_Pre`和`**_Post`的修改后点击应用,图上红线包围的内区间即为相关计算片段
<img src="https://pics-cloud.6277837.xyz/imgs/202310162153952.png" align="center" height="80%" width="80%" >
<img src="https://cdn.marques22.com/imgs/202310162153952.png" align="center" height="80%" width="80%" >
点击`计算对齐`则计算两信号的互相关计算结果会显示在右侧计算时长与电脑性能、信号长度有关一般在1-2分钟左右程序可能进入无响应阶段不要关闭程序等待即可
<img src="https://pics-cloud.6277837.xyz/imgs/202310162202532.png" align="center" height="80%" width="80%" >
<img src="https://cdn.marques22.com/imgs/202310162202532.png" align="center" height="80%" width="80%" >
点击`读取对齐`,则从保存的结果中读取最近的一次记录进行显示
### 2.5 选取对齐点
本步骤是选择自动计算或手动输入PSG信号和心晓起始点之间的距离
<img src="https://pics-cloud.6277837.xyz/imgs/202310162203974.png" align="center" height="30%" width="30%" >
<img src="https://cdn.marques22.com/imgs/202310162203974.png" align="center" height="30%" width="30%" >
四个结果数据的集中程度,一定程度上反映了信号是否容易预对齐
+ 正数表示心晓开机比PSG晚PSG需要剔除前面若干个点或者心晓信号需要在前面补充若干个零
+ 负数表示心晓开机比PSG早PSG需要在前面补充若干个零或者心晓信号需要剔除前面若干个点
直接选择出现值较靠近的点,如上图可选择`24750`或`24733`,可以看到大体动基本对齐,若采样率或其他因素,
会有其他区间不能对齐的情况,或者肉眼不能从大体动分辨出来的情况。接下来进行片段级复核。
<img src="https://pics-cloud.6277837.xyz/imgs/202310162212400.png" align="center" height="80%" width="80%" >
<img src="https://cdn.marques22.com/imgs/202310162212400.png" align="center" height="80%" width="80%" >
### 2.6 片段级观测
@ -75,9 +81,9 @@ PSG_Post: 对PSG后端截断若干个点单位为点的个数仅计算信
右侧从上到下分别为PSG中的胸带信号呼吸间期心晓中呼吸努力信号呼吸间期PSG中的腹带信号呼吸间期
**对齐标准**有两个取其一或并用即可
1. 信号体动位置一致(可以存在偏移只要变化一致即可)
<img src="https://pics-cloud.6277837.xyz/imgs/202310162215819.png" align="center" height="80%" width="80%" >
<img src="https://cdn.marques22.com/imgs/202310162215819.png" align="center" height="80%" width="80%" >
2. 呼吸间期一致(可以存在偏移只要变化一致即可)
<img src="https://pics-cloud.6277837.xyz/imgs/202310162216347.png" align="center" height="80%" width="80%" >
<img src="https://cdn.marques22.com/imgs/202310162216347.png" align="center" height="80%" width="80%" >
### 2.7 保存结果
在符合上述条件的情况下,点击`保存`,会在当前程序下同级目录生成或追加`RespCoarseAlignInfo.csv`文件,记录对齐结果
@ -90,4 +96,5 @@ PSG_Post: 对PSG后端截断若干个点单位为点的个数仅计算信
~~todo1: 将相关计算分段计算,减少程序卡顿~~ 已实现
~~todo2: 将程序编译为exe文件减少安装依赖的过程~~ 已实现
~~todo3: 加入可控选择CPU数量或占用百分比避免造成电脑卡顿~~ 后者较难实现,暂行搁置
todo4: 缩小程序文件大小
todo4: 缩小程序文件大小
todo5: 程序退出后,进程清理不干净

View File

@ -231,7 +231,7 @@ class Data:
low = lowCut / (fs * 0.5)
high = highCut / (fs * 0.5)
sos = signal.butter(order, [low, high], btype="bandpass", output='sos')
return signal.sosfilt(sos, data)
return signal.sosfiltfilt(sos, data)
# 滤波
self.processed_THO = butter_bandpass_filter(self.raw_THO, self.Config["RespFilterConfig"]["LowCut"],