EMAN2
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 NAME;
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                 static const string NAME;
00092                 
00093           protected:
00094                 EMData * mask;
00095                 int nvec;       //number of desired principal components
00096 
00097           private:
00098                 float *covmat; // covariance matrix 
00099                 int   ncov;    // dimension of the covariance matrix
00100                 int   nimages; // number of images
00101                 float *eigval; // array for storing computed eigvalues
00102         }; 
00103 
00104         //-------------------------------------------------------------
00105 
00106         class PCAlarge : public Analyzer
00107         {
00108           public:
00109                 PCAlarge() : mask(0), nvec(0) {}
00110                 
00111                 virtual int insert_image(EMData * image);
00112                 
00113                 virtual vector<EMData*> analyze();
00114                 
00115                 string get_name() const
00116                 {
00117                         return NAME;
00118                 }               
00119                 
00120                 string get_desc() const
00121                 {
00122                         return "Principal component analysis";
00123                 }
00124                 
00125                 static Analyzer * NEW()
00126                 {
00127                         return new PCAlarge();
00128                 }
00129                 
00130                 void set_params(const Dict & new_params);
00131 
00132                 int Lanczos(const string &maskedimages, int *kstep, 
00133                             float  *diag, float *subdiag, float *V, 
00134                             float  *beta);
00135 
00136 
00137                 TypeDict get_param_types() const
00138                 {
00139                         TypeDict d;
00140                         d.put("mask", EMObject::EMDATA, "mask image");
00141                         d.put("nvec", EMObject::INT, "number of desired principal components");
00142                         return d;
00143                 }
00144                 
00145                 static const string NAME;
00146                 
00147           protected:
00148                 EMData * mask;
00149                 int nvec;       //number of desired principal components
00150 
00151           private:
00152                 int   ncov;    // dimension of the covariance matrix
00153                 int   nimages; // number of images used in the analysis
00154                 float *eigval; // array for storing computed eigvalues
00155         }; 
00156 
00157         class varimax : public Analyzer
00158         {
00159           public:
00160                 varimax() : m_mask(NULL) {}
00161                 
00162                 virtual int insert_image(EMData * image);
00163                 
00164                 virtual vector<EMData*> analyze();
00165                 
00166                 string get_name() const
00167                 {
00168                         return NAME;
00169                 }               
00170                 
00171                 string get_desc() const
00172                 {
00173                         return "varimax rotation of PCA results";
00174                 }
00175                 
00176                 static Analyzer * NEW()
00177                 {
00178                         return new varimax();
00179                 }
00180                 
00181                 virtual void set_params(const Dict & new_params);
00182 
00183                 TypeDict get_param_types() const
00184                 {
00185                         TypeDict d;
00186                         d.put("mask", EMObject::EMDATA, "mask image");
00187                         return d;
00188                 }
00189                 
00190                 static const string NAME;
00191                 
00192           private:
00193                 int m_nlen;
00194                 int m_nfac;
00195                 EMData *m_mask;
00196                 vector<float> m_data;
00197         }; 
00198 }
00199 
00200 #endif  //eman_analyzer_sparx_h__