wfdb—心电信号降采样

wfdb—心电信号降采样

想做一下在做本科毕设中遇到的一点问题,记录一下一个新手小白上手信号处理的过程啦!

在完成PhysioNet中心电信号的加载之后,首先对信号进行一些预处理。因为比赛中提供的代码和其他前十名论文提供的都是matlab版本(Matlab里面对信号处理的函数真的方便好多),但是还是想完全用python来做。

翻了半天发现 wfdb库里面还是有一些可以用的函数。

wfdb.processing.resample_ann(resampled_t, ann_sample)
Compute the new annotation indices
resampled_t : (numpy array) Array of signal locations as returned by scipy.signal.resample
ann_sample : (numpy array) Array of annotation
locations resampled_ann_sample : (numpy array) Array of resampled annotation locations
wfdb.processing.resample_sig(x, fs, fs_target)
Resample a signal to a different frequency.
x : (numpy array)Array containing the signal
fs : (int, or float) The original sampling frequency
fs_target : (int, or float )The target frequency resampled_x : (numpy array) Array of the resampled signal
values resampled_t : (numpy array) Array of the resampled signal
locations wfdb.processing.resample_singlechan(x, ann, fs, fs_target)
Resample a single-channel signal with its annotations
x: (numpy array) The signal array
ann : (wfdb Annotation) The wfdb annotation object
fs : (int,or float) The original frequency
fs_target :(int, or float) The target frequency
resampled_x : (numpy array) Array of the resampled signal values
resampled_ann : (wfdb Annotation) Annotation containing resampled annotation locations
**wfdb.processing.resample_multichan(xs, ann, fs, fs_target, resamp_ann_chan=0)
Resample multiple channels with their annotations
xs: (numpy array) The signal array
ann : (wfdb Annotation) The wfdb annotation object
fs :(int, or float) The original frequency
fs_target : (int, or float) The target frequency
resample_ann_channel : (int,optional) The signal channel used to compute new annotation indices
resampled_xs : (numpy array) Array of the resampled signal values
resampled_ann : (wfdb Annotation) Annotation containing resampled annotation locations

以上具体的函数是通过查看官方的wfdb库说明发现的函数手册地址

我所使用的信号均为多通道且没有ann,所以只能分别对每一单独的通道进行将采样再整合。

发现采样之后的信号居然在原来的信号里面找不到

x,_=wfdb.processing.resample_sig(x=signal[0][:,0], fs=10,fs_target=5)
print('采样前信号:',signal[0][:,0])
print('采样后信号',x)
print('采样前信号长度:',signal[0][:,0].size)
print('采样后信号长度:',x.size)
采样前信号: [ 0.2954947   0.40238516  0.40989399 ... -0.30432862 -0.29328622
 -0.26369258]
采样后信号 [ 0.18638951  0.4436716   0.28101152 ... -0.27558733 -0.26769241
 -0.33578054]


之后分析认为降采样完的信号数据和原来的数据并不是直接几个数值中抽取一个,具体原理没有进行分析,但是通过画图发现波形没有变化,就OK了

采样前数据波形
采样后波形

  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值