Boxcar smoothing is a convenient way to smooth out noise in a spectrum, enabling peaks of interest to be more easily viewed, defined and characterized for properties like peak intensity, center wavelength, and FWHM (full width half maximum). It is a convenient complement to spectral averaging, particularly to minimize acquisition times, but must be used judiciously to avoid impacting the spectral resolution of the data acquired.
Why Use Spectral Smoothing?
Pixel to pixel variations in the signal that is read out by a photodiode array spectrometer are due in large part to counting noise, as discussed in our tech note, Noise in Spectrometers. This can lead to differences in the recorded signal for neighboring pixels illuminated by similar levels of light, and give the appearance of a “noisy” spectrum.
The best way to mitigate this source of noise is to acquire and average multiple scans prior to reading out a spectrum, as this can improve the noise by a factor equal to the square root of the number of successive scans averaged. However, this is not always convenient or even possible in some cases: very rapid events, continuous monitoring at high data rates, or at long acquisition times.
Boxcar smoothing (also known as spectral smoothing) is an alternative or complementary approach that can also smooth out noise in the spectrum. Boxcar smoothing is a moving average with wavelength. For example, a boxcar setting of 2 will average an additional 2 pixels on each side (5 in total) and assign that average value to the center pixel. A value of zero results in no spectral smoothing. Much like averaging, use of boxcar smoothing can improve the noise by a factor equal to the square root of the number of adjacent pixels averaged.
How Do I Control Spectral Smoothing?
Boxcar smoothing can be controlled using the “Boxcar Width” setting found just below “Scans to Average” in OceanView software. It determines the number of adjacent detector elements on either side of each pixel to be averaged in the smoothing calculation. The greater this value, the smoother the data and the higher the signal-to-noise ratio. If the value entered is too high, however, a loss in spectral resolution will result, as we will discuss in the next section.
Pixels averaged = 2*Boxcar Width + 1
Once the Boxcar Width value has been set, it must remain fixed for the acquisition of all dark, reference and sample spectra. If boxcar smoothing is adjusted for a new sample, a new dark and reference must be taken as well. This is to compensate for any pixel-to-pixel variations that are inherent to the detector array such as hot pixels and variations in the dark noise, such as are often seen in InGaAs detector arrays.
Spectral Smoothing versus Spectral Resolution
In most spectrometers, the optical resolution exceeds the distance between two pixels on the detector, and thus one can easily average the signal from several neighboring pixels to decrease noise without losing spectral resolution.
If the Boxcar Width is set too high, however, the moving pixel average will begin to combine adjacent pixels, which are truly seeing different levels of light. This effectively reduces the resolution of the spectrometer, and can begin to blur the spectral shape, reduce the true peak height, and/or prevent closely spaced peaks from being distinguished. In general, a low boxcar width should be used for spectra with sharp, closely spaced peaks like Raman peaks, laser lines, plasma emission or LIBS, as shown below.
A more smoothly varying spectrum like fluorescence can tolerate a much higher boxcar width setting (fluorescence spectrometers often have a much lower spectral resolution to maximize sensitivity in any case). Absorbance spectra must be considered on a case-by-case basis. Though many are slowly varying, some have fairly sharp spectral features that could be affected by boxcar smoothing. The illumination light source spectrum must also be considered; for example, a deuterium lamp spectrum contains a very sharp, intense D-alpha line that can saturate the detector, and should not be smoothed excessively.
To smooth data without affecting resolution, set the boxcar value equal to the pixel resolution of your spectrometer. The pixel resolution of the spectrometer is dependent on the spectrometer bench and slit size (see pixel resolution table here). For a Flame-S spectrometer with a 10 µm slit, for example, a boxcar width of 2 or more will begin to degrade the resolution of the spectrometer. A Maya2000 Pro configured for fluorescence with a 200 µm slit, however, can tolerate a boxcar width setting of 7 with no impact to resolution.
If the number of pixels averaged exceeds the pixel resolution of the spectrometer, the smoothed resolution of the spectrometer can simply be calculated by using the number of pixels averaged in place of the pixel resolution (see our FAQ on calculating optical resolution).
Conclusion – Best Practices
Boxcar smoothing is an excellent way to improve the S:N of your spectrum, but should be used carefully and ideally in combination with spectral averaging to achieve the best quality spectra. Some best practices to employ:
- Maximize the number of averages to improve S:N before adjusting the boxcar width setting
- Check that the desired boxcar width does not degrade the resolution of the spectrometer
- If boxcar width does impact resolution, ensure that this will not compromise the data quality for your application
- Keep the boxcar width setting the same for all dark, reference, sample spectra
Curious to know more about boxcar smoothing? Learn more about the math behind the scenes below, or contact us to discuss the ideal boxcar width setting for your application.
The Mathematical Details of Boxcar Smoothing Calculations
The boxcar width setting in software determines the number of pixels to be averaged together. A value of n specifies the averaging of n pixels to the right and n pixels to the left.