Optimal parameters for findpeaks in spectral analysis
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yu Li
el 2 de Mayo de 2020
Comentada: Sangwoo Yoon
el 23 de Mzo. de 2021
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 comentarios
Respuesta aceptada
Shubh Sahu
el 5 de Mayo de 2020
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 comentarios
Sangwoo Yoon
el 23 de Mzo. de 2021
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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Parametric Spectral Estimation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!