24 jul. 2014

SNV and Detrend (Shootout 2002 NIR with R)


I want to say “thanks” to Aoife Gowen (@eefieg) for the references, in her last article to this blog. The article is the part 4 of a series called “NIR hyperspectral image analysis using R” and the title of this article is: "Pretreatments and partial least square discriminant analysis". (NIR News Vol.25 Nº 5 August 2014).
 
Lately I am playing with the Shootout 2002 data so we can summarize on this data things that we have seen before in the blog.
 
In the last post, I was using the raw spectra and that is not (in some cases) the best way to develop a calibration. So we treat the raw spectra with math treatments to improve the correlation of the spectra with the reference values, and to make more transferable calibrations. If we use a correct math-treatment the regressions will use less terms, and will improve the statistics, and the transferability.
Now I write the script used to treat the matrix X1 (training spectra matrix in Instrument 1):

>par(mfrow=c(2,2),ps=14)
>matplot(indices,t(nir.training1$X),type="l",col=1,
 + main="Raw Spectra")
#Applying "SNV" to the Shootout 2012 Data>X1_snv<-scale(t(nir.training1$X),center=TRUE,scale=TRUE)
>matplot(wavelength2,X1_snv,type="l",
 + xlab="Wavelength (nm)",ylab="1/R",lty=1,
 + col=2,main="SNV math_treat")
#Applying "Detrend" to the Shootout 2012 Data
>library(pracma)
>X1_detrend<-detrend(t(nir.training1$X))  
 +matplot(wavelength2,X1_detrend,type="l",
 +lty=1,xlab="Wavelength(nm)",ylab="1/R",col=3,
 +main="Detrend math_treat")
#Combining SNV with Detrend
>X1_snvdt<-detrend(X1_snv,tt="linear")
>matplot(wavelength2,X1_snvdt,type="l",lty=1,
 +xlab="Wavelength(nm)",ylab="1/R",col=4,
 +main=" SNV+Detrend math-treat")
 

As we are writing this script, we see on the Active Graphics Window the spectra , so we can compare them.

These are some of the most familiar anti-scatter math-treatments, apart from others like MSC.

 

We will continue with this type of exercises in the next posts.

No hay comentarios:

Publicar un comentario