#include <analyzer_sparx.h>


Public Member Functions | |
| PCAsmall () | |
| virtual int | insert_image (EMData *image) |
| insert a image to the list of input images | |
| virtual vector< EMData * > | analyze () |
| main function for Analyzer, analyze input images and create output images | |
| string | get_name () const |
| Get the Analyzer's name. | |
| string | get_desc () const |
| Get the Analyzer's description. | |
| void | set_params (const Dict &new_params) |
| Set the Analyzer parameters using a key/value dictionary. | |
| TypeDict | get_param_types () const |
| Get Analyzer parameter information in a dictionary. | |
Static Public Member Functions | |
| static Analyzer * | NEW () |
Protected Attributes | |
| EMData * | mask |
| int | nvec |
Private Attributes | |
| float * | covmat |
| int | ncov |
| int | nimages |
| float * | eigval |
Definition at line 45 of file analyzer_sparx.h.
| EMAN::PCAsmall::PCAsmall | ( | ) | [inline] |
| int PCAsmall::insert_image | ( | EMData * | image | ) | [virtual] |
insert a image to the list of input images
| image |
Implements EMAN::Analyzer.
Definition at line 251 of file analyzer.cpp.
References compress_image_mask(), covmat, EMDeletePtr(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), imgdata, mask, ncov, nimages, NullPointerException, and nx.
00252 { 00253 if(mask==0) 00254 throw NullPointerException("Null mask image pointer, set_params() first"); 00255 00256 EMData *maskedimage = Util::compress_image_mask(image,mask); 00257 00258 int nx = maskedimage->get_xsize(); 00259 float *imgdata = maskedimage->get_data(); 00260 if (nx != ncov) { 00261 fprintf(stderr,"insert_image: something is wrong...\n"); 00262 exit(1); 00263 } 00264 00265 // there is a faster version of the following rank-1 update 00266 nimages++; 00267 for (int j = 1; j <= nx; j++) 00268 for (int i = 1; i<=nx; i++) { 00269 covmat(i,j) += imgdata(i)*imgdata(j); 00270 } 00271 00272 EMDeletePtr(maskedimage); 00273 return 0; 00274 }
| vector< EMData * > PCAsmall::analyze | ( | ) | [virtual] |
main function for Analyzer, analyze input images and create output images
Implements EMAN::Analyzer.
Definition at line 278 of file analyzer.cpp.
References coveig(), covmat, eigval, eigvec, EMDeletePtr(), EMAN::EMData::get_data(), EMAN::Analyzer::images, mask, ncov, nvec, rdata, reconstitute_image_mask(), EMAN::EMData::set_attr(), EMAN::EMData::set_size(), and status.
00279 { 00280 float *eigvec; 00281 int status = 0; 00282 // printf("start analyzing..., ncov = %d\n", ncov); 00283 eigval = (float*)calloc(ncov,sizeof(float)); 00284 eigvec = (float*)calloc(ncov*ncov,sizeof(float)); 00285 status = Util::coveig(ncov, covmat, eigval, eigvec); 00286 // for (int i=1; i<=nvec; i++) printf("eigval = %11.4e\n", 00287 // eigval[ncov-i]); 00288 00289 // pack eigenvectors into the return imagelist 00290 EMData *eigenimage = new EMData(); 00291 eigenimage->set_size(ncov,1,1); 00292 float *rdata = eigenimage->get_data(); 00293 for (int j = 1; j<= nvec; j++) { 00294 for (int i = 0; i < ncov; i++) rdata[i] = eigvec(i,ncov-j); 00295 00296 EMData* recons_eigvec = Util::reconstitute_image_mask(eigenimage,mask); 00297 recons_eigvec->set_attr( "eigval", eigval[j-1] ); 00298 images.push_back(recons_eigvec); 00299 } 00300 00301 free(eigvec); 00302 EMDeletePtr(eigenimage); 00303 00304 return images; 00305 }
| string EMAN::PCAsmall::get_name | ( | ) | const [inline, virtual] |
Get the Analyzer's name.
Each Analyzer is identified by a unique name.
Implements EMAN::Analyzer.
Definition at line 59 of file analyzer_sparx.h.
| string EMAN::PCAsmall::get_desc | ( | ) | const [inline, virtual] |
Get the Analyzer's description.
Implements EMAN::Analyzer.
Definition at line 64 of file analyzer_sparx.h.
| static Analyzer* EMAN::PCAsmall::NEW | ( | ) | [inline, static] |
Definition at line 69 of file analyzer_sparx.h.
References PCAsmall().
Referenced by EMAN::Factory< T >::Factory().
00070 { 00071 return new PCAsmall(); 00072 }
| void PCAsmall::set_params | ( | const Dict & | new_params | ) | [virtual] |
Set the Analyzer parameters using a key/value dictionary.
| new_params | A dictionary containing the new parameters. |
Reimplemented from EMAN::Analyzer.
Definition at line 308 of file analyzer.cpp.
References compress_image_mask(), covmat, EMDeletePtr(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), mask, ncov, nimages, nvec, nx, ny, EMAN::Analyzer::params, and EMAN::EMData::set_size().
00309 { 00310 params = new_params; 00311 mask = params["mask"]; 00312 nvec = params["nvec"]; 00313 00314 // count the number of pixels under the mask 00315 // (this is really ugly!!!) 00316 EMData *dummy = new EMData(); 00317 00318 int nx = mask->get_xsize(); 00319 int ny = mask->get_ysize(); 00320 int nz = mask->get_zsize(); 00321 00322 dummy->set_size(nx,ny,nz); 00323 00324 EMData *dummy1d = Util::compress_image_mask(dummy,mask); 00325 ncov = dummy1d->get_xsize(); 00326 EMDeletePtr(dummy); 00327 EMDeletePtr(dummy1d); 00328 00329 // allocate and set up the covriance matrix 00330 nimages = 0; 00331 covmat = (float*)calloc(ncov*ncov,sizeof(float)); 00332 }
| TypeDict EMAN::PCAsmall::get_param_types | ( | ) | const [inline, virtual] |
Get Analyzer parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Implements EMAN::Analyzer.
Definition at line 83 of file analyzer_sparx.h.
References EMAN::EMObject::EMDATA, EMAN::EMObject::INT, and EMAN::TypeDict::put().
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 }
EMData* EMAN::PCAsmall::mask [protected] |
Definition at line 92 of file analyzer_sparx.h.
Referenced by analyze(), insert_image(), and set_params().
int EMAN::PCAsmall::nvec [protected] |
float* EMAN::PCAsmall::covmat [private] |
Definition at line 96 of file analyzer_sparx.h.
Referenced by analyze(), insert_image(), and set_params().
int EMAN::PCAsmall::ncov [private] |
Definition at line 97 of file analyzer_sparx.h.
Referenced by analyze(), insert_image(), and set_params().
int EMAN::PCAsmall::nimages [private] |
float* EMAN::PCAsmall::eigval [private] |
1.5.6