EMAN2
|
MRC file = header + data (nx x ny x nz). More...
#include <mrcio.h>
Classes | |
struct | FeiMrcExtHeader |
The extended header used by Fei MRC image. More... | |
struct | FeiMrcHeader |
Extended MRC format for tomography As used by Fei; original definition of extended header by Dave Agard and Bram Koster Contact Dustin Morado Dusti for details. n.Mo rado@ uth. tmc.e duMore... | |
struct | MrcHeader |
Public Member Functions | |
MrcIO (const string &fname, IOMode rw_mode=READ_ONLY) | |
~MrcIO () | |
int | read_ctf (Ctf &ctf, int image_index=0) |
Read CTF data from this image. More... | |
void | write_ctf (const Ctf &ctf, int image_index=0) |
Write CTF data to this image. More... | |
int | get_nimg () |
Return the number of images in this image 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 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... | |
virtual bool | is_single_image_format () const |
Is this image format only storing 1 image 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, off_t file_size=0) |
static int | get_mode_size (int mm) |
static int | to_em_datatype (int mrcmode) |
static int | to_mrcmode (int em_datatype, int is_complex) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
MrcHeader | mrch |
FeiMrcHeader | feimrch |
Private Types | |
enum | MrcMode { MRC_UCHAR = 0 , MRC_SHORT = 1 , MRC_FLOAT = 2 , MRC_SHORT_COMPLEX =3 , MRC_FLOAT_COMPLEX =4 , MRC_USHORT = 6 , MRC_UCHAR3 = 16 , MRC_CHAR = 17 , MRC_UHEX = 101 , MRC_UNKNOWN = 18 } |
enum | { MRC_NUM_LABELS = 10 , MRC_LABEL_SIZE = 80 , NUM_4BYTES_PRE_MAP = 52 , NUM_4BYTES_AFTER_MAP = 3 } |
Private Member Functions | |
void | swap_header (MrcHeader &mrch) |
void | update_stats (void *data, size_t size) |
This is a utility function used to calculate new min/max/mean/sigma when write MRC file as 16 bit or 8 bit. More... | |
int | read_mrc_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false) |
int | read_fei_header (Dict &dict, int image_index=0, const Region *area=0, bool is_3d=false) |
int | transpose (float *data, int nx, int ny, int nz) const |
Static Private Member Functions | |
static int | generate_machine_stamp () |
generate the machine stamp used in MRC image format. More... | |
static void | check_swap (const int *data, const char *filnam, bool show_errors, bool &do_swap, bool &have_err) |
This is a utility routine to tell whether to byte swap MRC header. More... | |
Private Attributes | |
int | mode_size |
union { | |
MrcHeader mrch | |
FeiMrcHeader feimrch | |
}; | |
bool | isFEI |
bool | is_stack |
int | stack_size |
bool | is_8_bit_packed |
bool | use_given_dimensions |
int | is_ri |
bool | is_big_endian |
bool | is_new_file |
bool | is_transpose |
float | rendermin |
float | rendermax |
int | renderbits |
Static Private Attributes | |
static const char * | CTF_MAGIC = "!-" |
static const char * | SHORT_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 |
MRC file = header + data (nx x ny x nz).
A MRC image file stores 1D, 2D or 3D image. The image's dimensions and pixel type are defined in the header.
|
private |
|
private |
Definition at line 49 of file mrcio.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and mrch.
MrcIO::~MrcIO | ( | ) |
|
staticprivate |
This is a utility routine to tell whether to byte swap MRC header.
Definition at line 230 of file mrcio.cpp.
References generate_machine_stamp(), and EMAN::ByteOrder::swap_bytes().
Referenced by is_valid().
|
staticprivate |
generate the machine stamp used in MRC image format.
Definition at line 1713 of file mrcio.cpp.
References EMAN::ByteOrder::is_host_big_endian().
Referenced by check_swap().
|
static |
Definition at line 1595 of file mrcio.cpp.
References MRC_CHAR, MRC_FLOAT, MRC_FLOAT_COMPLEX, MRC_SHORT, MRC_SHORT_COMPLEX, MRC_UCHAR, and MRC_USHORT.
Referenced by is_valid().
|
virtual |
Return the number of images in this image file.
Reimplemented from EMAN::ImageIO.
Definition at line 1740 of file mrcio.cpp.
References EMAN::ImageIO::init(), and stack_size.
|
static |
Definition at line 342 of file mrcio.cpp.
References check_swap(), ENTERFUNC, EXITFUNC, get_mode_size(), LOGWARN, MRC_FLOAT_COMPLEX, MRC_SHORT_COMPLEX, MRC_UCHAR, MRC_UHEX, MRC_UNKNOWN, and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().
|
virtual |
Read CTF data from this image.
ctf | Used to store the CTF data. |
image_index | The index of the image to read. |
Reimplemented from EMAN::ImageIO.
Definition at line 1551 of file mrcio.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, EMAN::Ctf::from_string(), EMAN::ImageIO::init(), EMAN::MrcIO::MrcHeader::labels, and mrch.
Referenced by read_mrc_header().
|
private |
Definition at line 574 of file mrcio.cpp.
References EMAN::MrcIO::FeiMrcExtHeader::a_tilt, EMAN::MrcIO::FeiMrcHeader::alpha, EMAN::MrcIO::FeiMrcHeader::amax, EMAN::MrcIO::FeiMrcHeader::amean, EMAN::MrcIO::FeiMrcHeader::amin, EMAN::MrcIO::FeiMrcExtHeader::appliedDefocus, EMAN::MrcIO::FeiMrcExtHeader::b_tilt, EMAN::MrcIO::FeiMrcHeader::beta, EMAN::MrcIO::FeiMrcExtHeader::binning, EMAN::ImageIO::check_region(), EMAN::MrcIO::FeiMrcExtHeader::defocus, EMAN::MrcIO::FeiMrcHeader::dvid, ENTERFUNC, EXITFUNC, EMAN::MrcIO::FeiMrcExtHeader::exp_time, feimrch, EMAN::ImageIO::file, EMAN::ImageIO::filename, EMAN::MrcIO::FeiMrcHeader::gamma, EMAN::EMUtil::get_region_dims(), EMAN::MrcIO::FeiMrcExtHeader::ht, EMAN::MrcIO::FeiMrcHeader::idtype, ImageReadException, EMAN::ImageIO::init(), is_new_file, EMAN::MrcIO::FeiMrcHeader::ispg, EMAN::MrcIO::FeiMrcHeader::labl, EMAN::MrcIO::FeiMrcHeader::lens, EMAN::MrcIO::FeiMrcExtHeader::magnification, EMAN::MrcIO::FeiMrcHeader::mapc, EMAN::MrcIO::FeiMrcHeader::mapr, EMAN::MrcIO::FeiMrcHeader::maps, EMAN::MrcIO::FeiMrcHeader::max2, EMAN::MrcIO::FeiMrcHeader::max3, EMAN::MrcIO::FeiMrcHeader::max4, EMAN::MrcIO::FeiMrcExtHeader::mean_int, EMAN::MrcIO::FeiMrcHeader::min2, EMAN::MrcIO::FeiMrcHeader::min3, EMAN::MrcIO::FeiMrcHeader::min4, EMAN::MrcIO::FeiMrcHeader::mode, MRC_LABEL_SIZE, EMAN::MrcIO::FeiMrcHeader::mx, EMAN::MrcIO::FeiMrcHeader::my, EMAN::MrcIO::FeiMrcHeader::mz, EMAN::MrcIO::FeiMrcHeader::nd1, EMAN::MrcIO::FeiMrcHeader::nd2, EMAN::MrcIO::FeiMrcHeader::next, EMAN::MrcIO::FeiMrcHeader::nlabl, EMAN::MrcIO::FeiMrcHeader::nsymbt, EMAN::MrcIO::FeiMrcHeader::numfloats, EMAN::MrcIO::FeiMrcHeader::numintegers, EMAN::MrcIO::FeiMrcHeader::nx, EMAN::MrcIO::FeiMrcHeader::nxstart, EMAN::MrcIO::FeiMrcHeader::ny, EMAN::MrcIO::FeiMrcHeader::nystart, EMAN::MrcIO::FeiMrcHeader::nz, EMAN::MrcIO::FeiMrcHeader::nzstart, EMAN::MrcIO::FeiMrcExtHeader::pixel_size, portable_fseek(), EMAN::MrcIO::FeiMrcHeader::sub, EMAN::MrcIO::FeiMrcExtHeader::tilt_axis, EMAN::MrcIO::FeiMrcHeader::tiltangles, to_em_datatype(), EMAN::MrcIO::FeiMrcHeader::vd1, EMAN::MrcIO::FeiMrcHeader::vd2, EMAN::MrcIO::FeiMrcExtHeader::x_shift, EMAN::MrcIO::FeiMrcExtHeader::x_stage, EMAN::MrcIO::FeiMrcHeader::xlen, EMAN::MrcIO::FeiMrcHeader::xorg, EMAN::MrcIO::FeiMrcExtHeader::y_shift, EMAN::MrcIO::FeiMrcExtHeader::y_stage, EMAN::MrcIO::FeiMrcHeader::ylen, EMAN::MrcIO::FeiMrcHeader::yorg, EMAN::MrcIO::FeiMrcExtHeader::z_stage, EMAN::MrcIO::FeiMrcHeader::zfac, EMAN::MrcIO::FeiMrcHeader::zlen, and EMAN::MrcIO::FeiMrcHeader::zorg.
|
private |
Definition at line 428 of file mrcio.cpp.
References EMAN::MrcIO::MrcHeader::alpha, EMAN::MrcIO::MrcHeader::amax, EMAN::MrcIO::MrcHeader::amean, EMAN::MrcIO::MrcHeader::amin, EMAN::MrcIO::MrcHeader::beta, EMAN::ImageIO::check_region(), ENTERFUNC, EXITFUNC, EMAN::ImageIO::filename, EMAN::MrcIO::MrcHeader::gamma, EMAN::Region::get_ndim(), EMAN::EMUtil::get_region_dims(), ImageReadException, EMAN::ImageIO::is_complex_mode(), is_new_file, is_stack, is_transpose, EMAN::MrcIO::MrcHeader::ispg, EMAN::MrcIO::MrcHeader::labels, EMAN::MrcIO::MrcHeader::machinestamp, EMAN::MrcIO::MrcHeader::mapc, EMAN::MrcIO::MrcHeader::mapr, EMAN::MrcIO::MrcHeader::maps, EMAN::MrcIO::MrcHeader::mode, MRC_LABEL_SIZE, mrch, EMAN::MrcIO::MrcHeader::mx, EMAN::MrcIO::MrcHeader::my, EMAN::MrcIO::MrcHeader::mz, EMAN::MrcIO::MrcHeader::nlabels, EMAN::MrcIO::MrcHeader::nsymbt, EMAN::MrcIO::MrcHeader::nx, EMAN::MrcIO::MrcHeader::nxstart, EMAN::MrcIO::MrcHeader::ny, EMAN::MrcIO::MrcHeader::nystart, EMAN::MrcIO::MrcHeader::nz, EMAN::MrcIO::MrcHeader::nzstart, EMAN::Region::origin, read_ctf(), EMAN::MrcIO::MrcHeader::rms, to_em_datatype(), EMAN::EMAN1Ctf::to_vector(), EMAN::MrcIO::MrcHeader::xlen, EMAN::MrcIO::MrcHeader::xorigin, EMAN::MrcIO::MrcHeader::ylen, EMAN::MrcIO::MrcHeader::yorigin, EMAN::MrcIO::MrcHeader::zlen, and EMAN::MrcIO::MrcHeader::zorigin.
|
private |
Definition at line 1734 of file mrcio.cpp.
References EMAN::MrcIO::MrcHeader::machinestamp, mrch, NUM_4BYTES_AFTER_MAP, NUM_4BYTES_PRE_MAP, and EMAN::ByteOrder::swap_bytes().
|
static |
Definition at line 1621 of file mrcio.cpp.
References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_SHORT_COMPLEX, EMAN::EMUtil::EM_UCHAR, EMAN::EMUtil::EM_UNKNOWN, EMAN::EMUtil::EM_USHORT, MRC_CHAR, MRC_FLOAT, MRC_FLOAT_COMPLEX, MRC_SHORT, MRC_SHORT_COMPLEX, MRC_UCHAR, and MRC_USHORT.
Referenced by read_fei_header(), and read_mrc_header().
|
static |
Definition at line 1654 of file mrcio.cpp.
References EMAN::EMUtil::EM_CHAR, EMAN::EMUtil::EM_FLOAT, EMAN::EMUtil::EM_FLOAT_COMPLEX, EMAN::EMUtil::EM_INT, EMAN::EMUtil::EM_SHORT, EMAN::EMUtil::EM_SHORT_COMPLEX, EMAN::EMUtil::EM_UCHAR, EMAN::EMUtil::EM_UINT, EMAN::EMUtil::EM_USHORT, EMAN::EMUtil::EM_USHORT_COMPLEX, is_complex(), MRC_CHAR, MRC_FLOAT, MRC_FLOAT_COMPLEX, MRC_SHORT, MRC_SHORT_COMPLEX, MRC_UCHAR, MRC_UNKNOWN, and MRC_USHORT.
|
private |
|
private |
This is a utility function used to calculate new min/max/mean/sigma when write MRC file as 16 bit or 8 bit.
It will write new set of min/max/mean/sigma to mrch. this function needs get the output data storage type from mrch.mode.
Definition at line 1406 of file mrcio.cpp.
References EMAN::MrcIO::MrcHeader::amax, EMAN::MrcIO::MrcHeader::amean, EMAN::MrcIO::MrcHeader::amin, EMAN::ImageIO::file, EMAN::ImageIO::filename, ImageWriteException, InvalidCallException, EMAN::MrcIO::MrcHeader::mode, MRC_CHAR, MRC_SHORT, MRC_SHORT_COMPLEX, MRC_UCHAR, MRC_USHORT, mrch, portable_fseek(), EMAN::MrcIO::MrcHeader::rms, and sqrt().
|
virtual |
Write CTF data to this image.
ctf | Ctf instance storing the CTF data. |
image_index | The index of the image to write. |
Reimplemented from EMAN::ImageIO.
Definition at line 1569 of file mrcio.cpp.
References CTF_MAGIC, ENTERFUNC, EXITFUNC, EMAN::ImageIO::file, EMAN::ImageIO::filename, ImageWriteException, EMAN::ImageIO::init(), EMAN::MrcIO::MrcHeader::labels, MRC_LABEL_SIZE, mrch, and EMAN::Ctf::to_string().
union { ... } EMAN::MrcIO::@9 |
|
staticprivate |
Definition at line 260 of file mrcio.h.
Referenced by read_ctf(), and write_ctf().
FeiMrcHeader EMAN::MrcIO::feimrch |
Definition at line 268 of file mrcio.h.
Referenced by read_fei_header().
|
private |
|
private |
Definition at line 284 of file mrcio.h.
Referenced by read_fei_header(), and read_mrc_header().
|
private |
Definition at line 275 of file mrcio.h.
Referenced by read_mrc_header().
|
private |
Definition at line 285 of file mrcio.h.
Referenced by read_mrc_header().
MrcHeader EMAN::MrcIO::mrch |
Definition at line 267 of file mrcio.h.
Referenced by MrcIO(), read_ctf(), read_mrc_header(), swap_header(), update_stats(), and write_ctf().
|
private |
Definition at line 276 of file mrcio.h.
Referenced by get_nimg().