EMAN2
imagicio.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__imagicio_h__
33#define eman__imagicio_h__ 1
34
35#include "imageio.h"
36
37namespace EMAN
38{
65 class ImagicIO : public ImageIO
66 {
67 public:
68 static const char *HED_EXT;
69 static const char *IMG_EXT;
70
71 explicit ImagicIO(const string & fname, IOMode rw_mode = READ_ONLY);
72 ~ImagicIO();
73
75 static bool is_valid(const void *first_block);
76
78 {
79 return false;
80 }
81
82 int get_nimg();
83
84 private:
85 static const char *REAL_TYPE_MAGIC;
86 static const char *CTF_MAGIC;
87
88
90 {
97 };
98
99 enum
100 {
104 };
105
107 {
108 int imgnum; // image number, [1,n]
109 int count; // total number of images - 1 (only first image), [0,n-1]
110 int error; // Error code for this image
111 int headrec; // # of header records/image (always 1)
112 int mday; // image creation time
113 int month;
114 int year;
115 int hour;
117 int sec;
118 int reals; // image size in reals
119 int pixels; // image size in pixels
120 int ny; // # of lines / image
121 int nx; // # of pixels / line
122 char type[4]; // PACK, INTG, REAL, COMP, RECO
123 int ixold; // Top left X-coord. in image before windowing
124 int iyold; // Top left Y-coord. in image before windowing
125 float avdens; // average density
126 float sigma; // deviation of density
127 float varia; // variance of density
128 float oldav; // old average density
129 float max; // max density
130 float min; // min density
131 int complex; // not used
132 float cellx; // not used
133 float celly; // not used
134 float cellz; // not used
135 float cella1; // not used
136 float cella2; // not used
137 char label[80]; // image id string
138 int space[8];
139 float mrc1[4];
140 int mrc2;
141 int space2[7];
142 int lbuf; // effective buffer len = nx
143 int inn; // lines in buffer = 1
144 int iblp; // buffer lines/image = ny
145 int ifb; // 1st line in buf = 0
146 int lbr; // last buf line read = -1
147 int lbw; // last buf line written = 0
148 int lastlr; // last line called for read = -1
149 int lastlw; // last line called for write = 1
150 int ncflag; // decode to complex = 0
151 int num; // file number = 40 (?)
152 int nhalf; // leff/2
153 int ibsd; // record size for r/w (words) = nx*2
154 int ihfl; // file # = 8
155 int lcbr; // lin count read buf = -1
156 int lcbw; // lin count wr buf = 1
157 int imstr; // calc stat on rd = -1
158 int imstw; // calc stat on wr = -1
159 int istart; // begin line in buf = 1
160 int iend; // end line in buf = nx
161 int leff; // eff line len = nx
162 int linbuf; // line len (16 bit) nx *2
163 int ntotbuf; // total buf in pgm = -1
164 int space3[5];
165 int icstart; // complex line start = 1
166 int icend; // complex line end = nx/2
167 int rdonly; // read only = 0
168 int misc[157]; // Remainder of header (EMAN1 specific settings not supported)
169 };
170
171 size_t get_datatype_size(DataType t);
174 void swap_header(ImagicHeader & hed);
175 DataType get_datatype_from_name(const char *name);
176
178 Ctf * read_ctf(const ImagicHeader& hed) const;
179 void write_ctf(const Ctf * const ctf, int image_index = 0);
180
181 private:
184
185 FILE *hed_file;
186 FILE *img_file;
187
192
194 int nz;
195 };
196
197}
198
199
200#endif //eman__imagicio_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: imagicio.h:66
size_t get_datatype_size(DataType t)
Definition: imagicio.cpp:650
bool is_single_image_format() const
Is this image format only storing 1 image or not.
Definition: imagicio.h:77
ImagicIO(const string &fname, IOMode rw_mode=READ_ONLY)
Definition: imagicio.cpp:50
bool is_big_endian
Definition: imagicio.h:189
FILE * hed_file
Definition: imagicio.h:185
FILE * img_file
Definition: imagicio.h:186
static const char * REAL_TYPE_MAGIC
Definition: imagicio.h:85
ImagicHeader imagich
Definition: imagicio.h:188
DataType get_datatype_from_name(const char *name)
Definition: imagicio.cpp:628
bool is_new_img
Definition: imagicio.h:191
@ IMAGIC_UNKNOWN_TYPE
Definition: imagicio.h:96
@ IMAGIC_FFT_FLOAT_COMPLEX
Definition: imagicio.h:95
@ IMAGIC_FLOAT_COMPLEX
Definition: imagicio.h:94
int get_nimg()
Return the number of images in this image file.
Definition: imagicio.cpp:622
static bool is_valid(const void *first_block)
Definition: imagicio.cpp:121
bool is_new_hed
Definition: imagicio.h:190
static const char * HED_EXT
Definition: imagicio.h:68
DataType datatype
Definition: imagicio.h:193
void make_header_host_endian(ImagicHeader &hed)
Definition: imagicio.cpp:690
string img_filename
Definition: imagicio.h:183
@ NUM_4BYTES_AFTER_SPACE
Definition: imagicio.h:103
@ NUM_4BYTES_AFTER_IXOLD
Definition: imagicio.h:102
@ NUM_4BYTES_PRE_IXOLD
Definition: imagicio.h:101
int to_em_datatype(DataType t)
Definition: imagicio.cpp:672
static const char * IMG_EXT
Definition: imagicio.h:69
string hed_filename
Definition: imagicio.h:182
Ctf * read_ctf(const ImagicHeader &hed) const
the Ctf object is a EMAN1Ctf object.
Definition: imagicio.cpp:567
void swap_header(ImagicHeader &hed)
Definition: imagicio.cpp:698
static const char * CTF_MAGIC
Definition: imagicio.h:86
void write_ctf(const Ctf *const ctf, int image_index=0)
Definition: imagicio.cpp:589
E2Exception class.
Definition: aligner.h:40