peak width calculation methods

조회 수: 24 (최근 30일)
sarmad m
sarmad m 2017년 4월 13일
댓글: Christian 2020년 6월 23일
Hi
I'm calculating peak width using half-prominence method . For the peak in the rectangle is there is a method to make the horizontal line the finds the widths to shift up or make vertical line like this image
? . I tried both methods for peak width detection (half-width, half-prominence ) but it gave me the same results .
Half-prominence
close all
order =9 ;
framelen =15;
lx = 20;
% generate sinal
x = 1:1:1432;
y = (AV)';
y = sgolayfilt(y,order,framelen);
% get derivatives
dy = diff(y);
dx = diff(x);
dy_dx = [0 dy./dx];
findpeaks(y,x,'Annotate','extents','MinPeakProminence',0.006);
% get peaks with width computed by 'findpeaks'
[pks,locs,peakWidth1,p] = findpeaks(y,x,'MinPeakProminence',0.006);
half-height :
order =7 ;
framelen =11;
x=-AV;
lx = 20;
sgf = sgolayfilt(x,order,framelen);
hold on;
sgf= 0.02-sgf;
findpeaks(sgf,'MinPeakProminence',0.004,'WidthReference','halfheight','Annotate','extents');
[pks,locs,widths,proms]=findpeaks(sgf,'MinPeakProminence',0.004,'WidthReference','halfheight');
pks = -pks;
plot(locs,pks,'g*');
text(locs+.02,pks,num2str((1:numel(pks))'));

채택된 답변

Greg Dionne
Greg Dionne 2017년 4월 14일
It seems you are interested in the relative height of the spike with its immediate vicinity (not with respect to higher peaks). To do that, try subtracting off the results of a lowpass or median filter first.
findpeaks(sgf - medfilt1(sgf,21), ...)

추가 답변 (2개)

Matlaber
Matlaber 2019년 1월 14일
I still cannot get the meaning how the width being calculated.
  댓글 수: 3
Matlaber
Matlaber 2020년 5월 9일
I am asking that too.
Christian
Christian 2020년 6월 23일
Me too...

댓글을 달려면 로그인하십시오.


sarmad m
sarmad m 2017년 4월 27일
편집: sarmad m 2017년 4월 27일
I have added median filter, and tested this data below.
and I got these widths values using this code :
close all
% plot default annotated peaks
subplot(2,1,1);
order =11 ;
framelen =15;
lx = 20;
% generate sinal
x = 1:1:1432;
y = -(Averages)';
y = sgolayfilt(y,order,framelen);
% get derivatives
dy = diff(y);
dx = diff(x);
dy_dx = [0 dy./dx];
%plot(x);
findpeaks(y - medfilt1(y,50),x,'Annotate','extents','MinPeakProminence',0.003);
% get peaks with width computed by 'findpeaks'
[pks,locs,peakWidth1,p] = findpeaks(y,x,'MinPeakProminence',0.003);
subplot(212);
plot(x,y);
My problem is with peak number 6 width which is= 24 ?, I think it calculates the width at the start and end edges .
  댓글 수: 1
Greg Dionne
Greg Dionne 2017년 4월 27일
looks like you forgot the medfilt1 in the second call to findpeaks.
You may also try using 'WidthReference' 'halfheight' if you're after FWHM values once you've removed the baseline.
load data.csv
close all
% plot default annotated peaks
order =11 ;
framelen =15;
% generate sinal
y = -(data)';
y = sgolayfilt(y,order,framelen);
%plot(x);
findpeaks(y - medfilt1(y,50),'Annotate','extents','MinPeakProminence',0.003);
% get peaks with width computed by 'findpeaks'
[pks,locs,peakWidth1,p] = findpeaks(y - medfilt1(y,50),'MinPeakProminence',0.003);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by