Corrspecgui and Analyzeparticles: Difference between pages

From Eigenvector Research Documentation Wiki
(Difference between pages)
Jump to navigation Jump to search
imported>Willem
No edit summary
 
imported>Donal
 
Line 1: Line 1:
==Correlation Spectroscopy Interface==
===Purpose===
Corrspecgui is the interactive version of corrspec. The principles of correlation spectroscopy are shown in the demo of corrspec; in the manual in the chapter 'Tutorial for the correlation spectroscopy function corrspec' and for in depth information: W. Windig, D.E. Margevich, W.P. McKenna, A novel tool for two-dimensional (2D) correlation spectroscopy, Chemometrics and Intelligent Laboratory Systems, 28, 1995, 108-128.<br>


After starting the program the files are read in through the file menu. The cursor is not displayed until pressing the 'Move cursor to max' button, described below. Often the setting 'Z Origin Equal Zero', described below, is turned on in order to simplify the dispersion matrix.<br>
ANALYZEPARTCLES Identify particles (blobs, connected regions), and their properties, in an image dataset.


Below the buttons the number of pure variables selected is displayed, followed by editable boxes defining the number of contour levels used in the display of the dispersion matrix and to define the offsets. Below the display of the pure variables the cursor position is displayed.<br>
===Synopsis===


Below, the buttons and menus of corrspecgui will be discussed. The names of the buttons will be displayed by placing the cursor on top of them.<br>
: [imgdso, model] = analyzeparticles(x, options);                           
''Toggle settings display'': turns the settings, displayed on the right, on or off.<br>
: [imgdso, model] = analyzeparticles(x);                                   
''Set pure variable:'' the components defined by the pure variables, indicated by the cross-hair cursor, are eliminated.<br>
: [imgdso, model] = analyzeparticles(x, model);
''Reset last variable'': undoes the action of the previous 'Set pure variable'.<br>
''Cursor'': enables manual change of cursor position, indicating the pure variables.<br>
''Move cursor to max'': moves the cursor to the maximum in the matrix defined by the setting 'Max Algorithm'.<br>
''Plot At Cursor'': Plots the data at the cursor position in the follow forms:<br>
a) Cursor Variable Plots, a plot of the (pure) variable of the X data set, the (pure) variable of the Y data set, both as a function of axisscale{1} and a plot of both variables, as a visual tool to judge the correlation between these two variables.<br>
b) Cursor Spectrum Plots: a plot of the spectra in the displayed map.<br>
''Inactivate'': Areas that should not be used for pure variables can be inactivated, after which these areas are excluded when the cursor is set to the maximum (by the program of the 'Move cursor to max' button). After clicking one of these buttons the mouse is used to indicate the area to be inactivated. The different inactivate options define whether only the x or y data are inactivated, or both x and y.<br> 
''Reactivate last selection'': Reactivation of the previous inactivated area.<br>
Plot map in 3D: a 3D presentation of the map. Works best with the 'Plot Settings' 'False Color' on. The display can be rotated with the mouse. The button toggles between 3D on and off.
''Resolve spectra'': resolves the data using the pure variables. The resolved results are displayed in the following form:<br>
a)X Spec, X Con, Y spec, Y con, with the resolved spectra and contributions for both X and Y data.<br>
b)X vs Y Con, which shows the resolved X contributions versus the resolved Y contributions, as a tool to judge the correlations between the variables.<br>
c) Maps: the resolved correlation maps.<br>
d) Diagnostics: the original dispersion matrix, the dispersion matrix reconstructed from the resolved components, the sum of the maps shown under the tab 'Maps' and an overlay of these maps, each in a different color.<br>
e) Current plot: clicking on any of the plots mentioned above will display it enlarged under 'Current plot'.<br>


The settings, displayed at the right, have the following functions:<br>
===Description===
''Load demo data'': loads the data used for the demo in corrspec.<br>
 
''Plot type'': determines plots along the z and y axes of the correlation matrix.<br>
Particle analysis is used to identify particle-like areas in an image and return information about the identified particles’ characteristics such as their area, shape and pixel values. A particle is considered to be an isolated contiguous region of pixels within the image which have similar intensity values or color values. Particles are also known as “connected regions” or “blobs”.
''Max Algorithm'': defines the matrix of which its maximum determines pure variables.<br>
 
