20 ene 2018

Analyzing Soy meal in transmitance (part 2)

This is the second of the posts about analyzing soy meal unground in an Infratec, adding the sample directly to the conveyor in the same way that we do with wheat or barley. The range wavelength in the Infratec is from 850 to 1050nm, in steps of 2 nm, so we have a total of 100 data points.

Once we have decided one of the math treatments to work, we can apply a Principal Components analysis to the data. This way we can understand better the structure of the data.
X_msc_prcomp<-prcomp(X_msc)

This way we obtain two importan matrices, the score matrix and the loadings matrix (We have been talking about this matrices in other posts).
In this post we are going to check the loadings that we can see graphically in two ways: as spectra or in the Principal Component space.
If we want to se them as spectra (first three loadings), run this script in R:
>matplot(wavelengths,X_msc_prcomp$center,type="l",
 xlab="wavelengths",ylab="transmitance")
Or we can see them in the Principal Components space, were we can see the range of variation
and this is the script for this last plot:
 par(mfrow=c(1,2),pty="s")
 offset<-c(0,0.09) # to create space for labels
 plot(X_msc_prcomp$rotation[,1:2],
      type="l",xlim=range(X_msc_prcomp$rotation[,1])+offset,
      xlab="PC1",ylab="PC2")
 #identify(X_msc_prcomp$rotation[,1:2])
 points(X_msc_prcomp$rotation[c(33,64,100),1:2],pos=4)
 text(X_msc_prcomp$rotation[c(33,64,100),1:2],pos=4,
      labels=paste(c(914,976,1050),"nm"))

offset<-c(-0.05,0.25) # to create space for labels
plot(X_msc_prcomp$rotation[,2:3],type="l",
     xlim=range(X_msc_prcomp$rotation[,1])+offset,
     xlab="PC2",ylab="PC3")
#identify(X_msc_prcomp$rotation[,2:3])
points(X_msc_prcomp$rotation[c(33,64,100),2:3],pos=4)
text(X_msc_prcomp$rotation[c(33,64,100),2:3],pos=4,
     labels=paste(c(914,976,1050),"nm"))
 
 


19 ene 2018

Implementing Good Product in Win ISI Diagram

New features Good Product added to Win ISI Diagram.
 

 

 
https://www.linkedin.com/feed/update/urn:li:activity:6357682248438943744
https://www.linkedin.com/feed/update/urn:li:activity:6357682248438943744

18 ene 2018

Analyzing Soy meal in transmitance (part 1)

One of the common applications in NIR analysis is the measure of soy meal, to predict Moisture, Protein, Fat and Fiber. As we know, Protein is the most important parameter and it is important to get an accurate prediction.

What about to measure soy meal in a transmittance instrument like Infratec?. Infratec has a smaller range, but this range (850 to 1050 nm) penetrate most into the sample, so we can measure in transmittance with a certain path length to avoid saturation. With this purpose, a certain number of samples with known reference value for the parameters was analyzed in the instrument, putting the soy meal unground and directly into the conveyor.

Spectra of the samples was export in a spectra file and lab values added.

Spectra file was export into R software as raw spectra, and a multiple scatter correction was added.


X<-as.matrix(sm_ift[,6:105])
wavelengths<-as.matrix(seq(850,1048,by=2))
matplot(wavelengths,t(X),type="l",

        xlab="wavelengths",ylab="transmitance")

#Math Treatments
#Multiple Scatter Correction
library(pls)
X_msc<-msc(X)

matplot(wavelengths,t(X_msc),type="l",
        xlab="wavelengths",ylab="transmitance")

#Mean Centering
  #We can check in wich areas is the variation of the data.
X_msc_mc<-scale(X_msc,scale=FALSE)


#We can see the variation at every wavelength with a boxplot.
boxplot(X_msc)






20 dic 2017

Previous steps for a LOCAL calibration (part II)


Continuing with the previous post:
Previous steps for a LOCAL calibration
 
We can check the Mahalanobis distances (GH) from the samples from one product respect to the samples of other product, and to check the average MD, the maximum and minimum and how many samples are over a certain cutoff. The idea is to create a multiproduct library but not with products that are very different, so they have to maintain certain certain similarities in order to take the maximum benefits from the LOCALs calibrations
 
In the case of the green samples (pork meat meal type 2), the GH go from 1.109 to 6.375 versus the blue samples (pork meat meal type 1) with 17 samples over 3.00 (from 105) with an average of 2.43 respect to the PC space of the blue samples (pork meat meal type 1).

In the case of the green samples (pork meat meal type 3), the GH goes from 1.561 to 8.650 with 24 samples over 3.00 (from 40) with an average of 3.71 respect to the PC space of the blue samples(pork meat meal type 1).

In the case of the red samples ((pork meat meal type 4)), the GH go from 0.912 to 14.462 with 211 samples over 3.00 (from 402) with an average of 3.91 respect to the PC space of the blue samples  (pork meat meal type 1).
 
The GH high values are due specially to the second PC because are samples with higher protein than the samples in the blue group.
 
I seems that all these meat meal products can be merged in a unique library to develop a LOCAL calibration and we will see their configuration, extension, maintenance and validation in more coming posts

8 dic 2017

Previous steps for a LOCAL calibration.

With four different sets of Meat meal (4 species of pork), I develop a lib file for each one. I see one of them on the 3D graph and add the others as secondary files in order to see how they match one with the others. Looking to the correlation of the scores respect their own libraries it is clear that for all of them the moisture is the main source of variation and is explained in all in the first principal component. The second principal component is the highest correlated to the second principal component in the four libraries.
Three of the families set overlap almost in the protein range, but one of them had a broad range in the low protein, so the idea is to see this in the scores maps.
In this plot, we see the scores of the four sets in the PC space of one of the libraries, overlapped.
 
 
Dark blue:   Range of protein from 44,26 to 77,3
Green:        Range of protein from 69,50  to 79,51
Light blue:   Range of protein from 69,50  to 82,90
Red:            Range of protein from 66,51  to 87


If we see the map of scores, which contain the second principal component, for all the groups and the plot for the dark blue group divided in 3rds we can get some conclusions.
 This are previous studies in order to build a Local calibration, so more details will came in next posts.