EMAN2
spiderio.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__spiderio_h__
33#define eman__spiderio_h__ 1
34
35#include "imageio.h"
36
37namespace EMAN
38{
71 class SpiderIO : public ImageIO
72 {
73 public:
74 explicit SpiderIO(const string & fname, IOMode rw_mode = READ_ONLY);
75 ~SpiderIO();
76
78 static bool is_valid(const void *first_block);
79
80 bool is_single_image_format() const { return false; }
81
85 int get_nimg();
86
87 protected:
89 {
90 float nslice; // number of slices in volume; 1 for a 2D image.
91 float nrow; // nrow, number of rows per slice
92 float irec; // total number of records in the file (unused)
93 float nhistrec; // obsolete, unused
94
103 float type; //iform, file type
104
110 float mmvalid; // imami, max/min flag.
111 float max; // fmax, max value
112 float min; // fmin, min value
113 float mean; // av, average value
114 float sigma; // sig, std dev, -1=unknown
115 float ihist; // obsolete, no longer used
116 float nsam; // nsam, number of pixels per row
117 float headrec; // labrec, number of records in header
118 float angvalid; // iangle, flag, 1 if tilt angles have been computed
119 float phi; // tilt angle
120 float theta; // tilt angle
121 float gamma; // tilt angle (also called psi).
122 float dx; // xoff, x translation
123 float dy; // yoff, y translation
124 float dz; // zoff, z translation
125 float scale; // scale factor
126 float headlen; // labbyt, header length in bytes
127 float reclen; // lenbyt, record length in bytes
128
141 float istack;
142 float inuse; // not used
148 float maxim;
152 float imgnum;
153
156 float lastindx;
157
158 float u6; // unused
159 float u7; // unused
160
166 float Kangle;
167 float phi1;
168 float theta1;
169 float psi1;
170 float phi2;
171 float theta2;
172 float psi2;
173 char u8[48]; //unused
174 float xf[27]; // reserved for Jose Maria's transforms
175 float u9[135]; // unused
176 char date[11]; // creation date e.g. 27-MAY-1999
177 char time[8]; // creation time e.g. 09:43:19
178 char title[160];
179 };
180
182 {
189 };
190
191 enum
192 {
196 };
197
211 //ISTACK, MAXIM, IMGNUM only useful for overall stack header
212 int write_single_header(const Dict & dict, const Region* area, int image_index, size_t offset,
213 SpiderHeader *& hp, int ISTACK, int MAXIM=1, int IMGNUM=1, bool use_host_endian=true);
214
226 int write_single_data(float *data, const Region * area, SpiderHeader *& hp,
227 size_t offset, int img_index, int max_nimg, bool use_host_endian=true);
228
233 virtual bool is_valid_spider(const void *first_block);
234
235 protected:
236 bool need_swap() const;
237 void swap_data(float *data, size_t nitems);
238 void swap_header(SpiderHeader * header);
239
240 protected:
241
242 SpiderHeader *first_h; // overall image header
243 SpiderHeader *cur_h; // the current reading/writing image header
244
247 };
248}
249
250#endif //eman__spiderio_h__
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
ImageIO classes are designed for reading/writing various electron micrography image formats,...
Definition: imageio.h:127
IOMode rw_mode
Definition: imageio.h:353
Region defines a 2D or 3D rectangular region specified by its origin coordinates and all edges' sizes...
Definition: geometry.h:497
SPIDER: (System for Processing Image Data from Electron microscopy and Related fields) is an image pr...
Definition: spiderio.h:72
int write_single_data(float *data, const Region *area, SpiderHeader *&hp, size_t offset, int img_index, int max_nimg, bool use_host_endian=true)
write a single image data
Definition: spiderio.cpp:616
int get_nimg()
get the number of images in this stacked SPIDER image
Definition: spiderio.cpp:678
SpiderHeader * cur_h
Definition: spiderio.h:243
SpiderIO(const string &fname, IOMode rw_mode=READ_ONLY)
Definition: spiderio.cpp:44
bool is_new_file
Definition: spiderio.h:246
virtual bool is_valid_spider(const void *first_block)
check the data block to see if it represents valid stacked SPIDER image file header
Definition: spiderio.cpp:106
void swap_header(SpiderHeader *header)
Definition: spiderio.cpp:654
void swap_data(float *data, size_t nitems)
Definition: spiderio.cpp:647
@ OVERALL_STACK_HEADER
Definition: spiderio.h:194
@ SINGLE_IMAGE_HEADER
Definition: spiderio.h:193
@ NUM_FLOATS_IN_HEADER
Definition: spiderio.h:195
bool is_single_image_format() const
Is this image format only storing 1 image or not.
Definition: spiderio.h:80
bool need_swap() const
Definition: spiderio.cpp:696
static bool is_valid(const void *first_block)
Definition: spiderio.cpp:111
int write_single_header(const Dict &dict, const Region *area, int image_index, size_t offset, SpiderHeader *&hp, int ISTACK, int MAXIM=1, int IMGNUM=1, bool use_host_endian=true)
write a SPIDER header to spider_file
Definition: spiderio.cpp:400
bool is_big_endian
Definition: spiderio.h:245
SpiderHeader * first_h
Definition: spiderio.h:242
E2Exception class.
Definition: aligner.h:40
float imgnum
imgnum is only used in a stacked image header.
Definition: spiderio.h:152
float Kangle
flag that additional angles are present in header.
Definition: spiderio.h:166
float mmvalid
max/min flag.
Definition: spiderio.h:110
float lastindx
This position is only used in the overall header of indexed stacks.
Definition: spiderio.h:156
float maxim
maxim is only used in the overall header for a stacked image file.
Definition: spiderio.h:148
float type
file type: 1 : 2D image; 3 : 3D volume; -11 : 2D Fourier, mixed radix odd.
Definition: spiderio.h:103
float istack
istack = 0 for simple 2D or 3D (non-stack) files.
Definition: spiderio.h:141