#
Page tree
Skip to end of metadata
Go to start of metadata

In this tutorial quantitative analysis by means of Perception Studio and by means of Matlab is described.


Outline

In many industries quantitative measurement of spectral information gives a valued input for e.g. quality inspection. This page summarizes an example for modelling the API (active pharmaceutical ingredient) of pills.

The goal is to find a model which allows the measurement of the amount of the chemical ingredient in pills. The achieved model is applied to the measurement data and results in a gray-value image, where its pixel values correspond to the quantity of the modelled substance. Of course such a model can get applied in real-time to enable industrial real time inspection e.g. in the field of pharmaceutical production.

In this tutorial pills of different Ibuprofen content are investigated with a NIR line-scan camera FX17 of Specim, compliant for CCI processing. After a short exploratory analysis, the CCI-Constrain method is used for modelling, after that Matlab is used to do chemometric modelling.

Data, Samples & Measurement

Download the example project Ibuprofen pills from the download section.

 ibuprofen
TitlePills of different Ibuprofen concentration
CategoryPharma
Sample DescriptionFrom top to bottom: 74, 60, 49, 23 m/m Ibuprofen in Lactose (monohydrate).

From left to right: pill side 1 and 2

Tablet pressing in a Lactose matrix
Reference material used:
Commercial pill of active ingredient 600 mg

Steps:

  • Removal of coating
  • Milling of active ingredient tablets
  • Mixing with Lactose monohydrate
  • Homogenization (mortar)
  • Pressing of tablets (≈ 5 t/m²)

Sample ID-
Sample LocationPerception Park Lab
DonorManfred / Perception Park
Date of Measurement-
Measurement SystemSpecim FX17
Measurement DescriptionMeasurement in reflectance
Measurement SetupIllumination: Halogen spots 2-sided.

Background: black non-woven fabric.

Measurement ID20180222161347
FormulaUnknown
AnalysisSample preparation: Ibuprofen 600 without coating mixed with lactose and pressed to tablets. Each approx. 1g.
PreprocessingUnknown
Spectroscopic DiscussionSpectral bands strongly correlated with Ibuprofen are in the range 1115-1230nm.
Sample Image(s)

Start the project

Install the example project by double clicking on the downloaded file and following the instructions of the installer.

Open the Perception Studio program (e.g. from a link on your desktop) and change to the Start perspective.

Switch to example projects and select Ibuprofen pills from the list shown in the Start perspective.

Now, all data are loaded into the Perception Studio program, please give the system some seconds time to load all the data.

Exploratory analysis of the data

Change to the Explore perspective and select the hyperspectral cube ibuprofen from the project browser.
In the Explore perspective the loaded hyperspectral data (data set ibuprofen) is visualized by an image in the center of the perspective as well as a spectra view on the bottom and a cube intersection view to the right.

Explore spectral information

The loaded example data contains predefined spectra sets. Have a look in the spectra view and study the shown spectra sets.

The reflectance measurement was done in the NIR range (~950-1700nm). Spectral bands are strongly correlated with the varying Ibuprofen content in the range 1115-1230nm.

Explore the nature of nested information

Preview Feature - find candidates for appropriate preprocessing

In the following image the Preview of the data is shown.

Intensity1st derivative2nd derivative

Without preprocessing the pills are hardly distinguishable by their color information in the image above. By applying the 1st derivative the varying Ibuprofen content gets visible through a greenish color gradient. The 2nd derivative shows clear differences between pills of different Ibuprofen content.

The Preview feature correlates with the varying Ibuprofen content when preprocessing "1st derivative" or "2nd derivative" is applied.
This indicates that "1st derivative" or "2nd derivative" are potential candidates for appropriate preprocessing when the extraction of the Ibuprofen content is the goal.

Statistical Features - judge the quality of spectra

Various statistical features can get selected from the ribbon menu on the top of Perception Studios Model perspective.
The statistical maximum of the 1st derivative of the pills shows uncertainties on the border of the pills (light area).
Position the mouse on such an area and study the spectral information.

The spectra of an "uncertain" pixel is shown above in white color.
As you can see, the spectra hardly correspond to the spectra from the center of the pill. It is good practice to not consider such pixels in further investigations - the spectral response seems to be distorted by measurement errors and therefore seems not to be trustworthy.

For more information on exploratory investigations of hyperspectral data see Exploratory analysis of plastics.

Model the application relevant information

In this tutorial our goal is to model the Ibuprofen concentration of pills. Each pill was measured twice, once from side 1 (top side) and the once from side 2 (bottom side). Side 1 of all pills is used for training, side 2 is used to validate the developed model later on.

Perception Studio - CCI-Constrain Method

The following procedure describes the modelling process by means of the CCI-Constrain method.

Switch to Perception Studios Model perspective and select Constrain as CCI method from the ribbon menu on the top of this perspective.

As you can see the modelling process automatically results in an image which describes the Ibuprofen content with the color red.
This is because the selected spectra sets were manually given colors in correspondence to the concentration of Ibuprofen in the pills. The spectra set of 73.6% Ibuprofen is deep-red, while the spectra set of 23.4% is shown by a light-red color.

