Waveform Database
python安装直接 pip install wfdb 然后就没有然后了
里面可能有用的就是这个示例,文档可以去这里
# import the WFDB package
import wfdb
# load a record using the 'rdrecord' function
record = wfdb.rdrecord('sample-data/a103l')
# plot the record to screen
wfdb.plot_wfdb(record=record, title='Example signals')
MATLAB安装
需要先安装java
这个可以在matlab命令行界面,直接选个风水比
较好的目录(在matlab中)
然后命令行运行
[old_path]=which('rdsamp'); if(~isempty(old_path)) rmpath(old_path(1:end-8)); end
wfdb_url='https://physionet.org/physiotools/matlab/wfdb-app-matlab/wfdb-app-toolbox-0-10-0.zip';
[filestr,status] = urlwrite(wfdb_url,'wfdb-app-toolbox-0-10-0.zip');
unzip('wfdb-app-toolbox-0-10-0.zip');
cd mcode
addpath(pwd)
savepath
当然,这等价于手动下载并解压 压缩包
把解压后下一层根目录添加到MATLAB的搜索路径里(主页/环境/设置路径)
好的现在可以在命令行
wfdbdemo
直接跑示例(注意这玩意会在上级刚才压缩包解压后的同级目录(不是子目录)下载示例数据,如果和之前数据集重复建议删除
文档可以查看这里《注意眼睛!》
那么之后就可以开始充分的调用各种格式的数据了
主要函数说明:
rdsamp 读入生理信号及其注释
[signal,Fs,tm]=rdsamp(recordName,signaList,N,N0,rawUnits,highResolution)
举例:在Matlab中输入以下内容通过rdsamp函数可以读出MITDB信号库中的一个recordName为‘100‘的信号并借助plot函数显示:
[tm, signal]=rdsamp('mitdb/100',[],1000);
plot(tm,signal(:,1));
其中,该信号中有两列采集信号,每列长为650000个采样点,所以获得的signal应该是一个2*650000的矩阵。但是可以在函数输入可选项:
SignalList:选择其中某列信号读入,输入为空默认为全部列,此处就是默认全部;
N:需要读入信号的长度,本身信号长为650000,此处只截取了其中1000长度;
N0:截取信号开始的采样点,此处默认为1,也就是截取了信号的1–1000采样点;
rawUnits:信号读入信号值需要的精度,具体请看帮助;
highResolution:信号分辨率,1为高,0为低,默认为0
rdann 读入注释信息
[ann,type,subtype,chan,num,comments]=rdann(recordName,annotator,C,N,N0,type)
举例:
[tm, signal]=rdsamp('challenge/2013/set-a/a01');
[ann]=rdann('challenge/2013/set-a/a01','fqrs');
plot(tm,signal(:,1));hold on;grid on
plot(tm(ann),signal(ann,1),'ro','MarkerSize',4)
本程序首先用rdsamp函数读入‘challenge’信号库中的命名为‘a01’的全部信号,再用‘rdann’函数读入与之对应的注释信息,类型为‘fqrs’,也就是QRS出现的位置,最后由plot显示’Challenge’生理库中命名为‘a01’信号及其QRS注释信息
其中红色的圆点就是注释文件中标注QRS出现的地方。其实注释信息我们可以通过一些算法求出来的,但是既然生理库中已经给出我们就可以直接用,而且他们官方的肯定经过矫正很准确的,既方便也有保证,直接拿来用何乐不为?另外如果我们想自己开发检测QRS或者R,可以将自己得到的结果和官方的注释信息对比,看看自己算法的准确率。
由于官方文档主页实在是太护眼了!直接搬运一下
Contents
Introduction
FAQ
Applications
- a2m, ad2m, ahaconvert, ahaecg2mit, m2a, md2a: converting between AHA DB and WFDB formats
- ann2rr, rr2ann: convert annotation files to interval lists and vice versa
- bxb: ANSI/AAMI-standard beat-by-beat annotation comparator
- calsig: calibrate signals of a WFDB record
- coherence: estimate coherence and cross-spectrum of two time series
- dfa: detrended fluctuation analysis
- ecgeval: generate and run ECG analyzer evaluation script
- ecgpuwave: QRS detector and waveform limit locator
- edf2mit, mit2edf: convert between EDF and WFDB-compatible formats
- edr: derive a respiration signal from an ECG
- epicmp: ANSI/AAMI-standard episode-by-episode annotation comparator
- fft: fast Fourier transform
- fir: general-purpose FIR filter for WFDB records
- gqfuse: combine QRS annotation files
- gqrs, gqpost: QRS detector and post-processor
- hrfft, hrlomb, hrmem: calculate and plot heart rate power spectra
- hrstats: collect and summarize heart rate statistics from an annotation file
- ihr: calculate instantaneous heart rate
- imageplt: plot a greyscale image
- log10: calculate common logarithms of two-column data
- lomb: estimate power spectrum using the Lomb periodogram method
- lwcat: postprocess output of plt to make PostScript, EPS, PDF or PNG
- memse: estimate power spectrum using maximum entropy (all poles) method
- mfilt: general-purpose median filter for WFDB records
- mrgann: merge annotation files
- mxm: ANSI/AAMI-standard measurement-by-measurement annotation comparator
- nguess: guess the times of missing normal beats in an annotation file
- nst: noise stress test for ECG analysis programs
- parsescp: parse SCP-ECG, optionally save in PhysioBank-compatible format
- plot2d, plot3d: make 2-D or 3-D plots from text files of data, using gnuplot
- plotstm: produce scatter plot of ST measurement errors on a PostScript device
- plt: make 2-D plots
- pltf: make function plots
- pnnlist, pNNx: derive pNNx statistics from an annotation interval list or an annotation file
- pnwlogin: provide direct access to PhysioNetWorks for WFDB applications
- pschart: produce annotated `chart recordings’ on a PostScript device
- psfd: produce annotated `full-disclosure’ plots on a PostScript device
- rdann: read a WFDB annotation file
- rdedfann: extract annotations from an EDF+ file
- rdsamp: read WFDB signal files
- rxr: ANSI/AAMI-standard run-by-run annotation comparator
- sampfreq: show sampling frequency for a record
- setwfdb, cshsetwfdb: set WFDB environment variables
- sigamp: measure signal amplitudes of a WFDB record
- sigavg: calculate averages of annotated waveforms
- signame: print names of signals of a WFDB record
- signum: print signal numbers of a WFDB record having specified names
- skewedit: edit skew fields of header file(s)
- snip: copy an excerpt of a WFDB record
- sortann: rearrange annotations in canonical order
- sqrs, sqrs125: single-channel QRS detector
- stepdet: single-channel step change detector
- sumann: summarize the contents of a WFDB annotation file
- sumstats: derive aggregate statistics from bxb, rxr, etc., line-format output
- tach: heart rate tachometer
- time2sec: convert WFDB standard time format into seconds
- wabp: arterial blood pressure (ABP) pulse detector
- wav2mit, mit2wav: convert between .wav and WFDB-compatible formats
- wave: waveform analyzer, viewer, and editor
- wfdb-config: print WFDB library version and configuration info
- wfdb2mat: convert WFDB-compatible signal file to Matlab .mat file
- wfdbcat: copy WFDB files to standard output
- wfdbcollate: collate WFDB records into a multi-segment record
- wfdbdesc: read signal specifications
- wfdbmap: make a synoptic map of a WFDB record
- wfdbtime: convert time to sample number, elapsed, and absolute time
- wfdbwhich: find a WFDB file and print its pathname
- wqrs: single-channel QRS detector based on length transform
- wrann: write a WFDB annotation file
- wrsamp: write WFDB signal files
- xform: sampling frequency, amplitude, and format conversion for WFDB records
WFDB libraries
WFDB file formats
- annot: WFDB annotation file formats
- header: WFDB header file format
- signal: WFDB signal file formats
- wfdbcal: WFDB calibration file format
Miscellaneous
- xview: xview toolkit information