이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to debug Error in Pan Tompkins?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am getting the following error when the AF signal is passed in Pan Tompkins algorithm.
Error using filtfilt>getCoeffsAndInitialConditions (line 181)
Data length must be larger than 18 samples.
Error in filtfilt (line 96)
[b,a,zi,nfact,L] = getCoeffsAndInitialConditions(b,a,Npts);
Error in pan_tompkin2 (line 194)
ecg_h = filtfilt(a,b,ecg);
I have downloaded AF Signals (MIT-BIH Arrhythmia Database as .mat) from physiobank-atm from physionet.org. Could you help in debugging it?
댓글 수: 3
Walter Roberson
2016년 4월 14일
Instructions on downloading: http://www.mathworks.com/matlabcentral/answers/10331-how-to-open-mit-bih-arrhythmia-database-file-in-matlab
Walter Roberson
2016년 4월 14일
For the Arrhythmia database, which "record" are you downloading? Are you downloading MLII or V5 ? On the MATLAB side, how are you loading the data into MATLAB, and how are you passing the data into pan_tomkin2?
My suspicion is that you might be trying to pass the name of the .mat instead of the content of the .mat
Shraddha Joshi
2016년 4월 15일
편집: Walter Roberson
2016년 4월 15일
I have attached a signal sample which I have downloaded along with Pan tompkins code I am using. Signal is downloaded as

