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

spiderio.h

Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
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__spiderio_h__
00037 #define eman__spiderio_h__ 1
00038 
00039 #include "imageio.h"
00040 
00041 namespace EMAN
00042 {
00075         class SpiderIO:public ImageIO
00076         {
00077           public:
00078                 explicit SpiderIO(const string & filename, IOMode rw_mode = READ_ONLY);
00079                 ~SpiderIO();
00080 
00081                 DEFINE_IMAGEIO_FUNC;
00082                 static bool is_valid(const void *first_block);
00083                 
00084                 bool is_single_image_format() const { return false;     }
00085                 
00089                 int get_nimg();
00090 
00091         protected:
00092                 struct SpiderHeader
00093                 {
00094                         float nslice;           // number of slices in volume; 1 for a 2D image.
00095                         float nrow;         // nrow, number of rows per slice 
00096                         float irec;                     // total number of records in the file (unused)
00097                         float nhistrec;     // obsolete, unused
00098                         
00107                         float type;             //iform, file type
00108                         
00114                         float mmvalid;          // imami, max/min flag.
00115                         float max;          // fmax, max value
00116                         float min;          // fmin, min value
00117                         float mean;         // av, average value
00118                         float sigma;            // sig, std dev, -1=unknown
00119                         float ihist;        // obsolete, no longer used
00120                         float nsam;         // nsam, number of pixels per row
00121                         float headrec;          // labrec, number of records in header
00122                         float angvalid;         // iangle, flag, 1 if tilt angles have been computed
00123                         float phi;          // tilt angle
00124                         float theta;        // tilt angle
00125                         float gamma;        // tilt angle  (also called psi).
00126                         float dx;           // xoff, x translation
00127                         float dy;           // yoff, y translation
00128                         float dz;                       // zoff, z translation
00129                         float scale;        // scale factor
00130                         float headlen;          // labbyt, header length in bytes
00131                         float reclen;       // lenbyt, record length in bytes
00132 
00145                         float istack;
00146                         float inuse;        // not used
00152                         float maxim;
00156                         float imgnum;
00157                         
00160                         float lastindx;    
00161                         
00162                         float u6;                  // unused
00163                         float u7;          // unused
00164                         
00170                         float Kangle;   
00171                         float phi1;
00172                         float theta1;
00173                         float psi1;
00174                         float phi2;
00175                         float theta2;
00176                         float psi2;
00177                         char  u8[48];           //unused
00178                         float xf[27];           // reserved for Jose Maria's transforms
00179                         float u9[135];      // unused
00180                         char date[11];      // creation date e.g. 27-MAY-1999 
00181                         char time[8];       // creation time e.g. 09:43:19 
00182                         char title[160];    
00183                 };
00184 
00185                 enum SpiderType
00186                 {
00187                         IMAGE_2D                        =   1,
00188                         IMAGE_3D                        =   3,
00189                         IMAGE_2D_FFT_ODD        = -11,
00190                         IMAGE_2D_FFT_EVEN       = -12,
00191                         IMAGE_3D_FFT_ODD        = -21,
00192                         IMAGE_3D_FFT_EVEN       = -22
00193                 };
00194 
00195                 enum
00196                 {
00197                         SINGLE_IMAGE_HEADER             =   0,
00198                         OVERALL_STACK_HEADER    =       2,
00199                         NUM_FLOATS_IN_HEADER    = 211
00200                 };
00201                 
00215                 //ISTACK, MAXIM, IMGNUM only useful for overall stack header
00216                 int write_single_header(const Dict & dict, const Region* area, int image_index, size_t offset,
00217                                                                 SpiderHeader *& hp,     int ISTACK, int MAXIM=1, int IMGNUM=1, bool use_host_endian=true);      
00218                 
00230                 int write_single_data(float *data, const Region * area, SpiderHeader *& hp,
00231                                                                 size_t offset, int img_index, int max_nimg, bool use_host_endian=true);
00232                 
00237                 virtual bool is_valid_spider(const void *first_block);
00238 
00239           protected:
00240                 bool need_swap() const;
00241                 void swap_data(float *data, size_t nitems);
00242                 void swap_header(SpiderHeader * header);
00243 
00244           protected:
00245                 string filename;
00246                 IOMode rw_mode;
00247 
00248                 FILE *spider_file;
00249                 SpiderHeader *first_h; // overall image header
00250                 SpiderHeader *cur_h;   // the current reading/writing image header
00251                 
00252                 bool is_big_endian;
00253                 bool initialized;
00254                 bool is_new_file;
00255         };
00256 }
00257 
00258 #endif  //eman__spiderio_h__

Generated on Tue Jun 11 13:40:44 2013 for EMAN2 by  doxygen 1.3.9.1