Optimal parameters for findpeaks in spectral analysis
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I'm trying to mark all the peaks in a Laser Induced Breakdown Spectroscopy (LIBS) spectrum where peaks are numerous and sharp. I'm playing with all the parameters in findpeaks function. Sadly, 'MinPeakDistance' and 'MinPeakHeight' don't work well due to the nature of the spectrum. Can anybody help to give some ideas for optimising the findpeaks?
%Loading data
FileName = uigetfile('*.txt','Please select spectra:');
fid = fopen(FileName,'rt');
temp = textscan(fid, '%f %f %f %f %f', 'headerLines', 8, 'Delimiter',';','CollectOutput', true);
fclose(fid);
temp= cell2mat(temp);
wavelength = temp(:,1);
raw_counts = temp(:,2); % Background subtracted
dark_counts = temp(:,3); % Background subtracted
counts = temp(:,2)-temp(:,3);
% Finding peaks
[PeakValue, PeakIdx] = findpeaks(counts,'MinPeakDistance',10);
figure(1)
plot(wavelength,counts,'b','LineWidth',2,'Markersize',6)
xlim([364 925])
xlabel('Wavelength (nm)')
ylabel('Intensity (arb. unit)')
text(wavelength(PeakIdx),PeakValue,num2str((1:numel(PeakValue))'))
Many thanks
댓글 수: 0
채택된 답변
Shubh Sahu
2020년 5월 5일
I assume that you need the peak which are sharp and with high intensity. I made some changes in your code please have a look. Change threshold according to your need.
%Loading data
FileName = uigetfile('*.txt','Please select spectra:');
fid = fopen(FileName,'rt');
temp = textscan(fid, '%f %f %f %f %f', 'headerLines', 8, 'Delimiter',';','CollectOutput', true);
fclose(fid);
temp= cell2mat(temp);
wavelength = temp(:,1);
raw_counts = temp(:,2); % Background subtracted
dark_counts = temp(:,3); % Background subtracted
counts = temp(:,2)-temp(:,3);
threshold=2500;
% Finding peaks
[PeakValue, PeakIdx] = findpeaks(counts);
PeakIdx=PeakIdx(PeakValue>threshold);
figure(1)
plot(wavelength,counts,'b','LineWidth',2,'Markersize',6)
xlim([364 925])
xlabel('Wavelength (nm)')
ylabel('Intensity (arb. unit)')
x=wavelength(PeakIdx);
y=PeakValue(PeakValue>threshold);
text(x,y,num2str((1:numel(y))'))
the result for the above code is some what like this.
댓글 수: 2
Sangwoo Yoon
2021년 3월 23일
Hi, can I ask a sily question?
I have LIBS data file ,where should I put this file to process LIBS data?
I want to know path to put this LIBS data.
I will appreciate your help.
From hs kim ( laser researcher in Mechanical engineering)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!