#include <sspiderio.h>
Inheritance diagram for EMAN::SingleSpiderIO:


Public Member Functions | |
| SingleSpiderIO (const string &filename, IOMode rw_mode=READ_ONLY) | |
| SingleSpiderIO constructor. | |
| ~SingleSpiderIO () | |
| int | write_header (const Dict &dict, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true) |
| Write a single SPIDER format header to an image. | |
| int | write_data (float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true) |
| Write data to an image. | |
| bool | is_single_image_format () const |
| Is this image format only storing 1 image or not. | |
Static Public Member Functions | |
| bool | is_valid (const void *first_block) |
Protected Member Functions | |
| bool | is_valid_spider (const void *first_block) |
| check the data block to see if it represents valid stacked SPIDER image file header | |
For Spider and Single Spider image format, please refer spiderio.h.
Definition at line 48 of file sspiderio.h.
|
||||||||||||
|
SingleSpiderIO constructor.
Definition at line 44 of file sspiderio.cpp. 00045 : SpiderIO(file, rw) 00046 { 00047 }
|
|
|
Definition at line 50 of file sspiderio.cpp. 00051 {
00052 }
|
|
|
Is this image format only storing 1 image or not. Some image formats like MRC only store 1 image in a file, so this function returns 'true' for them. Other image formats like IMAGIC/HDF5 may store mutliple images, so this function returns 'false' for them. Reimplemented from EMAN::SpiderIO. Definition at line 90 of file sspiderio.h. 00091 {
00092 return true;
00093 }
|
|
|
Reimplemented from EMAN::SpiderIO. Definition at line 75 of file sspiderio.cpp. References data, EMAN::ByteOrder::is_float_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes(). Referenced by EMAN::EMUtil::fast_get_image_type(), EMAN::EMUtil::get_image_type(), and is_valid_spider(). 00076 {
00077 ENTERFUNC;
00078 bool result = false;
00079
00080 if (first_block) {
00081 const float *data = static_cast < const float *>(first_block);
00082 float nslice = data[0];
00083 float nrow = data[1];
00084 float iform = data[4];
00085 float nsam = data[11];
00086 float labrec = data[12]; //NO. of records in file header
00087 float labbyt = data[21]; //total NO. of bytes in header
00088 float lenbyt = data[22]; //record length in bytes
00089 float istack = data[23];
00090
00091 bool big_endian = ByteOrder::is_float_big_endian(nslice);
00092 if (big_endian != ByteOrder::is_host_big_endian()) {
00093 ByteOrder::swap_bytes(&nslice);
00094 ByteOrder::swap_bytes(&nrow);
00095 ByteOrder::swap_bytes(&iform);
00096 ByteOrder::swap_bytes(&nsam);
00097 ByteOrder::swap_bytes(&labrec);
00098 ByteOrder::swap_bytes(&labbyt);
00099 ByteOrder::swap_bytes(&lenbyt);
00100 ByteOrder::swap_bytes(&istack);
00101 }
00102
00103 if( int(nslice) != nslice || int(nrow) != nrow
00104 || int(iform) != iform || int(nsam) != nsam
00105 || int(labrec) != labrec || int(labbyt) != labbyt
00106 || int(lenbyt) != lenbyt ) {
00107 result = false;
00108 }
00109 else {
00110 int itype = static_cast < int >(iform);
00111 if( int(istack) != SINGLE_IMAGE_HEADER ) {
00112 result = false; //istack>0 for overall header, istack<0 for indexed stack of image
00113 }
00114 else if( itype == IMAGE_2D_FFT_ODD || itype == IMAGE_2D_FFT_EVEN
00115 || itype == IMAGE_3D_FFT_ODD || itype == IMAGE_3D_FFT_EVEN ) {
00116 result = false; //Complex SPIDER image not supported in EMAN2
00117 }
00118 else if (itype == IMAGE_2D || itype == IMAGE_3D) {
00119 result = true;
00120 }
00121 }
00122
00123 int ilabrec = static_cast<int>(labrec);
00124 int ilabbyt = static_cast<int>(labbyt);
00125 int ilenbyt = static_cast<int>(lenbyt);
00126 if( ilabbyt != ilabrec * ilenbyt ) {
00127 result = false;
00128 }
00129 }
00130
00131 EXITFUNC;
00132 return result;
00133 }
|
|
|
check the data block to see if it represents valid stacked SPIDER image file header
Reimplemented from EMAN::SpiderIO. Definition at line 136 of file sspiderio.cpp. References is_valid(). 00137 {
00138 return SingleSpiderIO::is_valid(first_block);
00139 }
|
|
||||||||||||||||||||||||
|
Write data to an image.
Implements EMAN::ImageIO. Definition at line 67 of file sspiderio.cpp. References data, and EMAN::SpiderIO::write_single_data(). 00069 {
00070 size_t offset = (int) first_h->headlen;
00071 return write_single_data(data, area, first_h, offset, 0, 1, use_host_endian);
00072 }
|
|
||||||||||||||||||||||||
|
Write a single SPIDER format header to an image.
Implements EMAN::ImageIO. Definition at line 55 of file sspiderio.cpp. References EMAN::SpiderIO::write_single_header(). 00057 {
00058 size_t offset = 0;
00059 int image_index = 0;
00060 // if(!use_host_endian) {
00061 // ByteOrder::swap_bytes((float*)first_h, NUM_FLOATS_IN_HEADER);
00062 // }
00063 return write_single_header(dict, area, image_index, offset, first_h, SINGLE_IMAGE_HEADER, 1, 1, use_host_endian);
00064 }
|
1.3.9.1