analyzer_sparx.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Chao Yang
00007  * Copyright (c) 2000-2006
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  *
00034  */
00035 
00036 #ifndef eman_analyzer_sparx_h__
00037 #define eman_analyzer_sparx_h__
00038 
00039 #include "analyzer.h"
00040 
00041 namespace EMAN
00042 {
00045         class PCAsmall : public Analyzer
00046         {
00047           public:
00048                 PCAsmall() : mask(0), nvec(0) {}
00049                 
00050 //              virtual int insert_image(EMData * image) {
00051 //              images.push_back(image);
00052 //              return 0;
00053 //
00054 //}
00055                 virtual int insert_image(EMData * image);
00056                 
00057                 virtual vector<EMData*> analyze();
00058                 
00059                 string get_name() const
00060                 {
00061                         return "pca";
00062                 }               
00063                 
00064                 string get_desc() const
00065                 {
00066                         return "Principal component analysis";
00067                 }
00068                 
00069                 static Analyzer * NEW()
00070                 {
00071                         return new PCAsmall();
00072                 }
00073                 
00074                 void set_params(const Dict & new_params);
00075 
00076 //              void set_params(const Dict & new_params)
00077 //              {
00078 //                      params = new_params;
00079 //                      mask = params["mask"];
00080 //                      nvec = params["nvec"];
00081 //              }
00082 
00083                 TypeDict get_param_types() const
00084                 {
00085                         TypeDict d;
00086                         d.put("mask", EMObject::EMDATA, "mask image");
00087                         d.put("nvec", EMObject::INT, "number of desired principal components");
00088                         return d;
00089                 }
00090                 
00091           protected:
00092                 EMData * mask;
00093                 int nvec;       //number of desired principal components
00094 
00095           private:
00096                 float *covmat; // covariance matrix 
00097                 int   ncov;    // dimension of the covariance matrix
00098                 int   nimages; // number of images
00099                 float *eigval; // array for storing computed eigvalues
00100         }; 
00101 
00102         //-------------------------------------------------------------
00103 
00104         class PCAlarge : public Analyzer
00105         {
00106           public:
00107                 PCAlarge() : mask(0), nvec(0) {}
00108                 
00109                 virtual int insert_image(EMData * image);
00110                 
00111                 virtual vector<EMData*> analyze();
00112                 
00113                 string get_name() const
00114                 {
00115                         return "pca_large";
00116                 }               
00117                 
00118                 string get_desc() const
00119                 {
00120                         return "Principal component analysis";
00121                 }
00122                 
00123                 static Analyzer * NEW()
00124                 {
00125                         return new PCAlarge();
00126                 }
00127                 
00128                 void set_params(const Dict & new_params);
00129 
00130                 int Lanczos(const string &maskedimages, int *kstep, 
00131                             float  *diag, float *subdiag, float *V, 
00132                             float  *beta);
00133 
00134 
00135                 TypeDict get_param_types() const
00136                 {
00137                         TypeDict d;
00138                         d.put("mask", EMObject::EMDATA, "mask image");
00139                         d.put("nvec", EMObject::INT, "number of desired principal components");
00140                         return d;
00141                 }
00142                 
00143           protected:
00144                 EMData * mask;
00145                 int nvec;       //number of desired principal components
00146 
00147           private:
00148                 int   ncov;    // dimension of the covariance matrix
00149                 int   nimages; // number of images used in the analysis
00150                 float *eigval; // array for storing computed eigvalues
00151         }; 
00152 
00153         class varimax : public Analyzer
00154         {
00155           public:
00156                 varimax() : m_mask(NULL) {}
00157                 
00158                 virtual int insert_image(EMData * image);
00159                 
00160                 virtual vector<EMData*> analyze();
00161                 
00162                 string get_name() const
00163                 {
00164                         return "varimax";
00165                 }               
00166                 
00167                 string get_desc() const
00168                 {
00169                         return "varimax rotation of PCA results";
00170                 }
00171                 
00172                 static Analyzer * NEW()
00173                 {
00174                         return new varimax();
00175                 }
00176                 
00177                 virtual void set_params(const Dict & new_params);
00178 
00179                 TypeDict get_param_types() const
00180                 {
00181                         TypeDict d;
00182                         d.put("mask", EMObject::EMDATA, "mask image");
00183                         return d;
00184                 }
00185                 
00186           private:
00187                 int m_nlen;
00188                 int m_nfac;
00189                 EMData *m_mask;
00190                 vector<float> m_data;
00191          }; 
00192 }
00193 
00194 #endif  //eman_analyzer_sparx_h__ 

Generated on Sat Nov 7 02:18:55 2009 for EMAN2 by  doxygen 1.5.6