In the Pan Tompkins code attached below, in the lines 118 and 153, the command i have used to load signals is,
ecg=load('100.mat')
instead of
ecg=load('ECG_sample_noisy.mat')
채택된 답변
Walter Roberson
2016년 4월 15일
matstruct = load('100m.mat');
ecg = matstruct.val;
That is, you need to use the .val variable within the .mat. When you load() a .mat like that, returning a value, the result is a struct in which the fields are the names of the loaded variables.
댓글 수: 21
Shraddha Joshi
2016년 4월 15일
Sir, when I tried including the above instructions you said, in the lines 118 and 119 of the program attached below, I got following error:
Error using pan_tompkin2 (line 122) ecg must be a row or column vector
I am not getting where exactly to provide the above instructions in the original Pan Tompkin Algorithm code. Can u please help me?
Walter Roberson
2016년 4월 15일
matstruct = load('100m.mat');
ecg1 = matstruct.val(1,:);
ecg2 = matstruct.val(2,:);
Now ecg1 is the MLII signal and ecg2 is the V5 signal; process whichever one is appropriate for your purpose.
Shraddha Joshi
2016년 4월 16일
Thank You Sir. It did help in getting the output. One more help i needed, there are a few MITBIH Afib sample signals that I have downloaded which I have enclosed in the attached folder below. How can I pass all these sample signals one after the other through Pan Tompkins Algorithm and check and store their rr interval values?
Shraddha Joshi
2016년 4월 17일
Sir could u please help regarding above query at the earliset? How can the code correction be done to read all the mitbih afib signals one after the other through Pan tompkins algorithm and for each signal the rr interval calculated should be stored in a register or array?
Walter Roberson
2016년 4월 17일
fs = 360; %according to the .info files
dinfo = dir('*.mat');
filenames = {dinfo.name};
nfiles = length(filenames);
results = cell(nfiles, 1);
for K = 1 : nfiles
thisfile = filenames{K};
matstruct = load(thisfile);
ecgs = matstruct.val;
for rownum = 1 : size(ecgs,1)
ecg = ecgs(rownum, :);
results{K,rownum} = pan_tompkin2(ecg, fs, ... whatever);
end
end
Even better would be to go through the header files and read out the frequency, but I did not bother; all the ones I looked at were 360 Hz.
Shraddha Joshi
2016년 4월 17일
편집: Shraddha Joshi
2016년 4월 17일
Sorry for the inconvenience Sir. And yes the frequency is 360Hz for all signals. I tried with the above code but the error I am getting is
Undefined function or variable "ecgs".
Error in pan_tompkin2 (line 130) for rownum=1:size(ecgs,1);
What is this ecgs and how can I define it?
Shraddha Joshi
2016년 4월 18일
Is it possible to calculate sensitivity and specificity for the above signals? If so can u please tell me how to do so?
Walter Roberson
2016년 4월 18일
Sensitivity and specificity of what? You get back the R-wave indices and not much else. Do you have information about where the R-waves "really" are that you can compare against?
Shraddha Joshi
2016년 4월 18일
편집: Walter Roberson
2016년 4월 18일
According to the code u have sent before which is as below, we are storing the results in results{K,rownum}.
fs = 360; %according to the .info files
dinfo = dir('*.mat');
filenames = {dinfo.name};
nfiles = length(filenames);
results = cell(nfiles, 1);
for K = 1 : nfiles
thisfile = filenames{K};
matstruct = load(thisfile);
ecgs = matstruct.val;
for rownum = 1 : size(ecgs,1)
ecg = ecgs(rownum, :);
results{K,rownum} = pan_tompkin2(ecg, fs, ... whatever);
end
end
So as this results{K,rownum} gives information about RR intervals, can't we calculate Sensitivity and Specificity of the Afib signals we are passing? Or is there any other way from which we can calculate sensitivity and specificity of the signals?
Walter Roberson
2016년 4월 18일
You cannot calculate those without some information about what the accurate classification is. You could, for example, synthesize some data and put it through and then compare the results to the known values.
Shraddha Joshi
2016년 4월 18일
편집: Walter Roberson
2016년 4월 18일
Suppose if I check these rr intervals stored in results{k,rownum} with some standard rr interval range for different kind of arrhythmia based on decision rules and classify them as normal or abnormal ecg signals and again in abnormal as Afib or other arrhythmia; will i be able to calculate sensitivity and specificity then? If so, how exactly can i do it through code?
Walter Roberson
2016년 4월 18일
No, you need some information known to be true, not information that just had a different approximate classification method used. That information an be known to be true because you synthesized the information, or it can be known to be true by expert analysis of the signals.
You have the additional difficulty that your signal bounds are probably slightly fuzzy rather than sample-for-sample exact. You are sampling at 360 Hz, so if you have an event that takes less than 1/720 of a second to start, it could might legitimately get associated with either the sample #K or sample #(K-1). An expert looking at the plot might point to one particular sample one time as being the boundary, and the same expert might point to an adjacent sample the next time as being the same boundary. Especially in the presence of noise, it is often impossible to say that a particular sample is exactly the right boundary. Right at the calculated boundary it probably does not matter much whether the sample is inside or outside the boundary -- but (for example) 10 samples inside the boundary if you haven't yet agreed the boundary is there, then You Have A Problem that needs to be measured.
Some classification methods account for this by generating a confidence in their calculation, and then the statistical measures can be weighted by the confidence. But you do not appear to have that situation here.
Shraddha Joshi
2016년 4월 19일
So there is absolutely no way of determining sensitivity and specificity for the signals above program? At least by considering no.of heart beats? Or else could you please suggest any other way which would help me to calculate them? I really needed this calculation in order for further analysis with my project studies. Hoping for the help.
Shraddha Joshi
2016년 4월 19일
Or is there a way to check if the above signals passed are atrial fibrillation or no, based on heart rate calculation from rr intervals obtained ?
Walter Roberson
2016년 4월 19일
Without some objective truth or expert analysis, your system might as well just be playing NumberWang
Shraddha Joshi
2016년 4월 19일
So are you trying to say that there is no way to calculate heart rate from rr intervals found?
Walter Roberson
2016년 4월 19일
I do not know anything about calculating heart rate from ecg signals. I do not know what rr intervals are. I was responding about sensitivity and specificity: to calculate those, you need information known by construction or expert opinion to be true.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