''Dispersion Algorithm'': defines the matrix displayed.<br>
Our image analysis software can analyze particles in images using either the “analyzeparticles” Matlab function or the “Particle Analysis” GUI, which is a graphical interface to that function.  The analyzeparticles function itself is implemented using the ImageJ image analysis package (http://rsb.info.nih.gov/ij/) which is included with our software. Analyzeparticles integrates the ImageJ “Analyze Particles” feature into our software so it can be conveniently used with the Eigenvector dataset object and the other MIA/PLS_Toolbox tools.
''Plot Settings'': determines different aspects of the plots.<br>
 
a) Axis type: defines the continuous or discrete character of plots.<br>
====Inputs====
b) False color: creates false coloring of the dispersion matrix.<br>
 
c) Z Origin Equal Zero: only displays positive values in dispersion matrix.<br>
* '''x''' = image dataset object with one or more slabs,
d) Grid: toggle for grid in dispersion matrix.<br>
* '''model''' = previously generated model of type 'ANALYZEPARTICLES' (when applying model to new data).
e) Set X/Y direction: plots the x/y axis regular or in reverse.<br>
 
f) Color bar: inserts color-bar to indicate z values in plot.<br>
====Outputs====
g) Colormap: determines which colormap is used.<br>
* '''imgdso''' = input imgdso modified with addition of classesets identifying particles. One classset has a class for each particle. Pixels within particle j have class = j. Non particle pixels have class = 0. Second classset has one class for all particles. Pixels within any particle have class = 1. Non particle pixels have class = 0.
* '''model''' = a standard model structure model with the following fields (see [[Standard Model Structure]]):
** '''modeltype''': 'ANALYZEPARTICLES',
** '''datasource''': structure array with information about input data,
** '''date''': date of creation,
** '''time''': time of creation,
** '''info''': additional model information,
** '''particletable''': A dataset containing the requested particle properties,
***  Rows are particles,
***  Columns represent properties, identified by particletable.label{2}.
** '''allparticles''': a vector with one entry per pixel, value = 0 if pixel is not a particle pixel, 1 otherwise.
** '''particles''': a vector with one entry per pixel, value = j, where j = 0, 1, ...n if pixel is part of particle number j.
** '''foreground''': a vector with one entry per pixel, value = 0 or 255, showing the binary image representing all possible particle pixels.
** '''detail''': sub-structure with additional model details and results, including:
*** model.detail.thresholdValue: the threshold value used in forming the binary image,
*** model.detail.height: height of the image (in pixels),
*** model.detail.width: width of the image (in pixels),
*** model.detail.nparticles: number of identified particles,
*** model.detail.ij: contains the Java evri.ij.plugin.ParticlesAnalyzer object.
 
===Options===
''options'' =  a structure array with the following fields:
 
* '''display''': [ 'off' | {'on'} ], governs level of display to command window. 'off' suppresses output,
* '''plots''' [ 'none' | {'final'} ], governs level of plotting,
 
* '''includeholes''': [ 'off' | {'on'} ], holes within particles are included?,
* '''includeedgeparticles''': [ {'off'} | 'on' ], include particles intersecting the image's edge?,
* '''thresholdslab''': Index of dataset slab to use for creating binary image. Default = [],
* '''thresholdvalue''': Value to use as threshold when creating binary image,
* '''reversemask''': [ 'off' | {'on'}] reverse the particle binary mask?
* '''apply_abs''': [ {'off'} | 'on' ] apply absolute value to data initially?
The following four options represent criteria which potential particles must satisfy to be considered particles:
* '''minsize''': Lower limit to particle area. Default is 50 pixels,
* '''maxsize''': Upper limit to particle area. Default is infinite,
* '''mincircularity''': Lower limit to particle circularity. Default = 0.0,
* '''maxcircularity''': Upper limit to particle circularity. Default = 1.0,
The remaining options indicate whether these additional particle properties should be measured and reported:
* '''particleminmax''': [ {'off'} | 'on' ] measure particle min and max values,
* '''particlemedian''': [ {'off'} | 'on' ] measure particle median value,
* '''particlestddev''': [ {'off'} | 'on' ] measure particle standard deviation value,
* '''particleperimeter''': [ {'off'} | 'on' ] measure length of particle perimeter (pixels),
* '''particleshape''': [ {'off'} | 'on' ] measure particle shape parameters (Conc., AR, Round, Solidity),
* '''particleferet''': [ {'off'} | 'on' ] measure Feret diameters of particle.
 
