EMAN2
imagicio2.h
Go to the documentation of this file.
1/*
2 * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
3 * Copyright (c) 2000-2006 Baylor College of Medicine
4 *
5 * This software is issued under a joint BSD/GNU license. You may use the
6 * source code in this file under either license. However, note that the
7 * complete EMAN2 and SPARX software packages have some GPL dependencies,
8 * so you are responsible for compliance with the licenses of these packages
9 * if you opt to use BSD licensing. The warranty disclaimer below holds
10 * in either instance.
11 *
12 * This complete copyright notice must be included in any revised version of the
13 * source code. Additional authorship citations may be added, but existing
14 * author citations must be preserved.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 * */
31
32#ifndef eman__imagicio2_h__
33#define eman__imagicio2_h__ 1
34
35#include "imageio.h"
36
37namespace EMAN
38{
69 class ImagicIO2 : public ImageIO
70 {
71 public:
72 static const char *HED_EXT;
73 static const char *IMG_EXT;
74
75 explicit ImagicIO2(const string & fname, IOMode rw_mode = READ_ONLY);
76 ~ImagicIO2();
77
79 static bool is_valid(const void *first_block);
80
81 /* If returns -1, then we have an old-style Imagic file
82 *
83 * @return 0 for new Imagic4D file, -1 for old-style Imagic file*/
84 int init_test();
85
90 {
91 return false;
92 }
93
97 int get_nimg();
98
99 private:
100 static const char *REAL_TYPE_MAGIC;
101 static const char *CTF_MAGIC;
102
103
105 {
112 };
113
114 /*This enum is used to skip those char type when swap bytes between big endian and little endian*/
115 enum
116 {
119 NUM_4BYTES_AFTER_NAME = 150 //before HISTORY
120 };
121
123 {
124 VAX_VMS = 16777216, //for VAX/VMS
125 LINUX_WINDOWS = 33686018, //for OSF, ULTRIX, LINUX, MS WINDOWS
126 SGI_IBM = 67372036 //for SiliconGraphics, SUN, HP, IBM
127 };
128
132 struct Imagic4D {
133 int imgnum; //1 image location number (1,2,3,...)
134 int count; //2 total # images in file (1st record only), total number of images - 1 (0,1,2,...)
135 int error; //3 error code for this image during IMAGIC run
136 int headrec;//4 number of header records per image (=1 always)
137 int month; //5 creation month
138 int mday; //6 creation day
139 int year; //7 creation year
140 int hour; //8 creation hour
141 int minute; //9 creation minute
142 int sec; //10 creation second
143 int rsize; //11 image size in bytes
144 int izold; //12 top left Z co-ordinate before THREED-CUT
145 int ny; //13 number of lines per image (for 1D data IXLP1=1)
146 int nx; //14 number of pixels per line (IYLP)
147 char type[4]; //15 only 'REAL', or 'INTG' are implemented for EMAN
148 // 4 characters determining the image type
149 // REAL : REAL/float
150 // INTG : INTEGER*2/short
151 // PACK : PACK/byte
152 // COMP : 2 REAL / 2 float
153 // RECO : complex format with 0 in imaginary part)
154 int ixold; //16 top left X co-ordinate before CUT-IMAGE (boxing)
155 int iyold; //17 top left Y co-ordinate before CUT-IMAGE (boxing)
156 float avdens; //18 average density in image
157 float sigma; //19 standard deviation of density
158 float user1; //20 at user's own disposal
159 float user2; //21 at user's own disposal
160 float densmax; //22 highest density in image
161 float densmin; //23 minimal density in image
162 int complex; //24 label indicating that data is always complex
163 float defocus1; //25 defocus value 1
164 float defocus2; //26 defocus value 2
165 float defangle; //27 defocus angle
166 float sinostart; //28 start angle if image is a sinogram
167 float sinoend; //29 end angle if image is a sinogram
168 char label[80]; //30-49 coded NAME/TITLE of the image (80 characters)
169 float ccc3d; //50 3D simularity criteria
170 int ref3d; //51 3D membership
171 int mident; //52 micrograph identification number
172 int ezshift; //53 equivalent shift in Z direction
173 int ealpha; //54 equivalent Euler angle alpha
174 int ebeta; //55 equivalent Euler angle beta
175 int egamma; //56 equivalent Euler angle gamma
176 int unused1; //57 currently not used
177 int unused2; //58 currently not used
178 int nalisum; //59 number of image summed
179 int pgroup; //60 point-group symmetry in international notation (622, for example)
180 int izlp; //61 number of 2D planes in 3D data (for 1D/2D: IZLP=1)
181 int i4lp; //62 number of objects in file:
182 // 1D (IXLP=1): number of 1D spectra
183 // 2D (IZLP=1): number of 2D images
184 // 3D (IZLP>1): number of 3D volumes
185 int i5lp; //63
186 int i6lp; //64
187 float alpha; //65 Euler angle alpha (3D and Angular Reconst.)
188 float beta; //66 Euler angle beta (3D and Angular Reconst.)
189 float gamma; //67 Euler angle gamma (3D and Angular Reconst.)
190 int imavers; //68 IMAGIC version, which created the file (yyyymmdd)
191 int realtype; //69 floating point type, machine stamp
192 // 16777216 for VAX/VMS
193 // 33686018 for OSF,ULTRIX, LINUX, MS Windows
194 // 67372036 for SiliconGraphics, SUN, HP, IBM
195 char buffer[120]; //70-99 Variables that control the buffering
196 // during read/write in IMAGIC-5 programs.
197 // PLEASE DO NOT TOUCH !
198 float angle; //100 last rotation angle
199 float voltage; //101 acceleration voltage (kv)
200 int spaberr; //102 sperical aberration (mm)
201 int pcoher; //103 partial coherence
202 float ccc; //104 cross correlation peak hight
203 float errar; //105 error in angular reconstitution, if -1.0: the file is a special file (FABOSA)
204 float err3d; //106 error in 3D reconstruction
205 int ref; //107 (multi-) reference number
206 float classno; //108 class number in MSA classification
207 float locold; //109 location number before CUT-IMAGE (boxing), or before copy in ANG-RECONST and EX-COPY
208 float repqual; //110 representation quality, used in MSA-RUN and MSA (eigen) filtering
209 float zshift; //111 last shift in Z direction
210 float xshift; //112 last shift in X direction
211 float yshift; //113 last shift in Y direction
212 float numcls; //114 number members in the class specified in CLASSNO, if this image represents a class average (class-sum image)
213 float ovqual; //115 overall quality of the class in CLASSNO
214 float eangle; //116 equivalent angle
215 float exshift; //117 equivalent shift in X direction
216 float eyshift; //118 equivalent shift in Y direction
217 float cmtotvar; //119 total variance in data matrix relative to center of mass (MSA calculations)
218 float informat; //120 Gauss norm / real*FT Space information of the data set
219 int numeigen; //121 number of eigen values in MSA
220 int niactive; //122 number of active images in MSA calculations
221 float resolx; //123 Angstrom per pixel/voxel in X direction, if DAT1(105) = -1.0 (FABOSA): mm per pixel
222 float resoly; //124 Angstrom per pixel/voxel in Y direction
223 float resolz; //125 Angstrom per pixel/voxel in Z direction
224 float alpha2; //126 Euler angle alpha (from projection matching), Special FABOSA variables if DAT1(105) = -1.0
225 float beta2; //127 Euler angle beta (from projection matching), Special FABOSA variables if DAT1(105) = -1.0
226 float gamma2; //128 Euler angle gamma (from projection matching), Special FABOSA variables if DAT1(105) = -1.0
227 float nmetric; //129 Metric used in MSA calculations
228 float actmsa; //130 a flag indicating whether the "image" is active or not. Used during MSA calculations
229 float coosmsa[69]; //131-199 co-ordinates of "image" along factorial axis
230 // number 1 through 69 (maximum possible).
231 // Used during MSA calculations.
232// float eigval; //150 eigval, eigenvalues if the "images" represent eigenimages (eigenvalue #1 into loc#1 etc.)
233 char history[228]; //220-256 coded history of image (228 characters)
234 };
235
236 size_t get_datatype_size(DataType t) const;
237 int to_em_datatype(DataType t) const;
238 void make_header_host_endian(Imagic4D & hed) const;
239 void swap_header(Imagic4D & hed) const;
240 DataType get_datatype_from_name(const char *name) const;
241
243 Ctf * read_ctf(const Imagic4D& hed) const;
244 void write_ctf(const Ctf * const ctf, int image_index = 0);
245
246 int generate_machine_stamp() const;
247 private:
250
251 FILE *hed_file;
252 FILE *img_file;
253
258
260 int nz;
261 };
262
263}
264
265
266#endif //eman__imagicio2_h__
Ctf is the base class for all CTF model.
Definition: ctf.h:60
ImageIO classes are designed for reading/writing various electron micrography image formats,...
Definition: imageio.h:127
IOMode rw_mode
Definition: imageio.h:353
IMAGIC-5 Header File Format.
Definition: imagicio2.h:70
DataType datatype
Definition: imagicio2.h:259
static const char * IMG_EXT
Definition: imagicio2.h:73
int get_nimg()
Get number of images in this file.
Definition: imagicio2.cpp:739
FILE * img_file
Definition: imagicio2.h:252
static bool is_valid(const void *first_block)
Definition: imagicio2.cpp:161
static const char * REAL_TYPE_MAGIC
Definition: imagicio2.h:100
@ IMAGIC_FFT_FLOAT_COMPLEX
Definition: imagicio2.h:110
ImagicIO2(const string &fname, IOMode rw_mode=READ_ONLY)
Definition: imagicio2.cpp:51
string hed_filename
Definition: imagicio2.h:248
void write_ctf(const Ctf *const ctf, int image_index=0)
Definition: imagicio2.cpp:438
bool is_big_endian
Definition: imagicio2.h:255
Ctf * read_ctf(const Imagic4D &hed) const
the Ctf object is a EMAN1Ctf object.
Definition: imagicio2.cpp:416
static const char * HED_EXT
Definition: imagicio2.h:72
Imagic4D imagich
Definition: imagicio2.h:254
void make_header_host_endian(Imagic4D &hed) const
Definition: imagicio2.cpp:651
string img_filename
Definition: imagicio2.h:249
int generate_machine_stamp() const
Definition: imagicio2.cpp:636
int to_em_datatype(DataType t) const
Definition: imagicio2.cpp:397
static const char * CTF_MAGIC
Definition: imagicio2.h:101
void swap_header(Imagic4D &hed) const
Definition: imagicio2.cpp:658
size_t get_datatype_size(DataType t) const
Definition: imagicio2.cpp:751
DataType get_datatype_from_name(const char *name) const
Definition: imagicio2.cpp:375
FILE * hed_file
Definition: imagicio2.h:251
bool is_single_image_format() const
If this file format is only for single iamge.
Definition: imagicio2.h:89
@ NUM_4BYTES_AFTER_IXOLD
Definition: imagicio2.h:118
E2Exception class.
Definition: aligner.h:40
IMAGIC-4D file format http://www.imagescience.de/formats/formats.htm.
Definition: imagicio2.h:132