EMAN2
pifio.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__pifio_h__
33#define eman__pifio_h__ 1
34
35#include "imageio.h"
36
37namespace EMAN
38{
52 class PifIO : public ImageIO
53 {
54 public:
55 explicit PifIO(const string & fname, IOMode rw_mode = READ_ONLY);
56 ~PifIO();
57
59 static bool is_valid(const void *first_block);
60
62 {
63 return false;
64 }
65 int get_nimg();
66
67 private:
68 enum
69 {
71 };
72
74 {
80 PIF_BOXED_DATA = 6, // byte, read as 0
87 PIF_MAP_FLOAT_INT_2 = 40, // 4 byte floatint, read as 2
88 PIF_BOXED_FLOAT_INT = 46, // 4 byte floatint, read as 2
90 };
91
92 // note there are no floats in these files. Floats are stored as ints with
93 // a scaling factor.
95 {
96 int magic[2]; // magic number; identify PIF file
97 char scalefactor[16]; // to convert float ints -> floats
98 int nimg; // number of images in file
99 int endian; // endianness, 0 -> vax,intel (little), 1 -> SGI, PowerPC (big)
100 char program[32]; // program which generated image
101 int htype; // 1 - all images same number of pixels and depth, 0 - otherwise
102 int nx; // number of columns
103 int ny; // number of rows
104 int nz; // number of sections
105 int mode; // image data type
106
107 int even;
108 int mrcX; // MRC X dim
109 int mrcY; // MRC Y dim
110 int mrcZ; // MRC Z dim
111 char scale_fac[16];
112 char ctf_a0[13];
113 char ctf_a1[13];
114 char ctf_a2[13];
115 char ctf_a3[13];
116 char ctf_a4[13];
117 char ctf_a5[13];
118 char pad[318];
119 };
120
122 { // color map for depthcued images
123 short r[256];
124 short g[256];
125 short b[256];
126 };
127
129 {
130 int nx;
131 int ny;
132 int nz; // size of this image
133 int mode; // image data type
134 int bkg; // background value
135 int radius; // boxed image radius
138 int zstart; // starting number of each axis
139 int mx;
140 int my;
141 int mz; // intervals along x,y,z
142 int xlen;
143 int ylen;
144 int zlen; // cell dimensions (floatints)
145 int alpha;
146 int beta;
147 int gamma; // angles (floatints)
148 int mapc;
149 int mapr;
150 int maps; // axes->sections (1,2,3=x,y,z)
151 int min;
152 int max;
153 int mean;
154 int sigma; // statistics (floatints)
155 int ispg; // spacegroup
156 int nsymbt; // bytes for symmetry ops
158 int yorigin; // origin (floatint)
159 char title[80];
160 char time[32];
161 char imagenum[16]; // unique micrograph number
162 char scannum[8]; // scan number of micrograph
165 int pad[63]; // later use
166 };
167
168 int get_mode_size(PifDataMode mode);
169 bool is_float_int(int mode);
170 void fseek_to(int image_index);
171 int to_em_datatype(int pif_datatype);
172 int to_pif_datatype(int em_datatype);
173
174 string filename;
180 };
181
182}
183
184
185#endif //eman__pifio_h__
ImageIO classes are designed for reading/writing various electron micrography image formats,...
Definition: imageio.h:127
IOMode rw_mode
Definition: imageio.h:353
PIF(Portable Image Format for EM Data) is an image format from Purdue University.
Definition: pifio.h:53
DEFINE_IMAGEIO_FUNC
Definition: pifio.h:58
int mode_size
Definition: pifio.h:176
@ PIF_MAGIC_NUM
Definition: pifio.h:70
bool is_float_int(int mode)
Definition: pifio.cpp:97
string filename
Definition: pifio.h:174
int get_mode_size(PifDataMode mode)
Definition: pifio.cpp:64
bool is_new_file
Definition: pifio.h:178
int get_nimg()
Return the number of images in this image file.
Definition: pifio.cpp:540
static bool is_valid(const void *first_block)
Definition: pifio.cpp:164
PifFileHeader pfh
Definition: pifio.h:175
int to_em_datatype(int pif_datatype)
Definition: pifio.cpp:547
PifDataMode
Definition: pifio.h:74
@ PIF_FLOAT_INT
Definition: pifio.h:77
@ PIF_SHORT
Definition: pifio.h:76
@ PIF_SHORT_COMPLEX
Definition: pifio.h:78
@ PIF_FLOAT_COMPLEX
Definition: pifio.h:84
@ PIF_MAP_FLOAT_SHORT
Definition: pifio.h:85
@ PIF_BOXED_FLOAT_INT
Definition: pifio.h:88
@ PIF_SHORT_FLOAT
Definition: pifio.h:81
@ PIF_FLOAT
Definition: pifio.h:83
@ PIF_BOXED_DATA
Definition: pifio.h:80
@ PIF_MAP_FLOAT_INT
Definition: pifio.h:86
@ PIF_CHAR
Definition: pifio.h:75
@ PIF_INVALID
Definition: pifio.h:89
@ PIF_MAP_FLOAT_INT_2
Definition: pifio.h:87
@ PIF_FLOAT_INT_COMPLEX
Definition: pifio.h:79
@ PIF_SHORT_FLOAT_COMPLEX
Definition: pifio.h:82
bool is_big_endian
Definition: pifio.h:177
bool is_single_image_format() const
Is this image format only storing 1 image or not.
Definition: pifio.h:61
PifIO(const string &fname, IOMode rw_mode=READ_ONLY)
Definition: pifio.cpp:44
void fseek_to(int image_index)
Definition: pifio.cpp:193
int to_pif_datatype(int em_datatype)
Definition: pifio.cpp:587
float real_scale_factor
Definition: pifio.h:179
E2Exception class.
Definition: aligner.h:40