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

situs is a a Situs-specific format on a cubic lattice. More...

#include <situsio.h>

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

Public Member Functions

 SitusIO (const string &fname, IOMode rw_mode=READ_ONLY)
 
 ~SitusIO ()
 
- 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_new_file
 
float apix
 
float origx
 
float origy
 
float origz
 
int nx
 
int ny
 
int nz
 

Static Private Attributes

static const int SITUS_HEADER_LINES =2
 
static const int FLOAT_SIZE = 12
 
static const int NFLOAT_PER_LINE = 10
 
static const char * OUTFORMAT = "%12.6f"
 
static const int LINE_LENGTH = 1024
 

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

situs is a a Situs-specific format on a cubic lattice.

This allows Situs programs to keep track of coordinate systems and it makes the core Situs programs independent of the ever changing map format standards. In the editable (ASCII or text) Situs format, a short header holds the voxel spacing WIDTH, the map origin as defined by the 3D coordinates of the first voxel ORIGX, ORIGY, ORIGZ, and the map dimensions (number of increments) NX, NY, NZ. This minimalist header is followed by the data fields such that x increments change fastest and z increments change slowest. http://situs.biomachina.org/fguide.html#map2map

Definition at line 48 of file situsio.h.

Constructor & Destructor Documentation

◆ SitusIO()

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

Definition at line 44 of file situsio.cpp.

44 :
45 ImageIO(fname, rw),
46 is_new_file(false),
47 apix(0.0f), origx(0.0f), origy(0.0f), origz(0.0f),
48 nx(0), ny(0), nz(0)
49{
50}
ImageIO(const string &fname, IOMode rw)
Definition: imageio.cpp:40
float origx
Definition: situsio.h:61
float origy
Definition: situsio.h:61
float apix
Definition: situsio.h:61
bool is_new_file
Definition: situsio.h:59
float origz
Definition: situsio.h:61

◆ ~SitusIO()

SitusIO::~SitusIO ( )

Definition at line 52 of file situsio.cpp.

53{
54 if (file) {
55 fclose(file);
56 file = 0;
57 }
58}
FILE * file
Definition: imageio.h:354

References EMAN::ImageIO::file.

Member Function Documentation

◆ is_valid()

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

Definition at line 182 of file situsio.cpp.

183{
184 ENTERFUNC;
185 if (!first_block) {
186 return false;
187 }
188
189 char *buf = (char *)(first_block);
190 string line1 = Util::get_line_from_string(&buf);
191
192 if(line1.size()==0) return false;
193
194 float apix, origx, origy, origz;
195 int nx, ny, nz, missing;
196
197 // We're looking for exactly 7
198 if(sscanf(line1.c_str(), "%f %f %f %f %d %d %d %d", &apix, &origx, &origy, &origz, &nx, &ny, &nz,&missing) != 7) return false;
199
200 if(apix<0.01 || apix>100) return false;
201 if(nx<=0 || ny<0 || nz<0) return false;
202
203 EXITFUNC;
204 return true;
205}
static string get_line_from_string(char **str)
Extract a single line from a multi-line string.
Definition: util.cpp:322
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References apix, ENTERFUNC, EXITFUNC, EMAN::Util::get_line_from_string(), nx, ny, nz, origx, origy, and origz.

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

Member Data Documentation

◆ apix

float EMAN::SitusIO::apix
private

Definition at line 61 of file situsio.h.

Referenced by is_valid().

◆ DEFINE_IMAGEIO_FUNC

EMAN::SitusIO::DEFINE_IMAGEIO_FUNC

Definition at line 54 of file situsio.h.

◆ FLOAT_SIZE

const int SitusIO::FLOAT_SIZE = 12
staticprivate

Definition at line 65 of file situsio.h.

◆ is_new_file

bool EMAN::SitusIO::is_new_file
private

Definition at line 59 of file situsio.h.

◆ LINE_LENGTH

const int SitusIO::LINE_LENGTH = 1024
staticprivate

Definition at line 68 of file situsio.h.

◆ NFLOAT_PER_LINE

const int SitusIO::NFLOAT_PER_LINE = 10
staticprivate

Definition at line 66 of file situsio.h.

◆ nx

int EMAN::SitusIO::nx
private

Definition at line 62 of file situsio.h.

Referenced by is_valid().

◆ ny

int EMAN::SitusIO::ny
private

Definition at line 62 of file situsio.h.

Referenced by is_valid().

◆ nz

int EMAN::SitusIO::nz
private

Definition at line 62 of file situsio.h.

Referenced by is_valid().

◆ origx

float EMAN::SitusIO::origx
private

Definition at line 61 of file situsio.h.

Referenced by is_valid().

◆ origy

float EMAN::SitusIO::origy
private

Definition at line 61 of file situsio.h.

Referenced by is_valid().

◆ origz

float EMAN::SitusIO::origz
private

Definition at line 61 of file situsio.h.

Referenced by is_valid().

◆ OUTFORMAT

const char * SitusIO::OUTFORMAT = "%12.6f"
staticprivate

Definition at line 67 of file situsio.h.

◆ SITUS_HEADER_LINES

const int SitusIO::SITUS_HEADER_LINES =2
staticprivate

Definition at line 64 of file situsio.h.


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