Main Content

ECG의 R 파형 검출

이 예제에서는 웨이블릿을 사용하여 심전도(ECG) 신호를 분석하는 방법을 보여줍니다. ECG 신호는 흔히 비정상적인데 이는 시간의 경과에 따라 주파수 내용이 변한다는 것을 의미합니다. 이러한 변화가 관심이 있는 이벤트입니다.

웨이블릿은 신호를 시변 주파수(스케일) 성분으로 분해합니다. 신호 특징이 흔히 시간 및 주파수에서 국소화하기 때문에 더 희소화된(축소된) 표현으로 작업하면 더욱 쉽게 분석 및 추정을 수행할 수 있습니다.

QRS 복합파는 ECG 파형의 세 가지 편향으로 구성됩니다. QRS 복합파는 우심실과 좌심실의 탈분극을 반영하며 사람 ECG의 가장 두드러진 특징입니다.

2명 이상의 심장학자가 QRS 복합파의 R 피크를 주석으로 추가한 ECG 파형을 불러오고 플로팅합니다. ECG 데이터 및 주석은 MIT-BIH 부정맥 데이터베이스에서 가져옵니다. 데이터는 360Hz로 샘플링됩니다.

load mit200
figure
plot(tm,ecgsig)
hold on
plot(tm(ann),ecgsig(ann),'ro')
xlabel('Seconds')
ylabel('Amplitude')
title('Subject - MIT-BIH 200')

Figure contains an axes object. The axes object with title Subject - MIT-BIH 200, xlabel Seconds, ylabel Amplitude contains 2 objects of type line. One or more of the lines displays its values using only markers

웨이블릿을 사용하여 R-R 간격 추정과 같은 응용에 사용할 수 있는 자동 QRS 검출기를 만들 수 있습니다.

다음 두 가지 주요 특징으로 인해 웨이블릿을 일반 특징 검출기로 사용할 수 있습니다.

  • 웨이블릿 변환은 신호 성분을 서로 다른 주파수 대역으로 분리하며 이를 통해 신호의 더 희소한 표시가 가능해집니다.

  • 검출하려는 특징과 유사한 웨이블릿을 쉽게 찾을 수 있습니다.

'sym4' 웨이블릿은 QRS 복합파와 유사하며, 이 점 때문에 이 웨이블릿은 QRS 검출에 좋은 선택입니다. 이 점을 좀 더 명확하게 보여주기 위해 QRS 복합파를 추출하고 팽창 및 평행이동된 'sym4' 웨이블릿을 비교한 결과를 플로팅합니다.

qrsEx = ecgsig(4560:4810);
fb = dwtfilterbank('Wavelet','sym4','SignalLength',numel(qrsEx),'Level',3);
psi = wavelets(fb);
figure
plot(qrsEx)
hold on
plot(-2*circshift(psi(3,:),[0 -38]),'r')
axis tight
legend('QRS Complex','Sym4 Wavelet')
title('Comparison of Sym4 Wavelet and QRS Complex')
hold off

Figure contains an axes object. The axes object with title Comparison of Sym4 Wavelet and QRS Complex contains 2 objects of type line. These objects represent QRS Complex, Sym4 Wavelet.

MODWT(최대 중첩 이산 웨이블릿 변환)를 사용하여 ECG 파형의 R 피크를 향상시킵니다. MODWT는 데시메이션되지 않은 웨이블릿 변환이며 임의의 샘플 크기를 처리합니다.

먼저, 디폴트 'sym4' 웨이블릿을 사용하여 ECG 파형을 레벨 5까지 분해합니다. 그런 다음, 스케일 4 및 5의 웨이블릿 계수만 사용하여 ECG 파형의 주파수 국소화 버전을 복원합니다. 스케일은 다음 근사 주파수 대역에 대응됩니다.

  • 스케일 4 -- [11.25, 22.5)Hz

  • 스케일 5 -- [5.625, 11.25)Hz.

이 대역은 QRS 에너지를 극대화하는 것으로 나타난 통과대역을 포함합니다.

wt = modwt(ecgsig,5);
wtrec = zeros(size(wt));
wtrec(4:5,:) = wt(4:5,:);
y = imodwt(wtrec,'sym4');

웨이블릿 계수에서 만들어진 신호 근사의 제곱 절댓값을 사용하고 R 피크를 식별하기 위해 피크 찾기 알고리즘을 채택합니다.

Signal Processing Toolbox™가 있다면 findpeaks를 사용하여 피크를 찾을 수 있습니다. 웨이블릿 변환으로 구한 R-피크 파형을 플로팅하고 자동으로 검출된 피크 위치에 주석을 추가합니다.

y = abs(y).^2;
[qrspeaks,locs] = findpeaks(y,tm,'MinPeakHeight',0.35,...
    'MinPeakDistance',0.150);
figure
plot(tm,y)
hold on
plot(locs,qrspeaks,'ro')
xlabel('Seconds')
title('R Peaks Localized by Wavelet Transform with Automatic Annotations')

Figure contains an axes object. The axes object with title R Peaks Localized by Wavelet Transform with Automatic Annotations, xlabel Seconds contains 2 objects of type line. One or more of the lines displays its values using only markers

