Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

doapmd.cpp

Go to the documentation of this file.
00001 /*
00002  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00003  * Copyright (c) 2000-2006 Baylor College of Medicine
00004  *
00005  * This software is issued under a joint BSD/GNU license. You may use the
00006  * source code in this file under either license. However, note that the
00007  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00008  * so you are responsible for compliance with the licenses of these packages
00009  * if you opt to use BSD licensing. The warranty disclaimer below holds
00010  * in either instance.
00011  *
00012  * This complete copyright notice must be included in any revised version of the
00013  * source code. Additional authorship citations may be added, but existing
00014  * author citations must be preserved.
00015  *
00016  * This program is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  *
00021  * This program is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  *
00030  */
00031 
00032 #include "log.h"
00033 #include "emdata.h"
00034 #include "xydata.h"
00035 #include "assert.h"
00036 #include "projector.h"
00037 
00038 #include <sys/types.h>
00039 #include <sys/times.h>
00040 #include <time.h>
00041 #include <sys/time.h>
00042 
00043 #ifndef CLK_TCK
00044 #define CLK_TCK 60
00045 #endif
00046 
00047 double mytimer()
00048 {
00049     struct tms use;
00050     double tmp;
00051     times(&use);
00052     tmp = use.tms_utime;
00053     tmp += use.tms_stime;
00054     return (double)(tmp) / CLK_TCK;
00055 }
00056 
00057 using namespace EMAN;
00058 
00059 using std::cout;
00060 using std::cin;
00061 using std::endl;
00062 using std::string;
00063 
00064 #include "spidutil.h"
00065 
00066 int main()
00067 {
00068     EMData *volume = new EMData(); // initial volume
00069     EMData *expimg = new EMData(); // experimental image
00070 
00071     Dict    refparams;
00072     APMDopt options;
00073 
00074     vector <float> angles;
00075     float   delta, tlb, tub, plb, pub;
00076     int     ndim, nx, ny, nz, nang, status;
00077     int     nref, nimg, i;
00078     double  t0, t1;
00079     float   *newangles;
00080 
00081     printf("reading a 3-D volume...\n");
00082     volume->read_image("vol001.tfc");
00083 
00084     ndim = volume->get_ndim();
00085     nx   = volume->get_xsize();
00086     ny   = volume->get_ysize();
00087     nz   = volume->get_zsize();
00088 
00089     // print some stats
00090     printf("ndim = %d, nx = %d, ny = %d, nz = %d\n", ndim, nx, ny, nz);
00091 
00092     // generate a set of reference projections from the volume
00093 
00094     delta = 15.0;
00095     tlb   = 0.0;
00096     tub   = 90.0;
00097     plb   = 0.0;
00098     pub   = 359.9;
00099 
00100     // angles used to generate reference projections
00101     angles = Util::voea(delta, tlb, tub, plb, pub); 
00102     nang   = angles.size()/3;
00103     printf("size(angles) = %d\n", nang);
00104 
00105     refparams["anglelist"] = angles;
00106     refparams["angletype"] = "SPIDER";
00107     refparams["radius"]    = 30.0;
00108     t0 = mytimer();
00109     printf("generating reference projections...\n");
00110     EMData* refprj = volume->project("pawel", refparams);
00111     t1 = mytimer() - t0;
00112     nref  = refprj->get_zsize();
00113     printf("nref = %d\n", nref);
00114   
00115     printf("time used in ref projection calculation = %11.3e\n", t1);
00116 
00117     // read experimental images
00118     expimg->read_image("tf2d0001.tfc"); 
00119     nimg = expimg->get_zsize();
00120 
00121     options.mr    = 5;
00122     options.nr    = 30;
00123     options.iskip = 1;
00124     options.mode  = 'F'; 
00125 
00126     // run APMD on expimg using refprj as the reference, 
00127 
00128     printf("running APMD...\n");
00129 
00130     newangles = new float[nimg*3];
00131     status = apmd(refprj, refparams, expimg, options, newangles);
00132     if (status != 0) {
00133        fprintf(stderr, "APMD failed!\n");
00134        goto EXIT;
00135     }
00136 
00137     for (i = 1; i<=nimg; i++) 
00138        printf("psi = %g, theta = %g, phi = %g\n", 
00139               newangles(1,i), newangles(2,i), newangles(3,i));
00140 
00141 EXIT:
00142     if (volume)    delete volume;
00143     if (expimg)    delete expimg;
00144     if (refprj)    delete refprj;
00145     if (newangles) delete newangles;
00146     return status;
00147 }
00148 

Generated on Tue Jun 11 13:46:14 2013 for EMAN2 by  doxygen 1.3.9.1