===Algorithm===
There are two steps to particle analysis of an image dataset object (DSO). The first step is to obtain a binary image where image pixel values are either 0 or 1 where one value represents non-particle pixels and the other represents potential particle pixels. This is usually accomplished by specifying a threshold level where pixels having a value below or above the threshold value are assigned value 0 or 1. If no threshold level is specified then one is automatically determined as in the ImageJ auto thresholding method. If the image DSO has multiple slabs then one slab must be selected to determine the binary image or else the average of all the slabs can be used. A pixel assigned value 1 is not automatically part of a particle because other particle criteria can be specified such as a minimum particle area requirement, or other shape restriction. Once these filters are applied there may remain some particle regions.
 
The second step in particle analysis is to calculate the properties of each particle region. Properties include area, perimeter, centroid coordinates, shape properties (circularity, aspect ratio, roundness, and solidity) and Feret’s diameters (Feret  diameter, FeretX, FeretY, FeretAngle and MinFeret). There are other particle properties which depend on the particle’s pixel values including mean, median, minimum, maximum, and standard deviation. These are calculated for each slab for each particle.
 
 
====Measured Particle Properties====
Properties of each particle are returned in the model.particletable DSO. Particles' centroid coordinates (w, h) are always returned. Coordinates are given using the image convention where (x,y) indicates distance in pixels measured from the top left corner of the image, so the top left corner has coordinates (0,0) while the bottom right corner has coordinates (nwidth-1, nheight-1).
*'''X, Y''' are the coordinates of the particle's centroid.
 
Additional particle properties can be obtained by specifying options:
*'''Mean''' = mean pixel value over particle, per slab
*'''Median''' = mean pixel value over particle, per slab
*'''Min''' = minimum pixel value over particle, per slab
*'''Max''' = maximum pixel value over particle, per slab
*'''StdDev''' = standard deviation of pixel values over particle, per slab.
 
Particle properties which only depend on the particle shape (are the same for all slabs) include:
*'''Area''' = area of particle (in square pixels),
*'''Perim.''' = length of particle perimeter in pixel lengths.
 