To do the chemometric modelling, we need to assign nominal quantitative values to the spectra sets. In case of the CCI-Constrain method, just constrain (e.g.) gray-values, which correspond to the nominal quantitative values of the pills, to the spectra.

In the image above, the gray-values 74, 60, 49 and 23 got assigned to the spectra (click on the color field below Constraint to specify a color or gray value).
Because of the results from the exploratory investigation, the preprocessing 1st derivative was selected (in the ribbon above).

Validation of results

To validate the obtained results, move your mouse over the resulting image and inspect the image's gray-values. As you can see, the gray-value corresponds to the "constrained" gray-values.

Fine-tune the model to be more sensitive in order to reach a better match between your expectations (constrained values) and the results. To do so, move the slider from left to right. Be sure to find a setting which is a good trade-of of "robustness" and "sensitivity".

The obtained images for different preprocessings are analyzed statistically in the illustration below (by means of Matlab).

1st derivative - sensitivity 42nd derivative - sensitivity 4

1st derivative2nd derivative
nominalmeasureddeltameasureddelta
7471.8-2.270.8-3.2
6062.0+2.060.9+0.9
4947.8-1.247.7-1.3
2325.4+2.424.9+1.9

The measurement results obtained by 1st derivative and 2nd derivative are more or less comparable.
Since the noise in the results is more in value when 2nd derivative is applied (standard deviation is more in value), the model obtained by applying the 1st derivative as preprocessing method might is preferred.

For more information on modelling see Model Hyperspectral Information


Matlab - Statistics Toolbox

In this section, the possibility to do modelling work within Matlab is discussed. When imported back into Perception Studio, the model can get applied in real-time (Perception Core).

Step 1 - Select spectra and apply preprocessing

Select spectra from objects and apply spectral preprocessing within Perception Studio before export to Matlab.

Because of the experience gained in the initial exploratory step, „1st derivative“ is used.

Step 2 - Export of data

Select the data (the cube) within Perception Studio project browser (most left in the Explore or the Model perspective).

Before export, make sure the data is properly preprocessed.

Export Spectra Sets (ASCII)

Select "Spectra Sets Text File (*.sst)" to be the target file format and confirm.

Export Hyperspectral Cube data

Select "Matlab Binary (*.mat)" to be the target file format and confirm.

In the export options dialog select Processed and confirm. By this, preprocessed data (like it is shown in the Perception Studio program) gets exported.

Step 3 - Data import, modelling and export of the model from Matlab

Get helper functions used in this tutorial:

LoadSpectraSet.mLoadHSData.mSaveCCIModel.m

Download the data used in this tutorial.

Ibuprofen.matIbuprofen_spectra.sstibuprofen_PLS.fltp


Copy and run the following code in Matlab.

[svSpecSet , svCoordMap]= LoadSpectraSet;   %load the spectra sets from file.
[C,p,u] = LoadHSData;	                    %load the hyperspectral cube from file.


%get all spectra in form of a matrix in X and
%interpret the spectra sets name as nominal value in Y
X=[];
Y=[];
for i=1:length(svSpecSet)
    I = svSpecSet(i).I;
    X = cat(1,X,I);
    V = str2num( svSpecSet(i).name );
    V = repmat( V , [size(I,1) , 1] );
    Y = cat(1,Y,V);
end
 

%apply mean centering
XMeanCenter = mean( X , 1 );
X = X - repmat( XMeanCenter , [size(X,1) , 1] );

%calculate PLS regression
[XL,YL,XS,YS,Beta] = plsregress( X , Y , 4 );
B0 = Beta(1);
B = Beta(2:end);


%Apply linear model B to the cube.
X = reshape( permute(C,[1 3 2]) , [size(C,1)*size(C,3),size(C,2)] );   %bring cube in the form objects x variables.
X = X - repmat( XMeanCenter , [size(X,1) , 1] );                       %mean center the spectra
Y_ = X*B+B0;                                                           %apply model
Y_ = reshape( Y_ , [size(C,1),size(C,3)] );                            %reshape so the output is an "image".


%Show the prediction image: 
figure; imagesc(Y_);
colorbar
colormap gray


%export the model as a Studio compliant CCI-model:
B0=[B0 B0 B0];
B = repmat(B',[3,1]);
K = [1 1 1];
D = [0 0 0]; 
XMeanCenter = repmat(XMeanCenter,[3,1]); 
name='ibuprofen_SimPLS';
autoscale=0;
SaveCCIModel(B,B0,K,D,XMeanCenter,name,autoscale);

Step 4 - Import and apply the model in Studio

To load and to apply user designed models, the CCI-Design method can be used.

Switch to CCI-Design in Perception Studios Model perspective.

Import the Matlab model by a click on the button to the right of the Preset combo box.

The model is imported and applied to the selected hyperspectral cube.

Click on Save Model button to make the model available for real-time processing.

 


© 2019 by Perception Park GmbH
The content of this page and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact Perception Park and delete copied material. Perception Park GmbH, Wartingergasse 42, A-8010 Graz; Austria; FN 400381x

  • No labels