25 sept 2014

Hyperspectral Imaging and Applications Conference 2014

Few days for this interesting Conference, you can see the programme in this link or downladed in PDF here.

NIR Hyperspectral Imaging will be part of the applications conference, for some of the speakers, like Aoife Gowen talk about:


For more details visit the Web Page at: http://www.hsi2014.com/

15 sept 2014

Adapters from USB to Serial RS232 / RJ45

I have found three kind of connections when installing a NIR to a Computer: Serial Port, USB and RJ45.
 
Now is quite difficult to find a computer with a serial port, so the best option is to connect an adapter from USB to Serial RS232, but I have found that some of them performs fine to all the instruments and software´s, and others give connection problems. The adapters come with the drivers disk

  
USB connections are not a problem, because all the computers have several USB ports.
 
Some new NIR use the Ethernet connection RJ45, and normally all the computers have one, but we need another to connect the computer to a Network and Internet. We can buy a RJ45 board and install it into the computer, but I heard that in some cases is not easy the configuration, so one easy and quick solution is to connect an adapter from USB to RJ45. There are several in the market. They come with the drivers for 32 or 64 bytes.
 


14 sept 2014

SNV + Detrend with "Prospectr" package

I was using the function “detrend” from the “pracma” package, but we have the detrend function in the “prospectr” package. Using this last option we combine the SNV with the Detrend, which is a very common math-treatment to remove the scatter.

Looking to the function script the “sweep” function is used to center and scale the spectra matrix.
 
Using the shootout 2002 data:
>X1_detrend2<-detrend(nir.training1$X,
+wav=as.numeric(colnames(nir.training1$X)))
>matplot(wavelength2,t(X1_detrend2),type="l",lty=1,
+xlab="Wavelength(nm)",ylab="1/R",col=3,
+main="SNV + Detrend")



I compare with these plots the way prospectr runs the SNV detrend versus the other way I used in other posts.


Green with prospectr package and blue with pracma package.


10 sept 2014

2nd derivative using "apply" and "diff"


This is a simply exercise, where we convert the raw spectrum into its first derivative, and into its second derivative, using the function apply, and the function diff.
I use the shootout 2002 data available in the package ChemometricsWithR.

X1_diff1<-t(apply(nir.training1$X,1,diff))

In this case the 1 is to apply the function difference to the rows (spectra).
We don´t add more than the default options to the function diff, so the lag=1 and the value of differences=1.

The spectrum changes (losing 1 data point) to the black spectrum in the plot at the end of the post.
plot(as.numeric(colnames(X1_diff1)),X1_diff1 [1,],type="l",xlab="Wavelength (nm)",ylab="1/R (1st derivative)",lty=1,col=1)

We can say briefly that the second derivative is the derivative of the firs derivative; we can do this changing the value of the option “differences” from 1 to 2, losing, in this case two data points.

X1_diff2<-t(apply(nir.training1$X,1,diff,differences=2))

par(new=TRUE)

plot(as.numeric(colnames(X1_diff2)),X1_diff2[1,],type="l",xlab="Wavelength (nm)",ylab="1/R (2nd derivative)",lty=1,col=2)

The spectrum of the second derivative is the red one in the plot, compared with the black one of the first derivative.
This way to do the derivatives is very noisy, so in future post we will try to use gap derivative which is the way that softwares as Unscrambler, Win ISI and many others use the derivatives.

5 sept 2014

Wavelength Diagnostics in R


In the Wavelength diagnostics we compare the spectrum of a certain material (for example polystyrene) in our instrument with the nominal’s supplied by the manufacturer. We compare the peak positions and the difference between the nominal and the found value is what we can call “Delta”.
The manufacturers give us a Delta limit (depending of the instrument) and if the value is out of that limit for any peak the result will be FAIL. This is what we normally call “Accuracy Test”.
In the test we check also the Precision for every peak, calculating the standard deviation for ten repetitions. As for the Delta there are some tolerance limits.
If is important to check the Bandwidth delta and precision value.
This picture shows the table provide by VISION for the Wavelength Test.
 

 We can play to import this table in R to create a function to calculate the Wavelength diagnostics and to get the same results.
 
 

3 sept 2014

IDRC 2014 Conference Presentations


 
For those of us who has not been at the IDRC 2014, we can see (and download) the presentations at the  IDRC Website.

There are very nice presentations including:  history, fundamentals, chemometrics, applications, …….

Thanks to CNIRS for sharing these presentations.

You can see the Photo Albums of the Conference.