00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef IMPEM_DENSITY_HEADER_H
00010 #define IMPEM_DENSITY_HEADER_H
00011
00012 #include "em_config.h"
00013 #include "def.h"
00014 #include <IMP/exception.h>
00015 #include <iostream>
00016 #include <fstream>
00017 #include <cstring>
00018 #include <limits>
00019
00020 IMPEM_BEGIN_NAMESPACE
00021
00022
00023
00024 class IMPEMEXPORT DensityHeader
00025 {
00026
00027 public:
00028 DensityHeader();
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 emreal get_top(int ind) const
00063 {
00064 IMP_USAGE_CHECK(top_calculated_,
00065 " DensityHeader::get_top the top coordinates of the map "
00066 << "have not been setup yet " << std::endl);
00067 if (ind==0) return xtop_;
00068 if (ind==1) return ytop_;
00069 return ztop_;
00070
00071 }
00072
00073
00074
00075
00076
00077 void compute_xyz_top(bool force=false);
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 void update_map_dimensions(int nnx,int nny,int nnz);
00088
00089
00090
00091 void update_cell_dimensions();
00092
00093 void show(std::ostream& out=std::cout) const {
00094 out<< "nx: " << nx_ << " ny: " << ny_ << " nz: " << nz_ << std::endl;
00095 out<<"data_type: " << data_type_ << std::endl;
00096 out<<"nxstart: " << nxstart << " nystart: " << nystart <<" nzstart: "
00097 << nzstart << std::endl;
00098 out<<"mx: "<< mx <<" my:" << my << " mz: " << mz << std::endl;
00099 out<< "xlen: " << xlen <<" ylen: " << ylen <<" zlen: " << zlen
00100 << std::endl;
00101 out<<"alpha : " << alpha << " beta: " << beta <<" gamma: "<< gamma
00102 << std::endl;
00103 out<< "mapc : " << mapc << " mapr: " << mapr <<" maps: " << maps
00104 << std::endl;
00105 out<< "dmin: " << dmin << " dmax: " << dmax << " dmean: " << dmean
00106 << std::endl;
00107 out<<"ispg: " << ispg << std::endl;
00108 out<<"nsymbt: " << nsymbt << std::endl;
00109 out<< "user: " << user << std::endl;
00110 out<<"xorigin: " << xorigin_ << " yorigin: "<< yorigin_ <<" zorigin: "
00111 << zorigin_ << std::endl;
00112 out<<"map: " << map << std::endl;
00113 out<< "Objectpixelsize: " << Objectpixelsize_ << std::endl;
00114 out<< "Resolution: " << resolution_ << std::endl;
00115 out<< "machinestamp: " << machinestamp << std::endl;
00116 out<<"rms: " << rms << std::endl;
00117 out<<"nlabl: " << nlabl <<std::endl;
00118 for(int i=0;i<nlabl;i++)
00119 out<< "comments[" << i << "] = ->" << comments[i] << "<-" << std::endl;
00120 }
00121 friend std::ostream& operator<<(std::ostream& s, const DensityHeader &v) {
00122 v.show(s);
00123 return s;
00124 }
00125
00126
00127 static const unsigned short MAP_FIELD_SIZE = 4;
00128 static const unsigned short USER_FIELD_SIZE = 25;
00129 static const unsigned short COMMENT_FIELD_NUM_OF = 10;
00130 static const unsigned short COMMENT_FIELD_SINGLE_SIZE = 80;
00131
00132
00133
00134 int nxstart;
00135
00136 int nystart;
00137
00138 int nzstart;
00139
00140 int mx, my, mz;
00141 float xlen,ylen,zlen;
00142 float alpha, beta, gamma;
00143
00144
00145 int mapc, mapr, maps;
00146 float dmin,dmax,dmean;
00147 int ispg;
00148 int nsymbt;
00149 int user[USER_FIELD_SIZE];
00150 char map[MAP_FIELD_SIZE];
00151 int machinestamp;
00152 float rms;
00153 int nlabl;
00154
00155 char comments[COMMENT_FIELD_NUM_OF][COMMENT_FIELD_SINGLE_SIZE];
00156
00157
00158 int magic;
00159 float voltage;
00160 float Cs;
00161 float Aperture;
00162 float Magnification;
00163 float Postmagnification;
00164 float Exposuretime;
00165 float Microscope;
00166 float Pixelsize;
00167 float CCDArea;
00168 float Defocus;
00169 float Astigmatism;
00170 float AstigmatismAngle;
00171 float FocusIncrement;
00172 float CountsPerElectron;
00173 float Intensity;
00174 float EnergySlitwidth;
00175 float EnergyOffset;
00176 float Tiltangle;
00177 float Tiltaxis;
00178 float MarkerX;
00179 float MarkerY;
00180 int lswap;
00181
00182
00183 inline float get_resolution() const {
00184 IMP_INTERNAL_CHECK(is_resolution_set_,
00185 "The resolution was not set"<<std::endl);
00186 return resolution_;
00187 }
00188
00189 inline bool get_has_resolution() const {
00190 return is_resolution_set_;
00191 }
00192
00193 inline void set_resolution(float resolution) {
00194 is_resolution_set_=true;
00195 resolution_=resolution;}
00196
00197
00198 inline float get_spacing() const {return Objectpixelsize_;}
00199
00200 inline float get_xorigin() const {return xorigin_;}
00201
00202 inline float get_yorigin() const {return yorigin_;}
00203
00204 inline float get_zorigin() const {return zorigin_;}
00205
00206
00207
00208
00209
00210 inline float get_origin(int i) const {
00211 IMP_USAGE_CHECK(i >= 0 && i <= 2,
00212 "The origin coordinate should be between 0 and 2");
00213 switch (i) {
00214 case 0: return get_xorigin();
00215 case 1: return get_yorigin();
00216 default: return get_zorigin();
00217 }
00218 }
00219
00220
00221
00222
00223 inline void set_xorigin(float x) {xorigin_=x; top_calculated_=false;}
00224
00225
00226
00227
00228 inline void set_yorigin(float y) {yorigin_=y; top_calculated_=false;}
00229
00230
00231
00232
00233 inline void set_zorigin(float z) {zorigin_=z; top_calculated_=false;}
00234
00235 inline bool is_top_calculated() const { return top_calculated_;}
00236 float Objectpixelsize_;
00237
00238
00239
00240 inline int get_nx() const {return nx_;}
00241
00242 inline int get_ny() const {return ny_;}
00243
00244 inline int get_nz() const {return nz_;}
00245 inline int get_number_of_voxels() const {return nx_*ny_*nz_;}
00246
00247
00248
00249
00250 inline void set_number_of_voxels(int nx,int ny, int nz) {
00251 nx_=nx;ny_=ny;nz_=nz;
00252 }
00253
00254 inline int get_data_type() const {return data_type_;}
00255 inline void set_data_type(int data_type) {data_type_=data_type;}
00256
00257 protected:
00258 float xtop_, ytop_, ztop_;
00259 float xorigin_, yorigin_, zorigin_;
00260 bool top_calculated_;
00261 float resolution_;
00262 bool is_resolution_set_;
00263 int nx_,ny_,nz_;
00264
00265
00266 int data_type_;
00267 };
00268
00269 IMPEM_END_NAMESPACE
00270
00271 #endif