Optimal parameters for findpeaks in spectral analysis

9 次查看(过去 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

采纳的回答

Shubh Sahu
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 个评论
Yu Li
Yu Li 2020-5-5
Thank you very much! I then realize I should subtract the baseline before peforming findpeaks. Then I can use 'MinPeakHeight' and it works well!
Sangwoo Yoon
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 个)

类别

Help CenterFile Exchange 中查找有关 Parametric Spectral Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by