In this tutorial quantitative analysis by means of Perception Studio and by means of Matlab is described.
In many industries quantitative measurement of spectral information gives an valued input e.g. for quality inspection. This page summarizes an example on modelling the API (active pharmaceutical ingredient) of pills.
The aim is to find a model which allows the measurement of the amount of the chemical ingredient in pills. As a result the achieved model is applied onto the measurement data and result in a gray-value image, where its pixel values correspond to the quantity (to the amount) 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 by a NIR line-scan camera FX17 of Specim compliant for CCI processing. After a short exploratory analysis, the CCI-Constrain method is used for modeling, after that Matlab is used to do chemometric modelling.
Data, Samples & Measurement
|Title||Pills of different Ibuprofen concentration|
|Sample Description||From up to down: 74, 60, 49, 23 m/m Ibuprofen in Lactose (monohydrat).|
From left to right: pill side 1 and 2
Tablet pressing in a Lactose matrix
|Sample Location||Perception Park Lab|
|Donor||Manfred / Perception Park|
|Date of Measurement||-|
|Measurement System||Specim FX17 CCI|
|Measurement Description||Measurement in reflectance|
|Measurement Setup||Illumination: Halogen spots 2-sided.|
Background: black non-woven fabric.
|Analysis||Sample preparation: Ibuprofen 600 without coating mixed with lactose and pressed to tablets. Each approx. 1g.|
|Spectroscopic Discussion||Spectral bands strong correlated to Ibuprofen are in the range 1115-1230nm.|
Start the project
Install the example project by double click on the downloaded file and follow 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 (watch the progress bar).
Exploratory analysis of the data
Change to the Explore perspective and select the HS cube ibuprofen from the project browser.
In the Explore perspective the Hyperspectral data loaded (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 come along with some 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 strong correlated to the varying Ibuprofen content in the range 1115-1230nm.
Explore the nature of information nested
Preview Feature - find candidates for a proper preprocessing
In the following illustration the preview of the data is shown.
|without||1st derivative||2nd derivative|
Without preprocessing the pills are hardly distinguishable in the image above by their color information. By applying the 1st derivative the varying Ibuprofen content get visible by a greenish color gradient. The 2nd derivative shows clear distances between pills of different Ibuprofen content.
So the Preview feature correlates to the varying Ibuprofen content when preprocessing "1st derivative" or "2nd derivative" is applied.
This indicates "1st der" or "2nd der" are potential candidates for a proper preprocessing when the extraction of the Ibuprofen content is aimed.
Statistical Features - judge the quality of spectra
Various statistical feature can get selected out from the ribbon menu on the top of Perception Studios Model perspective.
The statistical maximum of the 1st derivative of the pills show uncertainties on the border of the pills (light area).
Position the mouse onto 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 keep out such pixels from further investigation - the spectral response seem to be distorted by measurement errors and therefore seem to be not trustful.
For more information on exploratory investigation of hyperspectral data see Exploratory analysis of plastics.
Model the application relevant information
In this tutorial our aim is to model the Ibuprofen concentration of available pills. The measurement of pills are available two times. One from side 1 (top side) and the second one from side 2 (bottom side) of each pill. Side 1 of all pills are 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 by the color red.
This is because the user-given color of selected spectra sets was chosen 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 nominals values of the pills, to the spectra.
In the illustration 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 results gained, move your mouse over the resulting image and inspect the images gray-values. As you can see, the gray-value correspond to "constrained" gray-values.
E.g. 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 "sensitiveness".
The images gained for different preprocessing are analyzed statistically in the illustration below (by means of Matlab).
|1st derivative - sensitivety 4||2nd derivative - sensitivety 4|
|1st derivative||2nd derivative|
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 modeling see Model Hyperspectral Information
Matlab - Statistics Toolbox
In this section, the possibility to do the modelling work within Matlab is discussed. When imported back into Perception Studio, the model can get applied e.g. 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 experience gained in the beginning exploratory step, „1st derivative“ is used.
Step 2 - Export of data
Select the data (the cube) within Perception Studios project browser (most left in the Explore or the Model perspective).
Beforehand export, be 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) get exported.
Step 3 - Data import, modelling and export of the model from Matlab
Get helper functions used in this tutorial:
Download the data used in this tutorial.
Copy and run the following code in Matlab.
Step 4 - Import and apply the model in Studio
To load and to apply user designed models, the CCI-Design method can get used.
Switch to CCI-Design in Perception Studios Model perspective.
Import the Matlab model by a click on the button right to the Preset combo box.
The model is imported and applied to the hyperspectral cube selected.
E.g. click on Save Model button to get the model available e.g. 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