EMAN2
|
IMAGIC-5 Header File Format. More...
#include <imagicio2.h>
Classes | |
struct | Imagic4D |
IMAGIC-4D file format http://www.imagescience.de/formats/formats.htm. More... | |
Public Member Functions | |
ImagicIO2 (const string &fname, IOMode rw_mode=READ_ONLY) | |
~ImagicIO2 () | |
int | init_test () |
bool | is_single_image_format () const |
If this file format is only for single iamge. More... | |
int | get_nimg () |
Get number of images in this file. More... | |
Public Member Functions inherited from EMAN::ImageIO | |
ImageIO (const string &fname, IOMode rw) | |
virtual | ~ImageIO () |
virtual int | read_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false)=0 |
Read the header from an image. More... | |
virtual 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)=0 |
Write a header to an image. More... | |
virtual int | read_data (float *data, int image_index=0, const Region *area=0, bool is_3d=false)=0 |
Read the data from an image. More... | |
virtual int | read_data_8bit (unsigned char *data, int image_index=0, const Region *area=0, bool is_3d=false, float minval=0.0f, float maxval=0.0f) |
Read the data from an image as an 8 bit array, regardless of format. More... | |
virtual int | write_data (float *data, int image_index=0, const Region *area=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)=0 |
Write data to an image. More... | |
virtual int | read_ctf (Ctf &ctf, int image_index=0) |
Read CTF data from this image. More... | |
virtual void | write_ctf (const Ctf &ctf, int image_index=0) |
Write CTF data to this image. More... | |
virtual void | flush ()=0 |
Flush the IO buffer. More... | |
virtual bool | is_complex_mode ()=0 |
Is this an complex image or not. More... | |
virtual bool | is_image_big_endian ()=0 |
Is this image in big endian or not. More... | |
template<class T > | |
void | become_host_endian (T *data, size_t n=1) |
Convert data of this image into host endian format. More... | |
string | get_filename () const |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Static Public Attributes | |
static const char * | HED_EXT = "hed" |
static const char * | IMG_EXT = "img" |
Private Types | |
enum | DataType { IMAGIC_CHAR , IMAGIC_SHORT , IMAGIC_FLOAT , IMAGIC_FLOAT_COMPLEX , IMAGIC_FFT_FLOAT_COMPLEX , IMAGIC_UNKNOWN_TYPE } |
enum | { NUM_4BYTES_PRE_IYLP = 14 , NUM_4BYTES_AFTER_IXOLD = 14 , NUM_4BYTES_AFTER_NAME = 150 } |
enum | RealType { VAX_VMS = 16777216 , LINUX_WINDOWS = 33686018 , SGI_IBM = 67372036 } |
Private Member Functions | |
size_t | get_datatype_size (DataType t) const |
int | to_em_datatype (DataType t) const |
void | make_header_host_endian (Imagic4D &hed) const |
void | swap_header (Imagic4D &hed) const |
DataType | get_datatype_from_name (const char *name) const |
Ctf * | read_ctf (const Imagic4D &hed) const |
the Ctf object is a EMAN1Ctf object. More... | |
void | write_ctf (const Ctf *const ctf, int image_index=0) |
int | generate_machine_stamp () const |
Private Attributes | |
string | hed_filename |
string | img_filename |
FILE * | hed_file |
FILE * | img_file |
Imagic4D | imagich |
bool | is_big_endian |
bool | is_new_hed |
bool | is_new_img |
DataType | datatype |
int | nz |
Static Private Attributes | |
static const char * | REAL_TYPE_MAGIC = "REAL" |
static const char * | CTF_MAGIC = "!-" |
Additional Inherited Members | |
Public Types inherited from EMAN::ImageIO | |
enum | IOMode { READ_ONLY = 1 , READ_WRITE = 2 , WRITE_ONLY = 3 } |
Protected Member Functions inherited from EMAN::ImageIO | |
virtual void | init ()=0 |
Do some initialization before doing the read/write. More... | |
void | check_read_access (int image_index) |
Validate 'image_index' in file reading. More... | |
void | check_read_access (int image_index, const float *data) |
Validate 'image_index' and 'data' in file reading. More... | |
void | check_write_access (IOMode rw_mode, int image_index, int max_nimg=0) |
Validate rw_mode and image_index in file writing. More... | |
void | check_write_access (IOMode rw_mode, int image_index, int max_nimg, const float *data) |
Validate rw_mode, image_index, and data pointer in file writing. More... | |
void | check_region (const Region *area, const FloatSize &max_size, bool is_new_file=false, bool inbounds_only=true) |
Validate image I/O region. More... | |
void | check_region (const Region *area, const IntSize &max_size, bool is_new_file=false, bool inbounds_only=true) |
Validate image I/O region. More... | |
FILE * | sfopen (const string &filename, IOMode mode, bool *is_new=0, bool overwrite=false) |
Run fopen safely. More... | |
Protected Attributes inherited from EMAN::ImageIO | |
string | filename |
IOMode | rw_mode |
FILE * | file = nullptr |
bool | initialized = false |
IMAGIC-5 Header File Format.
Renewed 4D version: http://www.imagescience.de/formats/formats.htm
An IMAGIC-5 file has 2 files: a) a header file with extension ".hed". It contains information for every image. b) an image file with extension ".img". It contains raw data.
The header file contains one (fixed-size) record per image stored. Every header record consists of 256 REAL/float for every image.
The image file contains only the raw data. Depending on the internal IMAGIC-5 format used, which can be REAL, INTG, PACK or COMP, the data is stored as REAL/float, INTEGER/int, INTEGER*1/byte or 2x REAL/float, respectively. The first pixel stored is the upper left one. The data is stored line by line, section by section, volume by volume.
3D imagic uses the same format to 2D. it is a bunch of 2D slices. use the 'hint' IS_3D to treat "2D slices" as 3D volume.
This renewed version support storing multiple 3D images in one file (header/data pair).
EMAN2 will read both old and new Imagic header, but write to new format from - Grant Tang.
Definition at line 69 of file imagicio2.h.
|
private |
Enumerator | |
---|---|
NUM_4BYTES_PRE_IYLP | |
NUM_4BYTES_AFTER_IXOLD | |
NUM_4BYTES_AFTER_NAME |
Definition at line 115 of file imagicio2.h.
|
private |
Enumerator | |
---|---|
IMAGIC_CHAR | |
IMAGIC_SHORT | |
IMAGIC_FLOAT | |
IMAGIC_FLOAT_COMPLEX | |
IMAGIC_FFT_FLOAT_COMPLEX | |
IMAGIC_UNKNOWN_TYPE |
Definition at line 104 of file imagicio2.h.
|
private |
Definition at line 51 of file imagicio2.cpp.
References EMAN::Util::change_filename_ext(), EMAN::ImagicIO2::Imagic4D::count, datatype, EMAN::ImageIO::filename, HED_EXT, hed_filename, IMAGIC_UNKNOWN_TYPE, imagich, IMG_EXT, img_filename, is_big_endian, EMAN::ByteOrder::is_host_big_endian(), is_new_hed, is_new_img, and nz.
ImagicIO2::~ImagicIO2 | ( | ) |
|
private |
|
private |
Definition at line 375 of file imagicio2.cpp.
References IMAGIC_CHAR, IMAGIC_FFT_FLOAT_COMPLEX, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, IMAGIC_SHORT, IMAGIC_UNKNOWN_TYPE, and REAL_TYPE_MAGIC.
|
private |
Definition at line 751 of file imagicio2.cpp.
References IMAGIC_CHAR, IMAGIC_FFT_FLOAT_COMPLEX, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, and IMAGIC_SHORT.
|
virtual |
Get number of images in this file.
Reimplemented from EMAN::ImageIO.
Definition at line 739 of file imagicio2.cpp.
References EMAN::ImagicIO2::Imagic4D::count, imagich, and EMAN::ImageIO::init().
int ImagicIO2::init_test | ( | ) |
Definition at line 123 of file imagicio2.cpp.
References ENTERFUNC, EXITFUNC, FileAccessException, EMAN::ImageIO::filename, hed_filename, EMAN::ImageIO::initialized, and LOGERR.
|
inlinevirtual |
If this file format is only for single iamge.
Reimplemented from EMAN::ImageIO.
Definition at line 89 of file imagicio2.h.
|
static |
Definition at line 161 of file imagicio2.cpp.
References ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), LINUX_WINDOWS, nz, SGI_IBM, EMAN::ByteOrder::swap_bytes(), and VAX_VMS.
|
private |
Definition at line 651 of file imagicio2.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and swap_header().
the Ctf object is a EMAN1Ctf object.
Definition at line 416 of file imagicio2.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, EMAN::Ctf::from_string(), imagich, and EMAN::ImagicIO2::Imagic4D::label.
|
private |
Definition at line 658 of file imagicio2.cpp.
References EMAN::ImagicIO2::Imagic4D::ccc3d, EMAN::ImagicIO2::Imagic4D::ixold, NUM_4BYTES_AFTER_IXOLD, NUM_4BYTES_AFTER_NAME, NUM_4BYTES_PRE_IYLP, and EMAN::ByteOrder::swap_bytes().
Referenced by make_header_host_endian().
|
private |
Definition at line 397 of file imagicio2.cpp.
References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_UNKNOWN, IMAGIC_CHAR, IMAGIC_FFT_FLOAT_COMPLEX, IMAGIC_FLOAT, IMAGIC_FLOAT_COMPLEX, and IMAGIC_SHORT.
|
private |
Definition at line 438 of file imagicio2.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, hed_file, hed_filename, ImageWriteException, imagich, EMAN::ImageIO::init(), EMAN::ImagicIO2::Imagic4D::label, and EMAN::Ctf::to_string().
|
staticprivate |
Definition at line 101 of file imagicio2.h.
Referenced by read_ctf(), and write_ctf().
|
private |
Definition at line 259 of file imagicio2.h.
Referenced by ImagicIO2().
EMAN::ImagicIO2::DEFINE_IMAGEIO_FUNC |
Definition at line 78 of file imagicio2.h.
|
static |
Definition at line 72 of file imagicio2.h.
Referenced by ImagicIO2().
|
private |
Definition at line 251 of file imagicio2.h.
Referenced by write_ctf(), and ~ImagicIO2().
|
private |
Definition at line 248 of file imagicio2.h.
Referenced by ImagicIO2(), init_test(), and write_ctf().
|
private |
Definition at line 254 of file imagicio2.h.
Referenced by get_nimg(), ImagicIO2(), read_ctf(), and write_ctf().
|
static |
Definition at line 73 of file imagicio2.h.
Referenced by ImagicIO2().
|
private |
Definition at line 252 of file imagicio2.h.
Referenced by ~ImagicIO2().
|
private |
Definition at line 249 of file imagicio2.h.
Referenced by ImagicIO2().
|
private |
Definition at line 255 of file imagicio2.h.
Referenced by ImagicIO2(), and make_header_host_endian().
|
private |
Definition at line 256 of file imagicio2.h.
Referenced by ImagicIO2().
|
private |
Definition at line 257 of file imagicio2.h.
Referenced by ImagicIO2().
|
private |
Definition at line 260 of file imagicio2.h.
Referenced by ImagicIO2(), and is_valid().
|
staticprivate |
Definition at line 100 of file imagicio2.h.
Referenced by get_datatype_from_name().