Fluorescence background, baseline correction and cosmic-ray spikes in Raman spectra
Many Raman spectra sit on a broad, sloping background, and many carry sharp spikes that no sample produced. The background is usually fluorescence. The spikes come from cosmic-ray particles that hit the detector. This page explains where both come from, how to reduce them at the instrument, and how to remove them in software in a way that you can check and repeat.
What the background looks like
A Raman band is narrow. A fluorescence background is broad and has no features. It covers the same wavelength range as the Raman signal, so the Raman bands sit on top of it.[2]
The baseline is the smooth curve under the bands. Baseline correction means that you estimate this curve and subtract it, so that only the bands remain. The baseline is not measured. It is a model, and every method makes a different model.
Why fluorescence outshines Raman
Raman scattering is a weak process. Only about one photon in 10⁷ is scattered inelastically, that is, with a change of energy.[6] The Raman scattering page explains the process.
A cross section measures how likely a molecule is to interact with a photon. It has the unit of an area (cm²). A larger cross section means a stronger process.
- Spontaneous Raman cross sections are about 10⁻³⁰ to 10⁻²⁸ cm² according to one paper[7] and about 10⁻³⁰ to 10⁻²⁹ cm² according to a review.[6]
- A fluorophore is a molecule, or an impurity, that absorbs light and then emits it again as fluorescence. Typical absorption cross sections of fluorophores are about 10⁻¹⁶ to 10⁻¹⁵ cm².[6]
Fluorescence appears when the laser wavelength overlaps an absorption band of a fluorophore in the sample. In many organic and biological samples, visible laser light excites such fluorophores.[2] Even a small amount of a fluorophore can matter, because its absorption cross section is so much larger than a Raman cross section.
The two processes also differ in time. One paper gives a luminescence lifetime of about 10–1000 ps, against about 10 fs for Raman scattering.[8] Since 10 ps = 10,000 fs, even the shortest luminescence lasts about 10,000 ÷ 10 = 1,000 times longer than Raman scattering. Time gating uses this difference (see the next section).
Reduce it at the instrument first
Before you correct a background in software, check whether the instrument can reduce it. These are the main hardware options.
A longer laser wavelength
The laser wavelengths in common use for Raman are 532, 785 and 1064 nm.[2] Fluorescence needs an overlap between the laser wavelength and an absorption band, and visible light excites many fluorophores.[2] A near-infrared laser therefore often excites less fluorescence. The laser wavelength page compares the choices.
Shifted-excitation Raman difference spectroscopy (SERDS)
Shreve, Cherepy and Mathies first proposed SERDS in 1992.[9][8] You record two spectra with laser wavelengths that differ slightly. The Raman bands move with the laser. The luminescence spectrum stays almost the same when the excitation energy changes a little. When you subtract one spectrum from the other, the luminescence cancels and the Raman information remains.[8] (This description follows a later paper. The 1992 original was not checked for this page.)
Time gating
Time-resolved Raman uses a pulsed laser and collects light only during the short pulse, before most of the luminescence is emitted. It does not work when the fluorescence lifetime is close to the pulse duration. The finite pulse also lowers the spectral resolution.[8]
Polarization
Emitted luminescence does not keep the polarization of the laser. Polarization-sensitive detection can therefore reject the cross-polarized part of the luminescence. But the parallel-polarized part is normally not negligible, so this method “has been ineffective” in removing fluorescence.[8]
The full list
Lieber and Mahadevan-Jansen list the hardware and software approaches in use: wavelength shifting, time gating, frequency-domain filtering, first- and second-order derivatives, and curve fitting with a high-order polynomial.[1] For a full review of fluorescence suppression, see Wei, Chen and Liu.[10]
Baseline correction methods
All the methods below estimate a smooth curve that stays under the bands. They differ in what you must choose and in how they fail.
| Method | What you choose | Main strength | When it fails |
|---|---|---|---|
| Manual points | Which points are “baseline” | Full control | Subjective, slow, hard to repeat[3][11] |
| Polynomial fit | Polynomial order; regions to fit | Simple | Through the whole spectrum, the curve rises into the bands. The order changes band ratios[4] |
| Modified polynomial (ModPoly, I-ModPoly) | Polynomial order; stopping tolerance | Automatic; needs no peak-free regions | The polynomial order still has to be chosen |
| Asymmetric least squares (AsLS) | Smoothness λ; asymmetry p | No peak model and no polynomial order[3] | No automatic rule for λ and p[3] |
| airPLS, arPLS | Smoothness λ | Weights set automatically[12][13] | λ must still be chosen |
Manual points
In many software packages, baseline correction is semi-manual. You mark the start and end of the peak regions on the screen, and the software joins the remaining points with straight lines. This approach is subjective, takes time and is hard to repeat.[3, p. 2] The documentation of one open-source baseline library says that selecting regions by hand is “generally not encouraged since it is time consuming” and “can lead to hard to reproduce results”.[11]
Polynomial fit
An ordinary least-squares polynomial fitted to the whole spectrum is pulled up by the bands, because it tries to pass close to every point. The fitted curve then sits above the true baseline, as the figure below shows. You can fit only regions with no bands, but that brings back the manual choice. The modified polynomial avoids it.
The polynomial order matters. A study of cervical tissue spectra found that too low an order under-corrects and lowers contrast. Too high an order oscillates, which shifts intensities and changes band ratios.[4]
Modified polynomial (ModPoly and I-ModPoly)
Lieber and Mahadevan-Jansen automated polynomial fitting with a simple change.[1] The loop below is the version in the pybaselines library, after Gan and co-workers (2006); Lieber’s original compares each new fit with the original data instead.[14, polynomial.py, modpoly]
- Fit a polynomial to the spectrum.
- Wherever the data are above the fit, replace the data with the fit value.
- Fit again to the modified data.
- Repeat until the fit changes by less than a set tolerance.
In each pass the bands are clipped a little more, so the curve sinks under them.[14, polynomial.py, modpoly] In the open-source pybaselines library, the default version of this loop follows a slightly modified version by Gan and co-workers (2006). An option makes it compare the fit with the original data instead, as in Lieber’s method.[14, polynomial.py, modpoly]
Improved ModPoly (I-ModPoly) was developed for biomedical spectra, where the autofluorescence is “usually a few orders of magnitude stronger” than the Raman signal. It adds a statistical step that takes the noise into account.[15] It also removes peaks in the first pass: points that lie more than one standard deviation of the residual above the first fit are left out.[15][14, polynomial.py, imodpoly]
Asymmetric least squares (AsLS)
Eilers and Boelens built this method on the Whittaker smoother,[16][17] which finds a smooth curve z that stays close to the data y. Their manuscript is dated 21 October 2005.[3] It is usually cited as an unpublished manuscript or a report of Leiden University Medical Centre.[5]
The smoother minimizes a sum with two terms:[3, eq. 2]
yᵢ is the measured intensity at point i, zᵢ is the baseline at point i, wᵢ is the weight of point i, and λ is the smoothness parameter. The first sum measures how closely the baseline follows the data. The second sum penalizes curvature.
Δ²zᵢ is the second difference of the baseline: the change in slope from one point to the next.
Minimizing S leads to one linear system of equations:[3, eq. 3]
W is a diagonal matrix that holds the weights wᵢ, and D is the second-difference matrix, so that Dz gives the values Δ²zᵢ. Only the main diagonal and the two diagonals on each side of it are not zero, so a computer solves the system fast even for long spectra.
The “asymmetric” part is the weight rule. Points above the current baseline (probably band) get a small weight. Points below it (probably baseline) get a large weight:[3, p. 4]
p is the asymmetry parameter, a number between 0 and 1. A small p lets the bands pull on the baseline only weakly.
The weights depend on the baseline, and the baseline depends on the weights. So the method iterates:[3, pp. 4–5]
- Start with all weights equal and solve equation 3. This gives an ordinary smooth curve.
- Set new weights with equation 4.
- Solve equation 3 again with the new weights.
- Repeat steps 2 and 3 until the weights stop changing. In practice 5 to 10 iterations are enough.
What the two parameters do. A larger λ makes the baseline stiffer. A smaller p moves it down, toward the lower edge of the noise.
- Eilers and Boelens found 0.001 ≤ p ≤ 0.1 and 10² ≤ λ ≤ 10⁹ generally good for signals with positive peaks, “but exceptions may occur”.[3, p. 5]
- They advise you to try values of λ on a grid that is roughly linear in log λ, so that each step multiplies λ by the same factor.[3, p. 5]
- In their worked example on simulated data, p = 0.05 and λ = 10⁶, and the iteration converged after 5 iterations.[3, p. 6]
- They could not give an all-purpose recipe for choosing the parameters automatically, so “human judgement will generally be needed”.[3, p. 3]
The penalty in equation 1 acts between neighboring points. So the same λ gives a stiffer or a looser baseline when the number of points or their spacing changes. Values that work on one instrument do not transfer to another without a check.
Automatic weights: airPLS and arPLS
Two later methods keep the Whittaker smoother but set the weights automatically, so p is no longer needed: airPLS (adaptive iteratively reweighted penalized least squares)[12] and arPLS (asymmetrically reweighted penalized least squares).[13] You still choose λ.
Parameter values used in practice
The values below come from different data. Use them as starting points for your own tests, not as settings to copy.
| Where the values come from | p | λ | Source |
|---|---|---|---|
| General range found by the AsLS authors | 0.001–0.1 | 10²–10⁹ | [3, p. 5] |
| AsLS authors’ worked example (simulated data) | 0.05 | 10⁶ | [3, p. 6] |
| One tissue study (colon tumors), tuned to its data | 0.02 | 70,000 | [18, sec. 2.4.1] |
| One mineral study, λ scanned on a log scale | — | 10⁴–10⁸ | [5, Fig. 1] |
pybaselines default, asls |
0.01 | 10⁶ | [14, whittaker.py] |
pybaselines default, airpls |
— | 10⁶ | [14, whittaker.py] |
pybaselines default, arpls |
— | 10⁵ | [14, whittaker.py] |
The library defaults are one library’s starting values, not recommendations. The tissue study prints its weight equation with “≤” in both cases, which is a misprint. Use the rule in equation 4.[18][3]
How the baseline changes your results
The baseline is not a cosmetic step. It changes the numbers that you report.
Library identification
A conference study corrected mineral spectra with six baseline methods and then matched them against a subset of the RRUFF mineral library. Every method ran with its default parameters, with no tuning.[5]
| Baseline treatment | Mineral species identified correctly |
|---|---|
| airPLS | 48.37% |
| ALS (AsLS) | 46.74% |
| FABC | 45.65% |
| Kajfosz–Kwiatek | 45.11% |
| Dietrich | 39.67% |
| Parente | 37.5% |
| No baseline removal | 8.15% |
Source: Carey and co-workers, Table 1, “Species” column.[5]
Read these results with care. The study is a two-page conference abstract, and the authors call the results preliminary. The library spectra were already baseline-corrected before the study; only the query spectra were corrected with each method. The methods built on Whittaker smoothing “tend to work well even without tuning”. Even with good baseline removal, species were identified correctly less than 50% of the time.[5] The library search page covers other reasons why a search can fail.
The choice of λ
In the same study, the authors fitted AsLS baselines to one mineral spectrum with λ from 10⁴ to 10⁸ on a log scale. Low values of λ overfit the peaks. Large values preserve the peaks but often force the baseline above the original spectrum. The authors call the choice of λ “largely subjective”.[5, Fig. 1]
Band ratios
A study of cervical tissue spectra found that the polynomial order is not interchangeable. Too low an order under-corrects and lowers contrast. Too high an order oscillates, which shifts intensities and changes band ratios.[4]
Cosmic-ray spikes
What they are
Most Raman instruments record the spectrum with a CCD (charge-coupled device), a light-sensitive chip like the one in a digital camera. When a high-energy particle hits the chip, it produces a sharp spike that always points up.[2] These particles are called cosmic rays. At ground level they are mainly muons, secondary particles that cosmic rays produce in the atmosphere.[19]
How often
The Particle Data Group gives the integral intensity of vertical muons above 1 GeV/c at sea level as about 70 m⁻² s⁻¹ sr⁻¹. The flux through a horizontal detector is about 1 muon per cm² per minute. Recent measurements favor a value 10–15% lower.[19, sec. 30.3.1]
Why they matter
Spikes hinder later analysis, above all multivariate analysis.[20] The standard preprocessing protocols start with spike removal.[2]
The modified Z-score method
Whitaker and Hayes published a simple despiking algorithm. It finds spikes with modified Z-scores and replaces them with an average of nearby points.[20] The steps below follow a later paper that reproduces the method.[18, sec. 2.4.2]
- Take the first difference of the spectrum, ∇yₜ = yₜ − yₜ₋₁. The slowly varying background almost disappears. A spike becomes a very large jump.
- Compute the modified Z-score of every difference value:[18, eq. 3]
∇yₜ is the first difference at point t, M is the median of all the ∇yₜ, and MAD (the median absolute deviation) is the median of the values |∇yₜ − M|.
- Flag every point whose |Zₜ| is above a threshold.
- Replace each flagged point with the mean of its neighbors within a small window, leaving the flagged points out of the mean.[18, eqs. 4–6]
NIST gives the same score for general outlier detection: Mᵢ = 0.6745 (xᵢ − x̃)/MAD.[21] The reason for the constant is a property of the normal distribution, which the NIST page does not explain: 0.6745 is the 0.75 quantile of the standard normal distribution (Φ⁻¹(0.75) = 0.6745). So for normally distributed noise, MAD ÷ 0.6745 estimates the standard deviation σ, and the modified Z-score is the distance from the median in units of this estimated σ. Unlike the mean and the standard deviation, the median and the MAD change little when a few values are extreme.
Choosing the threshold
For general outlier detection, Iglewicz and Hoaglin recommend labeling points with a modified Z-score above 3.5 in absolute value as potential outliers.[21] Raman work uses very different values:
| Where the value comes from | Threshold | Source |
|---|---|---|
| General statistical rule (not specific to Raman) | 3.5 | [21] |
| One Raman tissue study, after tuning (window parameter m = 5) | 4 | [18, sec. 2.4.2] |
| One SERS study; spikes replaced by the median of neighboring points | 8 | [22, Methods (i)] |
Default of the crr() function in the hyperSpec.utils R package |
30 | [23] |
Too low a threshold flags real data. The steep sides of a narrow Raman band also give large first differences. In the synthetic example below, the sides of the tallest band rise above 3.5, while the spike is far higher. Tune the threshold on your own spectra, and look at what it flags.
Repeated acquisitions
Cosmic-ray hits arrive at random times. A spike in one frame is not expected at the same pixel in a second frame of the same spot, while real bands appear in every frame. Recording two or more frames and comparing them therefore separates spikes from bands. For a published, fully automated method, see Schulze and Turner’s “two-dimensionally coincident second difference” spike removal.[24]
The order of processing
A recent review describes the standard order of preprocessing steps, after a protocol by Guo, Popp and Bocklitz:[2][25]
- Quality control. Find and remove outlier spectra.
- Spike removal. Remove cosmic-ray spikes.
- Calibration. Calibrate the wavelength or wavenumber axis and the intensity. See the silicon and polystyrene pages for axis checks.
- Baseline correction. Remove fluorescence and other background.
- Smoothing. Reduce the noise.
- Normalization. Scale the spectra to a common intensity, so that you can compare them.
Checklist
- Record the laser wavelength, laser power, exposure time and number of frames.
- If you see fluorescence, try to reduce it at the instrument first.
- Look for spikes in every spectrum. Remove them before any other step.
- Calibrate the axis with a standard.
- Choose a baseline method. Start with AsLS and test λ on a log grid.
- Overlay each baseline on the raw spectrum. Check that it runs under the bands.
- Check that band-free regions are near zero and not clearly negative after correction.
- Use the same method and parameters for all spectra that you compare.
- Smooth and normalize last.
- Report the method, its parameters, and the software name and version.
Sources
- C. A. Lieber and A. Mahadevan-Jansen. Automated method for subtraction of fluorescence from biological Raman spectra. Applied Spectroscopy 57(11), 1363–1367 (2003). DOI 10.1366/000370203322554518. pubmed.ncbi.nlm.nih.gov/14658149/. Statements on this page rest on the abstract (PMID 14658149).
- R. T. Vulchi, V. Morgunov, R. Junjuri and T. Bocklitz. Artifacts and Anomalies in Raman Spectroscopy: A Review on Origins and Correction Procedures. Molecules 29(19), 4748 (2024). DOI 10.3390/molecules29194748. europepmc.org/article/PMC/PMC11478279. Open access.
- P. H. C. Eilers and H. F. M. Boelens. Baseline Correction with Asymmetric Least Squares Smoothing. Unpublished manuscript dated 21 October 2005, 24 pp. (2005). prod-dcd-datasets-public-files-eu-west-1.s3.eu-west-1.amazonaws.com/dd7c1919-302c-4ba0-8f88-8aa61e86bb9d. Usually cited as an unpublished manuscript. Page numbers refer to the manuscript. Some papers cite it as a Leiden University Medical Centre report.
- H. Metin, S. Buyukkurt and M. Unal. Effects of Baseline Correction Strategy on Cervical Raman Spectral Analysis in a Late-Gestation Rat Model. Biosensors 16(11), 603 (2026). DOI 10.3390/bios16110603. europepmc.org/article/PMC/PMC13800688.
- C. Carey, M. D. Dyar, T. F. Boucher, S. Giguere, C. M. Hoff, L. B. Breitenfeld, M. Parente, T. J. Tague Jr., P. Wang and S. Mahadevan. Baseline Removal in Raman Spectroscopy: Optimization Techniques. 46th Lunar and Planetary Science Conference Abstract 2464 (2015). www.hou.usra.edu/meetings/lpsc2015/pdf/2464.pdf. Conference abstract; the authors call the results preliminary.
- C. F. G. C. Geraldes. Introduction to Infrared and Raman-Based Biomedical Molecular Imaging and Comparison with Other Modalities. Molecules 25(23), 5547 (2020). DOI 10.3390/molecules25235547. europepmc.org/article/PMC/PMC7731440. Review article.
- P. A. Kocheril, H. Wang, R. E. Leighton, D. Lee, N. Naji, W. Min and L. Wei. Far-field single-molecule vibrational spectroscopy and imaging. Chemical Science 17(11), 5297–5316 (2026). DOI 10.1039/d5sc07076g. europepmc.org/article/PMC/PMC12927031.
- M. A. da Silva Martins, D. G. Ribeiro, E. A. Pereira dos Santos, A. A. Martin, A. Fontes and H. da Silva Martinho. Shifted-excitation Raman difference spectroscopy for in vitro and in vivo biological samples analysis. Biomedical Optics Express 1(2), 617–626 (2010). DOI 10.1364/BOE.1.000617. europepmc.org/article/PMC/PMC3018003.
- A. P. Shreve, N. J. Cherepy and R. A. Mathies. Effective Rejection of Fluorescence Interference in Raman Spectroscopy Using a Shifted Excitation Difference Technique. Applied Spectroscopy 46(4), 707–711 (1992). DOI 10.1366/0003702924125122. Cited for the date and authorship. The description on this page follows da Silva Martins et al. (2010).
- D. Wei, S. Chen and Q. Liu. Review of Fluorescence Suppression Techniques in Raman Spectroscopy. Applied Spectroscopy Reviews 50(5), 387–406 (2015). DOI 10.1080/05704928.2014.999936. Further reading.
- D. Erb. Polynomial Baselines (pybaselines documentation). pybaselines version 1.2.1.post1.dev28, section "Selective Masking". pybaselines.readthedocs.io/en/latest/algorithms/polynomial.html. Open-source software documentation, read 28 November 2026.
- Z.-M. Zhang, S. Chen and Y.-Z. Liang. Baseline correction using adaptive iteratively reweighted penalized least squares. Analyst 135(5), 1138–1146 (2010). DOI 10.1039/b922045c.
- S.-J. Baek, A. Park, Y.-J. Ahn and J. Choo. Baseline correction using asymmetrically reweighted penalized least squares smoothing. Analyst 140(1), 250–257 (2015). DOI 10.1039/c4an01061b.
- D. Erb. pybaselines source code: polynomial.py (modpoly, imodpoly) and whittaker.py (asls, airpls, arpls). GitHub main branch. github.com/derb12/pybaselines. Open-source implementation, read 28 November 2026. A secondary source for the algorithms it implements.
- J. Zhao, H. Lui, D. I. McLean and H. Zeng. Automated autofluorescence background subtraction algorithm for biomedical Raman spectroscopy. Applied Spectroscopy 61(11), 1225–1232 (2007). DOI 10.1366/000370207782597003. pubmed.ncbi.nlm.nih.gov/18028702/.
- E. T. Whittaker. On a New Method of Graduation. Proceedings of the Edinburgh Mathematical Society 41, 63–75. DOI 10.1017/s0013091500077853.
- P. H. C. Eilers. A Perfect Smoother. Analytical Chemistry 75(14), 3631–3636 (2003). DOI 10.1021/ac034173t.
- B. Esteves, S. Pimenta, M. J. Maciel, M. Costa, F. Baltazar, M. F. Cerqueira, P. Alpuim, C. A. Silva and J. H. Correia. Raman spectroscopy for classification of neoplastic and non-neoplastic CAM colon tumors. Heliyon 10(17), e36981 (2024). DOI 10.1016/j.heliyon.2024.e36981. europepmc.org/article/PMC/PMC11402221.
- J. J. Beatty, J. Matthews and S. P. Wakely. Cosmic Rays (revised October 2021). In R. L. Workman et al. (Particle Data Group), Review of Particle Physics. Progress of Theoretical and Experimental Physics 2022, 083C01 (2022). DOI 10.1093/ptep/ptac097. pdg.lbl.gov/2022/reviews/rpp2022-rev-cosmic-rays.pdf.
- D. A. Whitaker and K. Hayes. A simple algorithm for despiking Raman spectra. Chemometrics and Intelligent Laboratory Systems 179, 82–84 (2018). DOI 10.1016/j.chemolab.2018.06.009. doi.org/10.26434/chemrxiv.5993011.v2. Open preprint at the ChemRxiv link.
- Detection of Outliers, section 1.3.5.17. NIST/SEMATECH e-Handbook of Statistical Methods. www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm. Gives the modified Z-score and the 3.5 rule of Iglewicz and Hoaglin.
- J. Eisiri et al. TB-SERS analyzer: Analysis tool for tuberculosis prediction based on Raman spectroscopy with machine learning and convolutional neural network. PLOS Computational Biology 22(7), e1014397 (2026). DOI 10.1371/journal.pcbi.1014397. europepmc.org/article/PMC/PMC13379083.
- K. Mayer. Cosmic ray removal: crr() (hyperSpec.utils reference). hyperSpec.utils R package documentation. konradmayer.github.io/hyperSpec.utils/reference/crr.html. Software documentation. The function implements the Whitaker and Hayes (2018) code.
- H. G. Schulze and R. F. B. Turner. A Two-Dimensionally Coincident Second Difference Cosmic Ray Spike Removal Method for the Fully Automated Processing of Raman Spectra. Applied Spectroscopy 68(2), 185–191 (2014). DOI 10.1366/13-07216.
- S. Guo, J. Popp and T. Bocklitz. Chemometric analysis in Raman spectroscopy from experimental design to machine learning–based modeling. Nature Protocols 16(12), 5426–5459 (2021). DOI 10.1038/s41596-021-00620-3. Cited through Vulchi et al. (2024).