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

doapmq.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 
00073     APMQopt options;
00074 
00075     vector <float> angles;
00076     float   delta, tlb, tub, plb, pub;
00077     int     ndim, nx, ny, nz, nang, status;
00078     int     nref, nimg, i;
00079     double  t0, t1;
00080     float   *newangles, *shifts;
00081 
00082     printf("reading a 3-D volume...\n");
00083     volume->read_image("vol001.tfc");
00084 
00085     ndim = volume->get_ndim();
00086     nx   = volume->get_xsize();
00087     ny   = volume->get_ysize();
00088     nz   = volume->get_zsize();
00089 
00090     // print some stats
00091     printf("ndim = %d, nx = %d, ny = %d, nz = %d\n", ndim, nx, ny, nz);
00092 
00093     // generate a set of reference projections from the volume
00094 
00095     delta = 15.0;  // angular spacing
00096     tlb   = 0.0;   // lower bound on theta
00097     tub   = 90.0;  // upper bound on theta
00098     plb   = 0.0;   // lower bound on phi
00099     pub   = 359.9; // upper bound on phi
00100 
00101     // set angles used to generate reference projections
00102     angles = Util::voea(delta, tlb, tub, plb, pub); 
00103     nang   = angles.size()/3;
00104     printf("size(angles) = %d\n", nang);
00105 
00106     refparams["anglelist"] = angles;
00107     refparams["angletype"] = "SPIDER";
00108     refparams["radius"]    = 30.0;
00109     t0 = mytimer();
00110     printf("generating reference projections...\n");
00111     EMData* refprj = volume->project("pawel", refparams);
00112     t1 = mytimer() - t0;
00113     nref  = refprj->get_zsize();
00114     printf("nref = %d\n", nref);
00115   
00116     printf("time used in ref projection calculation = %11.3e\n", t1);
00117 
00118     // read experimental images
00119     expimg->read_image("tf2d0001.tfc"); 
00120     nimg = expimg->get_zsize();
00121 
00122     // run APMD on expimg using refprj as the reference, 
00123     printf("running APMQ...\n");
00124 
00125     options.mr      = 5;    // first ring
00126     options.nr      = 25;   // last ring
00127     options.shrange = 4;    // shift search range
00128     options.istep   = 1;    // shift search step size
00129     options.mode    = 'F';  
00130     options.range   = 0.0;  // no restricted angular search
00131     options.angexps = NULL;
00132 
00133     newangles = (float*) calloc(3*nimg,sizeof(float));
00134     shifts    = (float*) calloc(2*nimg,sizeof(float));
00135 
00136     status = apmq(refprj, refparams, expimg, options, newangles, shifts);
00137     if (status != 0) {
00138        fprintf(stderr, "APMD failed! status = %d\n", status);
00139        goto EXIT;
00140     }
00141 
00142     for (i = 1; i<=nimg; i++) 
00143        printf("psi = %g, theta = %g, phi = %g, sx = %g, sy = %g\n", 
00144               newangles(1,i), newangles(2,i), newangles(3,i),
00145               shifts(1,i), shifts(2,i));
00146 
00147 EXIT:
00148     if (volume)    delete volume;
00149     if (expimg)    delete expimg;
00150     if (refprj)    delete refprj;
00151     if (newangles) delete newangles;
00152     if (shifts)    delete shifts;
00153     return status;
00154 }

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