I have a problem with the removal of background of my SERS spectra. The raw spectrum looks like thisNormally I use the Asymetric least square baseline removal after I create a spectrum with a flat line instead of the first big peak and then I subtract it from the original spectrum. In spectra like this when I follow this procedure I get negative values in the beggining after the removal of the background. I am not an expert but negative values should not exist right? Any ideas how to solve this? Thank you all in advance
You probably have an edge filter to remove the backscattered light (Raleigh scattering) from the very low wavenumber region. So the "first big peak" is probably because of the transparency of the filter. You should not replace it with a flat line, just simple omit it and have a spectrum from ~ 50-200 cm-1 up to the desied value. If you try the Asymetric least square baseline removal for this part of the spectrum only, it will probably work fine. ALS does not like sudden, big jumps.
The ‘baseline’ of your data appears to be something resembling a logistic curve, although perhaps reversed. You will likely have to fit the section where the x- values are greater than 1000, then evaluate it over the entire x-range. See if the approach in Shifting Baselines of Raman Spectra suggests a solution to your problem.
Thanks a lot! I tried that already and it really works fine but due to the analysis of the samples we needed to know what is happening with the first big peak (that's why I try to replace it with the flat line). Thanks again for your kind help!
I am not certain what your data should look like, or what might be causeing the strange baseline. Another option sould be a digital filter to remove the low-frequency variation, however without your data, I cannot suggest a specific design. (A bandpass filter might be the best option.)
This took a bit longer than I had anticipated, because it is difficult to determine what the true baseline is (and I am still not certain of it), and then devise a way to isolate it.
This seems to work:
D = load('test spectra.mat');
A = D.AMAZON2H1;
A2 = A;
A2 = A2(40:1440,:);
figure
plot(A2(:,1), A2(:,2:end))
grid
[L,P] = islocalmin(A2(:,2), 'MinSeparation',200);
locs = A2(L,1);
Bi = interp1(A2(L,1), A2(L,2:end), A2(:,1), 'pchip');
figure
plot(A2(:,1), A2(:,2:end))
hold on
plot(A2(:,1), Bi, '-k')
hold off
grid
title('Data & Estimated Baselines')
figure
plot(A2(:,1), A2(:,2:end)-Bi) % Success!
grid
title('Baseline-Corrected Data')
It is likely not perfect, however it provides a basis for your further experiments to tweak it to give the result you want. On the basis of exploring your data graphically, I chose the index range of 40:1440. There is nothing absolute about this, I chose it because it appeared to correct the spectrum of your data that likely has the most information.
If you want to explore this technique in a bit more detail, include this plot that illustrates the approach I used:
figure
plot(A2(:,1), A2(:,2))
hold on
plot(A2(:,1), Bi(:,1), '-k')
plot(locs, A2(L,2), 'vr')
hold off
grid
See the documentation on the islocalmin and interp1 functions to understand how they work here.
I am not certain what it should look like, so my code may need to be tweaked. (For some reason, the plot image I posted appeared only as the file name, and not the image. If I had known that, I would have attached it separately.)
I apologise for my late reply. Actually the first column is the wavenumbers and the rest are several spectra. I just included more than one so I can provide an idea of how they look in general. Do you need me to concert those in another way? Thank you so much for your help!
@Csaba — The one you are commenting on belongs to Erini Bernikola (and should have been posted as a Comment to my Answer rather than an Answer). Mine is the first Answer in the thread.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/482457-raman-spectra-background-removal#comment_751968
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/482457-raman-spectra-background-removal#comment_751968
Sign in to comment.