EMAN2
Public Member Functions | Public Attributes | Private Attributes | List of all members
EMAN::EerIO Class Reference

#include <eerio.h>

Inheritance diagram for EMAN::EerIO:
Inheritance graph
[legend]
Collaboration diagram for EMAN::EerIO:
Collaboration graph
[legend]

Public Member Functions

 EerIO (const string &fname, IOMode rw_mode=READ_ONLY, Decoder &dec=decoder0x)
 
 ~EerIO ()
 
int get_nimg ()
 Return the number of images in this image file. More...
 
bool is_single_image_format () const override
 Is this image format only storing 1 image or not. 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
 

Public Attributes

 DEFINE_IMAGEIO_FUNC
 

Private Attributes

bool is_big_endian
 
TIFF * tiff_file
 
size_t num_frames = 0
 
Dict acquisition_data_dict
 
Decoderdecoder
 

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
 

Detailed Description

Definition at line 180 of file eerio.h.

Constructor & Destructor Documentation

◆ EerIO()

EerIO::EerIO ( const string &  fname,
IOMode  rw_mode = READ_ONLY,
Decoder dec = decoder0x 
)

Definition at line 150 of file eerio.cpp.

151: ImageIO(fname, rw), decoder(dec)
152{
153 TIFFSetWarningHandler(TIFFOutputWarning);
154
155 tiff_file = TIFFOpen(filename.c_str(), "r");
156
157 auto acquisition_metadata = read_acquisition_metadata(tiff_file);
158 acquisition_data_dict = parse_acquisition_data(acquisition_metadata);
159
160 for( ; TIFFReadDirectory(tiff_file); )
161 num_frames = TIFFCurrentDirectory(tiff_file) + 1;
162
163}
Decoder & decoder
Definition: eerio.h:198
size_t num_frames
Definition: eerio.h:195
TIFF * tiff_file
Definition: eerio.h:194
Dict acquisition_data_dict
Definition: eerio.h:196
string filename
Definition: imageio.h:352
ImageIO(const string &fname, IOMode rw)
Definition: imageio.cpp:40
Dict parse_acquisition_data(string metadata)
Definition: eerio.cpp:104
void TIFFOutputWarning(const char *module, const char *fmt, va_list ap)
Definition: eerio.cpp:69
string read_acquisition_metadata(TIFF *tiff)
Definition: eerio.cpp:78

References acquisition_data_dict, EMAN::ImageIO::filename, num_frames, parse_acquisition_data(), read_acquisition_metadata(), tiff_file, and TIFFOutputWarning().

◆ ~EerIO()

EerIO::~EerIO ( )

Definition at line 165 of file eerio.cpp.

166{
167 TIFFClose(tiff_file);
168}

References tiff_file.

Member Function Documentation

◆ get_nimg()

int EerIO::get_nimg ( )
virtual

Return the number of images in this image file.

Reimplemented from EMAN::ImageIO.

Definition at line 177 of file eerio.cpp.

178{
179 return num_frames;
180}

References num_frames.

◆ is_single_image_format()

bool EerIO::is_single_image_format ( ) const
overridevirtual

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::ImageIO.

Definition at line 257 of file eerio.cpp.

258{
259 return false;
260}

Member Data Documentation

◆ acquisition_data_dict

Dict EMAN::EerIO::acquisition_data_dict
private

Definition at line 196 of file eerio.h.

Referenced by EerIO().

◆ decoder

Decoder& EMAN::EerIO::decoder
private

Definition at line 198 of file eerio.h.

◆ DEFINE_IMAGEIO_FUNC

EMAN::EerIO::DEFINE_IMAGEIO_FUNC

Definition at line 190 of file eerio.h.

◆ is_big_endian

bool EMAN::EerIO::is_big_endian
private

Definition at line 193 of file eerio.h.

◆ num_frames

size_t EMAN::EerIO::num_frames = 0
private

Definition at line 195 of file eerio.h.

Referenced by EerIO(), and get_nimg().

◆ tiff_file

TIFF* EMAN::EerIO::tiff_file
private

Definition at line 194 of file eerio.h.

Referenced by EerIO(), and ~EerIO().


The documentation for this class was generated from the following files: