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

MRC file = header + data (nx x ny x nz). More...

#include <fitsio.h>

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

Public Member Functions

 FitsIO (const string &fname, IOMode rw_mode=READ_ONLY)
 
 ~FitsIO ()
 
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...
 
- 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 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, 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
 

Private Attributes

bool is_big_endian
 
bool is_new_file
 
int dstart
 
int dtype
 
int nx
 
int ny
 
int nz
 

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

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.

Definition at line 44 of file fitsio.h.

Constructor & Destructor Documentation

◆ FitsIO()

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

Definition at line 41 of file fitsio.cpp.

42: ImageIO(fname, rw)
43{
45 is_new_file = false;
46}
static bool is_host_big_endian()
Definition: byteorder.cpp:40
bool is_big_endian
Definition: fitsio.h:61
bool is_new_file
Definition: fitsio.h:62
ImageIO(const string &fname, IOMode rw)
Definition: imageio.cpp:40

References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and is_new_file.

◆ ~FitsIO()

FitsIO::~FitsIO ( )

Definition at line 48 of file fitsio.cpp.

49{
50 if (file) {
51 fclose(file);
52 file = 0;
53 }
54}
FILE * file
Definition: imageio.h:354

References EMAN::ImageIO::file.

Member Function Documentation

◆ get_mode_size()

static int EMAN::FitsIO::get_mode_size ( int  mm)
static

◆ is_valid()

bool FitsIO::is_valid ( const void *  first_block,
off_t  file_size = 0 
)
static

Definition at line 77 of file fitsio.cpp.

78{
80
81 if (!first_block) {
82 return false;
83 }
84
85 if (strncmp("SIMPLE ",(const char *)first_block,8)==0) return true;
86
88 return false;
89}
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References ENTERFUNC, and EXITFUNC.

Referenced by EMAN::EMUtil::get_image_type().

◆ read_ctf()

int FitsIO::read_ctf ( Ctf ctf,
int  image_index = 0 
)
virtual

Read CTF data from this image.

Parameters
ctfUsed to store the CTF data.
image_indexThe index of the image to read.
Returns
0 if OK; 1 if error.

Reimplemented from EMAN::ImageIO.

Definition at line 233 of file fitsio.cpp.

234{
235 ENTERFUNC;
236 init();
237 EXITFUNC;
238 return 0;
239}
virtual void init()=0
Do some initialization before doing the read/write.

References ENTERFUNC, EXITFUNC, and EMAN::ImageIO::init().

◆ to_em_datatype()

static int EMAN::FitsIO::to_em_datatype ( int  mrcmode)
static

◆ to_mrcmode()

static int EMAN::FitsIO::to_mrcmode ( int  em_datatype,
int  is_complex 
)
static

◆ write_ctf()

void FitsIO::write_ctf ( const Ctf ctf,
int  image_index = 0 
)
virtual

Write CTF data to this image.

Parameters
ctfCtf instance storing the CTF data.
image_indexThe index of the image to write.
Returns
0 if OK; 1 if error.

Reimplemented from EMAN::ImageIO.

Definition at line 241 of file fitsio.cpp.

242{
243 ENTERFUNC;
244 init();
245
246 EXITFUNC;
247}

References ENTERFUNC, EXITFUNC, and EMAN::ImageIO::init().

Member Data Documentation

◆ DEFINE_IMAGEIO_FUNC

EMAN::FitsIO::DEFINE_IMAGEIO_FUNC

Definition at line 50 of file fitsio.h.

◆ dstart

int EMAN::FitsIO::dstart
private

Definition at line 63 of file fitsio.h.

◆ dtype

int EMAN::FitsIO::dtype
private

Definition at line 64 of file fitsio.h.

◆ is_big_endian

bool EMAN::FitsIO::is_big_endian
private

Definition at line 61 of file fitsio.h.

Referenced by FitsIO().

◆ is_new_file

bool EMAN::FitsIO::is_new_file
private

Definition at line 62 of file fitsio.h.

Referenced by FitsIO().

◆ nx

int EMAN::FitsIO::nx
private

Definition at line 65 of file fitsio.h.

◆ ny

int EMAN::FitsIO::ny
private

Definition at line 65 of file fitsio.h.

◆ nz

int EMAN::FitsIO::nz
private

Definition at line 65 of file fitsio.h.


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