Faq how to automate PCA analysis for multiple images

From Eigenvector Research Documentation Wiki
Revision as of 10:29, 4 December 2018 by imported>Lyle (Created page with "===Issue:=== How do I automate PCA analysis for multiple images? ===Possible Solutions:=== Because the version of IMGPCA provided in the standard PLS_Toolbox requires some...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Issue:

How do I automate PCA analysis for multiple images?

Possible Solutions:

Because the version of IMGPCA provided in the standard PLS_Toolbox requires some inputs to operate, IMGPCA is not well suited to automated analysis. Although future versions of the PLS_Toolbox will allow this, the current version requires you use the basic PCA routine and handle the image aspects yourself.

First, create a preprocessing structure use the preprocess function:

>> s = preprocess;

This will bring up a dialog box that lets you specify what preprocessing you want. When you click "OK" it will return a preprocessing structure, s. (Alternatively, you can request the preprocessing method directly using the 'default' keyword. See "preprocess help" for more information.)

s = 
    description: 'Mean Center' 
      calibrate: {'[data,out{1}] = mncn(data);'} 
          apply: {'data = scale(data,out{1});'} 
           undo: {'data = rescale(data,out{1});'} 
            out: {} 
    settingsgui:  
  settingsonadd: 0 
    usesdataset: 0 
     caloutputs: 1 
        keyword: 'Mean Center' 
       userdata: [] 

Next, create a PCA options structure using:

>> opts = pca('options') 
opts = 
           name: 'options' 
        display: 'on' 
          plots: 'final' 
  outputversion: 3 
  preprocessing: {[]} 
   blockdetails: 'standard' 

then put the preprocessing structure s into this:

>> opts.preprocessing{1} = s 
opts = 
           name: 'options' 
        display: 'on' 
          plots: 'final' 
  outputversion: 3 
  preprocessing: {[1x1 struct]} 
   blockdetails: 'standard' 

Turn off the display, and turn the plots to 'none':

>> opts.display = 'off';
>> opts.plots = 'none'; 

Take you data and reshape it to number of pixels by number of channels (3 in your case) using the 'reshape' function. >> data = reshape(data,size(data,1)*size(data,2),size(data,3)); Then use the PCA function like:

>> model = pca(data,2,opts); 

The loadings will be in the model.loads field.

Still having problems? Please contact our helpdesk at helpdesk@eigenvector.com