R-피크 파형에 전문가 주석을 추가합니다. 자동 피크 검출 시간은 실제값 피크(±75msec)의 150msec 이내이면 정확한 것으로 간주됩니다.

plot(tm(ann),y(ann),'k*')
title('R peaks Localized by Wavelet Transform with Expert Annotations')

Figure contains an axes object. The axes object with title R peaks Localized by Wavelet Transform with Expert Annotations, xlabel Seconds contains 3 objects of type line. One or more of the lines displays its values using only markers

각각 전문가 시간 및 자동 피크 검출 시간인 tm(ann)locs의 값을 명령줄에서 비교할 수 있습니다. 웨이블릿 변환으로 R 피크를 향상시키면 적중율이 100%에 이르고 거짓양성을 제거할 수 있습니다. 웨이블릿 변환을 사용하여 계산된 심박수는 88.60비트/분이고 주석이 추가된 파형에 대한 심박수는 88.72비트/분입니다.

원래 데이터의 제곱 크기를 가지고 작업하면 R 피크를 분리하는 데 있어서 웨이블릿 변환이 얼마나 검출 문제를 더 쉽게 만드는지 확인할 수 있습니다. 원시 데이터를 가지고 작업하면 제곱한 S-파 피크가 R-파 피크를 10.4초 주변에서 넘어서는 경우처럼 식별에 실패할 수 있습니다.

figure
plot(tm,ecgsig,'k--')
hold on
plot(tm,y,'r','linewidth',1.5)
plot(tm,abs(ecgsig).^2,'b')
plot(tm(ann),ecgsig(ann),'ro','markerfacecolor',[1 0 0])
set(gca,'xlim',[10.2 12])
legend('Raw Data','Wavelet Reconstruction','Raw Data Squared', ...
    'Location','SouthEast');
xlabel('Seconds')

Figure contains an axes object. The axes object with xlabel Seconds contains 4 objects of type line. One or more of the lines displays its values using only markers These objects represent Raw Data, Wavelet Reconstruction, Raw Data Squared.

원시 데이터의 제곱한 크기에 findpeaks를 사용하면 12개의 거짓양성이 발생합니다.

[qrspeaks,locs] = findpeaks(ecgsig.^2,tm,'MinPeakHeight',0.35,...
    'MinPeakDistance',0.150);

R 피크의 극성 전환에 더하여 ECG는 흔히 잡음에 의해 손상됩니다.

load mit203
figure
plot(tm,ecgsig)
hold on
plot(tm(ann),ecgsig(ann),'ro')
xlabel('Seconds')
ylabel('Amplitude')
title('Subject - MIT-BIH 203 with Expert Annotations')

Figure contains an axes object. The axes object with title Subject - MIT-BIH 203 with Expert Annotations, xlabel Seconds, ylabel Amplitude contains 2 objects of type line. One or more of the lines displays its values using only markers

MODWT를 사용하여 R 피크를 분리합니다. findpeaks를 사용하여 피크 위치를 결정합니다. 전문가 및 자동 주석과 함께 R-피크 파형을 플로팅합니다.

wt = modwt(ecgsig,5);
wtrec = zeros(size(wt));
wtrec(4:5,:) = wt(4:5,:);
y = imodwt(wtrec,'sym4');
y = abs(y).^2;
[qrspeaks,locs] = findpeaks(y,tm,'MinPeakHeight',0.1,...
    'MinPeakDistance',0.150);
figure
plot(tm,y)
title('R-Waves Localized by Wavelet Transform')
hold on
hwav = plot(locs,qrspeaks,'ro');
hexp = plot(tm(ann),y(ann),'k*');
xlabel('Seconds')
legend([hwav hexp],'Automatic','Expert','Location','NorthEast');

Figure contains an axes object. The axes object with title R-Waves Localized by Wavelet Transform, xlabel Seconds contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Automatic, Expert.

적중율은 역시 100%이며 거짓 경고는 0개입니다.

지금까지의 예제에서는 modwt에서 생성된 신호 근사를 기반으로 매우 단순한 웨이블릿 QRS 검출기를 사용했습니다. 목표는 가장 강력한 웨이블릿 변환 기반 QRS 검출기를 구축하는 것이 아니라 신호 성분을 분리하는 웨이블릿 변환의 기능을 보여주는 것이었습니다. 예를 들면, 웨이블릿 변환이 피크 검출을 향상시키기 위해 신호의 멀티 스케일 분석을 제공한다는 사실을 이용할 수 있습니다.

참고 문헌

Goldberger A. L., L. A. N. Amaral, L. Glass, J. M. Hausdorff, P. Ch. Ivanov, R. G. Mark, J. E. Mietus, G. B. Moody, C-K Peng, H. E. Stanley. "PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals." Circulation 101. Vol.23, e215-e220, 2000. http://circ.ahajournals.org/cgi/content/full/101/23/e215

Moody, G. B. "Evaluating ECG Analyzers". http://www.physionet.org/physiotools/wfdb/doc/wag-src/eval0.tex

Moody G. B., R. G. Mark. "The impact of the MIT-BIH Arrhythmia Database." IEEE Eng in Med and Biol. Vol. 20, Number 3, 2001), pp. 45-50.

관련 항목