Particle shape properties:
*'''Circ.''' (circularity = 4π*area/perimeter^2.  A value of 1.0 indicates a perfect circle. As the value approaches 0.0, it indicates an increasingly elongated shape. Values may not be valid for very small particles. Also note that a circular particle with large holes will have smaller area than a circle with that perimeter, so circularity is only accurate if the particle has no holes (or 'includeholes=on'). A circular particle with large holes will have small solidity.
 
*'''AR''' (aspect ratio)  = major_axis/minor_axis.  
 
*'''Round''' (roundness)  = 4*area/(π*major_axis^2), or the inverse of the aspect ratio.
 
*'''Solidity'''          = area/convex area.
 
Particle Feret diameters,
Feret's Diameter is the longest distance between any two points along the particle boundary, also known as maximum caliper. The angle (0-180 degrees) of the Feret's diameter is displayed as FeretAngle, as well as the minimum caliper diameter (MinFeret).
 
*'''Feret'''        = Feret's diameter of particle (length in pixels)
 
*'''FeretX'''      = Coordinate of one end of Feret's diameter.
 
*'''FeretY'''      = Coordinate of one end of Feret's diameter.
 
*'''FeretAngle'''  = Angle between Feret's diameter and x-axis.
 
*'''MinFeret'''    = Minimum Feret's diameter of particle (length in pixels)
 
====Filtering Particles by Size and Circularity====
The number of particles returned by analyzeparticles can be reduced by specifying a minimum or maximum area or circularity that a particle must have. These values can be specified as options.minsize, options.maxsize, options.mincircularity, options.maxcircularity, or default values will be used.
 
====Reverse Mask to Measure Bright Particles====
The default behavior is to identify particles as connected regions which have intensity above a threshold value. This identifies brighter areas as particles while the rest of the image is considered a darker background. In some images, however, the particles may appear as darker spots on a brighter background. Such particles can be analyzed by setting the input option "reversemask" to "off" instead of its default value "on".
 
====Handling of Holes Within Particles====
The default behavior of analyzeparticles, option.includeholes = 'on', is to measure a particle's area or mean pixel value, etc. by including all enclosed pixels. Thus any holes within an enclosing particle do contribute to the particle's area or mean pixel value. This behavior can be changed by specifying the input option.includeholes = 'off', which will mean that non-particle pixels within the surrounding particle boundary are not used in calculating the particle area or mean pixel value, etc.. When option.includeholes = 'off' any "child" particles within such a hole are reported as additional particles and do not contribute to the enclosing particle's area and mean, etc. Thus, includeholes = 'off' can lead to identifying more particles. A set of N concentric circles would count as just one particle if includeholes = 'on' but would yield N particles when includeholes = 'off'.
 
====Handling of Excluded Pixels====
Pixels which are flagged as excluded by the dataset object are treated as non-particle pixels.
 
===See Also===
 
[[analysis]], [[particlegui]]

Revision as of 15:43, 12 March 2012

Purpose

ANALYZEPARTCLES Identify particles (blobs, connected regions), and their properties, in an image dataset.

Synopsis

[imgdso, model] = analyzeparticles(x, options);
[imgdso, model] = analyzeparticles(x);
[imgdso, model] = analyzeparticles(x, model);

Description

Particle analysis is used to identify particle-like areas in an image and return information about the identified particles’ characteristics such as their area, shape and pixel values. A particle is considered to be an isolated contiguous region of pixels within the image which have similar intensity values or color values. Particles are also known as “connected regions” or “blobs”.

Our image analysis software can analyze particles in images using either the “analyzeparticles” Matlab function or the “Particle Analysis” GUI, which is a graphical interface to that function. The analyzeparticles function itself is implemented using the ImageJ image analysis package (http://rsb.info.nih.gov/ij/) which is included with our software. Analyzeparticles integrates the ImageJ “Analyze Particles” feature into our software so it can be conveniently used with the Eigenvector dataset object and the other MIA/PLS_Toolbox tools.

Inputs

  • x = image dataset object with one or more slabs,
  • model = previously generated model of type 'ANALYZEPARTICLES' (when applying model to new data).

Outputs

  • imgdso = input imgdso modified with addition of classesets identifying particles. One classset has a class for each particle. Pixels within particle j have class = j. Non particle pixels have class = 0. Second classset has one class for all particles. Pixels within any particle have class = 1. Non particle pixels have class = 0.
  • model = a standard model structure model with the following fields (see Standard Model Structure):
    • modeltype: 'ANALYZEPARTICLES',
    • datasource: structure array with information about input data,
    • date: date of creation,
    • time: time of creation,
    • info: additional model information,
    • particletable: A dataset containing the requested particle properties,
      • Rows are particles,
      • Columns represent properties, identified by particletable.label{2}.
    • allparticles: a vector with one entry per pixel, value = 0 if pixel is not a particle pixel, 1 otherwise.
    • particles: a vector with one entry per pixel, value = j, where j = 0, 1, ...n if pixel is part of particle number j.
    • foreground: a vector with one entry per pixel, value = 0 or 255, showing the binary image representing all possible particle pixels.
    • detail: sub-structure with additional model details and results, including:
      • model.detail.thresholdValue: the threshold value used in forming the binary image,
      • model.detail.height: height of the image (in pixels),
      • model.detail.width: width of the image (in pixels),
      • model.detail.nparticles: number of identified particles,
      • model.detail.ij: contains the Java evri.ij.plugin.ParticlesAnalyzer object.

Options

options = a structure array with the following fields:

  • display: [ 'off' | {'on'} ], governs level of display to command window. 'off' suppresses output,
  • plots [ 'none' | {'final'} ], governs level of plotting,
  • includeholes: [ 'off' | {'on'} ], holes within particles are included?,
  • includeedgeparticles: [ {'off'} | 'on' ], include particles intersecting the image's edge?,
  • thresholdslab: Index of dataset slab to use for creating binary image. Default = [],
  • thresholdvalue: Value to use as threshold when creating binary image,
  • reversemask: [ 'off' | {'on'}] reverse the particle binary mask?
  • apply_abs: [ {'off'} | 'on' ] apply absolute value to data initially?

The following four options represent criteria which potential particles must satisfy to be considered particles:

  • minsize: Lower limit to particle area. Default is 50 pixels,
  • maxsize: Upper limit to particle area. Default is infinite,
  • mincircularity: Lower limit to particle circularity. Default = 0.0,
  • maxcircularity: Upper limit to particle circularity. Default = 1.0,

The remaining options indicate whether these additional particle properties should be measured and reported:

  • particleminmax: [ {'off'} | 'on' ] measure particle min and max values,
  • particlemedian: [ {'off'} | 'on' ] measure particle median value,
  • particlestddev: [ {'off'} | 'on' ] measure particle standard deviation value,
  • particleperimeter: [ {'off'} | 'on' ] measure length of particle perimeter (pixels),
  • particleshape: [ {'off'} | 'on' ] measure particle shape parameters (Conc., AR, Round, Solidity),
  • particleferet: [ {'off'} | 'on' ] measure Feret diameters of particle.

Algorithm

There are two steps to particle analysis of an image dataset object (DSO). The first step is to obtain a binary image where image pixel values are either 0 or 1 where one value represents non-particle pixels and the other represents potential particle pixels. This is usually accomplished by specifying a threshold level where pixels having a value below or above the threshold value are assigned value 0 or 1. If no threshold level is specified then one is automatically determined as in the ImageJ auto thresholding method. If the image DSO has multiple slabs then one slab must be selected to determine the binary image or else the average of all the slabs can be used. A pixel assigned value 1 is not automatically part of a particle because other particle criteria can be specified such as a minimum particle area requirement, or other shape restriction. Once these filters are applied there may remain some particle regions.

The second step in particle analysis is to calculate the properties of each particle region. Properties include area, perimeter, centroid coordinates, shape properties (circularity, aspect ratio, roundness, and solidity) and Feret’s diameters (Feret diameter, FeretX, FeretY, FeretAngle and MinFeret). There are other particle properties which depend on the particle’s pixel values including mean, median, minimum, maximum, and standard deviation. These are calculated for each slab for each particle.


Measured Particle Properties

Properties of each particle are returned in the model.particletable DSO. Particles' centroid coordinates (w, h) are always returned. Coordinates are given using the image convention where (x,y) indicates distance in pixels measured from the top left corner of the image, so the top left corner has coordinates (0,0) while the bottom right corner has coordinates (nwidth-1, nheight-1).

  • X, Y are the coordinates of the particle's centroid.

Additional particle properties can be obtained by specifying options:

  • Mean = mean pixel value over particle, per slab
  • Median = mean pixel value over particle, per slab
  • Min = minimum pixel value over particle, per slab
  • Max = maximum pixel value over particle, per slab
  • StdDev = standard deviation of pixel values over particle, per slab.

Particle properties which only depend on the particle shape (are the same for all slabs) include:

  • Area = area of particle (in square pixels),
  • Perim. = length of particle perimeter in pixel lengths.

Particle shape properties:

  • Circ. (circularity = 4π*area/perimeter^2. A value of 1.0 indicates a perfect circle. As the value approaches 0.0, it indicates an increasingly elongated shape. Values may not be valid for very small particles. Also note that a circular particle with large holes will have smaller area than a circle with that perimeter, so circularity is only accurate if the particle has no holes (or 'includeholes=on'). A circular particle with large holes will have small solidity.
  • AR (aspect ratio) = major_axis/minor_axis.
  • Round (roundness) = 4*area/(π*major_axis^2), or the inverse of the aspect ratio.
  • Solidity = area/convex area.

Particle Feret diameters, Feret's Diameter is the longest distance between any two points along the particle boundary, also known as maximum caliper. The angle (0-180 degrees) of the Feret's diameter is displayed as FeretAngle, as well as the minimum caliper diameter (MinFeret).

  • Feret = Feret's diameter of particle (length in pixels)
  • FeretX = Coordinate of one end of Feret's diameter.
  • FeretY = Coordinate of one end of Feret's diameter.
  • FeretAngle = Angle between Feret's diameter and x-axis.
  • MinFeret = Minimum Feret's diameter of particle (length in pixels)

Filtering Particles by Size and Circularity

The number of particles returned by analyzeparticles can be reduced by specifying a minimum or maximum area or circularity that a particle must have. These values can be specified as options.minsize, options.maxsize, options.mincircularity, options.maxcircularity, or default values will be used.

Reverse Mask to Measure Bright Particles

The default behavior is to identify particles as connected regions which have intensity above a threshold value. This identifies brighter areas as particles while the rest of the image is considered a darker background. In some images, however, the particles may appear as darker spots on a brighter background. Such particles can be analyzed by setting the input option "reversemask" to "off" instead of its default value "on".

Handling of Holes Within Particles

The default behavior of analyzeparticles, option.includeholes = 'on', is to measure a particle's area or mean pixel value, etc. by including all enclosed pixels. Thus any holes within an enclosing particle do contribute to the particle's area or mean pixel value. This behavior can be changed by specifying the input option.includeholes = 'off', which will mean that non-particle pixels within the surrounding particle boundary are not used in calculating the particle area or mean pixel value, etc.. When option.includeholes = 'off' any "child" particles within such a hole are reported as additional particles and do not contribute to the enclosing particle's area and mean, etc. Thus, includeholes = 'off' can lead to identifying more particles. A set of N concentric circles would count as just one particle if includeholes = 'on' but would yield N particles when includeholes = 'off'.

Handling of Excluded Pixels

Pixels which are flagged as excluded by the dataset object are treated as non-particle pixels.

See Also

analysis, particlegui