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

Amira file = ASCII header + binary data. More...

#include <amiraio.h>

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

Public Member Functions

 AmiraIO (const string &fname, IOMode rw_mode=READ_ONLY)
 
 ~AmiraIO ()
 
- 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 int get_nimg ()
 Return the number of images in this image file. 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)
 

Public Attributes

 DEFINE_IMAGEIO_FUNC
 

Private Attributes

bool is_big_endian
 
EMUtil::EMDataType dt
 
int nx
 
int ny
 
int nz
 
float pixel
 
float xorigin
 
float yorigin
 
float zorigin
 

Static Private Attributes

static const char * MAGIC = "# AmiraMesh"
 

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

Amira file = ASCII header + binary data.

Its first line has some magic name to label it as an Amira image. The first few lines of the file is the ASCII header. Followed the header is the data in binary format. The data has nx x ny x nz pixels.

An Amira file has only 1 2D or 3D image.

Definition at line 48 of file amiraio.h.

Constructor & Destructor Documentation

◆ AmiraIO()

AmiraIO::AmiraIO ( const string &  fname,
IOMode  rw_mode = READ_ONLY 
)

Definition at line 48 of file amiraio.cpp.

49: ImageIO(fname, rw),
51 nx(0), ny(0), nz(0),
52 pixel(0), xorigin(0), yorigin(0), zorigin(0)
53{
54}
float xorigin
Definition: amiraio.h:64
EMUtil::EMDataType dt
Definition: amiraio.h:59
float pixel
Definition: amiraio.h:63
float yorigin
Definition: amiraio.h:64
bool is_big_endian
Definition: amiraio.h:58
float zorigin
Definition: amiraio.h:64
@ EM_UNKNOWN
Definition: emutil.h:93
ImageIO(const string &fname, IOMode rw)
Definition: imageio.cpp:40

◆ ~AmiraIO()

AmiraIO::~AmiraIO ( )

Definition at line 56 of file amiraio.cpp.

57{
58 if (file) {
59 fclose(file);
60 file = 0;
61 }
62}
FILE * file
Definition: imageio.h:354

References EMAN::ImageIO::file.

Member Function Documentation

◆ is_valid()

bool AmiraIO::is_valid ( const void *  first_block)
static

Definition at line 100 of file amiraio.cpp.

101{
102 ENTERFUNC;
103 bool result = false;
104 if (!first_block) {
105 result = false;
106 }
107 else {
108 result = Util::check_file_by_magic(first_block, MAGIC);
109 }
110 EXITFUNC;
111 return result;
112}
static const char * MAGIC
Definition: amiraio.h:66
static bool check_file_by_magic(const void *first_block, const char *magic)
check whether a file starts with certain magic string.
Definition: util.cpp:239
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References EMAN::Util::check_file_by_magic(), ENTERFUNC, EXITFUNC, and MAGIC.

Referenced by EMAN::EMUtil::fast_get_image_type(), and EMAN::EMUtil::get_image_type().

Member Data Documentation

◆ DEFINE_IMAGEIO_FUNC

EMAN::AmiraIO::DEFINE_IMAGEIO_FUNC

Definition at line 54 of file amiraio.h.

◆ dt

EMUtil::EMDataType EMAN::AmiraIO::dt
private

Definition at line 59 of file amiraio.h.

◆ is_big_endian

bool EMAN::AmiraIO::is_big_endian
private

Definition at line 58 of file amiraio.h.

◆ MAGIC

const char * AmiraIO::MAGIC = "# AmiraMesh"
staticprivate

Definition at line 66 of file amiraio.h.

Referenced by is_valid().

◆ nx

int EMAN::AmiraIO::nx
private

Definition at line 60 of file amiraio.h.

◆ ny

int EMAN::AmiraIO::ny
private

Definition at line 61 of file amiraio.h.

◆ nz

int EMAN::AmiraIO::nz
private

Definition at line 62 of file amiraio.h.

◆ pixel

float EMAN::AmiraIO::pixel
private

Definition at line 63 of file amiraio.h.

◆ xorigin

float EMAN::AmiraIO::xorigin
private

Definition at line 64 of file amiraio.h.

◆ yorigin

float EMAN::AmiraIO::yorigin
private

Definition at line 64 of file amiraio.h.

◆ zorigin

float EMAN::AmiraIO::zorigin
private

Definition at line 64 of file amiraio.h.


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