Piecewise Direct Standardization (PDS) is a method that was proposed by Wang et al. (1991) to transfer NIR spectra from one instrument to another. As explained by Bouveresse & Massart (1996), several methods and algorithms were subsequently proposed in the literature to improve the transfer procedure. However, this post is limited to the presentation of the original PDS method.
Master and slave data
In this example, we will look at transferring the spectra collected with the ASD LabSpec 4 spectrometer (slave instrument) to the PHAZIR handheld spectrometer (master instrument). Refer to the Phazir & ASD section for details. Let’s load these data (available from the RNIR GitHib repository) and extract their corresponding wavelengths:
Note: As already pointed out in the Phazir & ASD section, the ASD spectra were acquired over a wider wavelength range and at a higher resolution than the PHAZIR spectra. This actually constitutes an advantage for performing PDS as more sampling points are available in the slave data to predict the master data during the PLS regression step. However, to keep this example simple and generic, we will resample the ASD spectra so they match the PHAZIR spectral resolution and range.
Resampling
There are many ways to resample spectral data and a future section of RNIR will be dedicated to this topic. In the meantime, the resampling of the slave data is performed here using a simple linear interpolation with R’s approx function:
Now, let’s take a look at the master and slave spectra after performing SNV to correct for scattering effects.
We see that the master and slave spectra are very similar, which is a good news and will contribute to facilitate the transfer between the two instruments.
The PDS algorithm
The PDS method relates the spectral intensities obtained at the wavelength i on the master instrument to the wavelengths contained in a moving window (from i-k to i+k) on the slave instrument. For each wavelength of the master instrument, a Partial Least Squares (PLS) regression model is then built between the spectral intensity of the master and slave instruments. The regression coefficients of the PLS model (with length 2k+1) form the ith column (between rows i-k and i+k) of a banded diagonal transfer matrix P. See Bouveresse & Massart (1996) or Wulfert et al. (2000) for schematic representations of this process. In R, the PDS algorithm that computes the transfer matrix P can be written as follows:
Applying PDS
Let’s now use our PDS function to compute the P matrix that will help us transferring spectra from the slave to the master instrument. We will be using a half moving window size (MWsize) of 2, meaning that 3 points will be selected in total (since the full window size is actually equal to 2[MWsize-1]+1), and 2 latent variables in the PLS regression.
Once we have computed the transfer matrix, performing the standardization is straightforward. Note however that, in addition to the transfer matrix P, the PDS algorithm presented above also computed an intercept term. This is because the data were not mean-centered. If you mean-center the data beforehand, the intercept term will be null. Therefore, in our case, to compute the standardized slave data, we multiply the spectral matrix by P and add the intercept:
It can be seen that the new standardized spectra match the ones of the master instrument. However, because of the nature of the PDS algorithm that uses a moving window, both ends of the standardized spectra need to be truncated. To improve the visibility, we can also remove the old slave data from our plot:
Finally, after PDS, it is often necessary to smooth the spectra due to the apparition of artifacts in the signal. This can be done as presented in the Smoothing section.