EMAN2
|
SPIDER: (System for Processing Image Data from Electron microscopy and Related fields) is an image processing system for electron microscopy. More...
#include <spiderio.h>
Classes | |
struct | SpiderHeader |
Public Member Functions | |
SpiderIO (const string &fname, IOMode rw_mode=READ_ONLY) | |
~SpiderIO () | |
bool | is_single_image_format () const |
Is this image format only storing 1 image or not. More... | |
int | get_nimg () |
get the number of images in this stacked SPIDER 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 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 |
Static Public Member Functions | |
static bool | is_valid (const void *first_block) |
Public Attributes | |
DEFINE_IMAGEIO_FUNC | |
Protected Types | |
enum | SpiderType { IMAGE_2D = 1 , IMAGE_3D = 3 , IMAGE_2D_FFT_ODD = -11 , IMAGE_2D_FFT_EVEN = -12 , IMAGE_3D_FFT_ODD = -21 , IMAGE_3D_FFT_EVEN = -22 } |
enum | { SINGLE_IMAGE_HEADER = 0 , OVERALL_STACK_HEADER = 2 , NUM_FLOATS_IN_HEADER = 211 } |
Protected Member Functions | |
int | write_single_header (const Dict &dict, const Region *area, int image_index, size_t offset, SpiderHeader *&hp, int ISTACK, int MAXIM=1, int IMGNUM=1, bool use_host_endian=true) |
write a SPIDER header to spider_file More... | |
int | write_single_data (float *data, const Region *area, SpiderHeader *&hp, size_t offset, int img_index, int max_nimg, bool use_host_endian=true) |
write a single image data More... | |
virtual bool | is_valid_spider (const void *first_block) |
check the data block to see if it represents valid stacked SPIDER image file header More... | |
bool | need_swap () const |
void | swap_data (float *data, size_t nitems) |
void | swap_header (SpiderHeader *header) |
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 | |
SpiderHeader * | first_h |
SpiderHeader * | cur_h |
bool | is_big_endian |
bool | is_new_file |
Protected Attributes inherited from EMAN::ImageIO | |
string | filename |
IOMode | rw_mode |
FILE * | file = nullptr |
bool | initialized = false |
Additional Inherited Members | |
Public Types inherited from EMAN::ImageIO | |
enum | IOMode { READ_ONLY = 1 , READ_WRITE = 2 , WRITE_ONLY = 3 } |
SPIDER: (System for Processing Image Data from Electron microscopy and Related fields) is an image processing system for electron microscopy.
SpiderIO reads/writes images used in spider format. (reference: http://www.wadsworth.org/spider_doc/spider/docs/index.html)
A single image = header + data.
header-length = ( ceiling(1024/(nx*4)) * (nx*4) ) where nx is the number of pixels per row. The data is (nx * ny * nslice) of floating numbers, where ny is number of rows per slice. nslice is number of slices.
There are 2 spider image formats:
image stack. There is one overall stack header followed by a stack of images in which each image has its own image header. EMAN currently only supports homogeneous image stack, which means all images have the same sizes.
if there is only 1 image in the file, it can be overwritten by a different-size image.
Record: In spider terminology, each row is called a record.
Note: To read the overall image header in a stacked spider file, use image_index = -1.
Definition at line 71 of file spiderio.h.
|
protected |
Enumerator | |
---|---|
SINGLE_IMAGE_HEADER | |
OVERALL_STACK_HEADER | |
NUM_FLOATS_IN_HEADER |
Definition at line 191 of file spiderio.h.
|
protected |
Enumerator | |
---|---|
IMAGE_2D | |
IMAGE_3D | |
IMAGE_2D_FFT_ODD | |
IMAGE_2D_FFT_EVEN | |
IMAGE_3D_FFT_ODD | |
IMAGE_3D_FFT_EVEN |
Definition at line 181 of file spiderio.h.
Definition at line 44 of file spiderio.cpp.
References EMAN::ImageIO::filename, EMAN::Util::is_file_exist(), and is_new_file.
SpiderIO::~SpiderIO | ( | ) |
|
virtual |
get the number of images in this stacked SPIDER image
Reimplemented from EMAN::ImageIO.
Definition at line 678 of file spiderio.cpp.
References Assert, first_h, ImageFormatException, EMAN::ImageIO::init(), is_new_file, EMAN::SpiderIO::SpiderHeader::istack, EMAN::SpiderIO::SpiderHeader::maxim, and SINGLE_IMAGE_HEADER.
|
inlinevirtual |
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.
Reimplemented in EMAN::SingleSpiderIO.
Definition at line 80 of file spiderio.h.
|
static |
Definition at line 111 of file spiderio.cpp.
References ENTERFUNC, EXITFUNC, EMAN::ByteOrder::is_float_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().
Referenced by EMAN::EMUtil::fast_get_image_type(), EMAN::EMUtil::get_image_type(), and is_valid_spider().
|
protectedvirtual |
check the data block to see if it represents valid stacked SPIDER image file header
first_block | the pointer to first block of the file |
Reimplemented in EMAN::SingleSpiderIO.
Definition at line 106 of file spiderio.cpp.
References is_valid().
|
protected |
Definition at line 696 of file spiderio.cpp.
References is_big_endian, EMAN::ByteOrder::is_host_big_endian(), and is_new_file.
Referenced by swap_data(), and swap_header().
|
protected |
Definition at line 647 of file spiderio.cpp.
References need_swap(), and EMAN::ByteOrder::swap_bytes().
|
protected |
Definition at line 654 of file spiderio.cpp.
References need_swap(), NUM_FLOATS_IN_HEADER, and EMAN::ByteOrder::swap_bytes().
|
protected |
write a single image data
data | the data block to be written |
area | the data region we want to write |
hp | the SpiderHeader pointer all header info will write to |
offset | the offset in the spider_file |
img_index | the image index inthe stack, it's 0-indexed |
max_nimg | max image number in a stack |
use_host_endian | use host machine's endian, set to false will swap the byte order |
ImageWriteException |
Definition at line 616 of file spiderio.cpp.
References EMAN::ImageIO::check_region(), EMAN::ImageIO::check_write_access(), ENTERFUNC, EXITFUNC, EMAN::ImageIO::file, EMAN::ImageIO::filename, ImageWriteException, is_new_file, EMAN::SpiderIO::SpiderHeader::nrow, EMAN::SpiderIO::SpiderHeader::nsam, EMAN::SpiderIO::SpiderHeader::nslice, portable_fseek(), EMAN::EMUtil::process_region_io(), EMAN::ImageIO::rw_mode, EMAN::ByteOrder::swap_bytes(), and EMAN::ImageIO::WRITE_ONLY.
Referenced by EMAN::SingleSpiderIO::write_data().
|
protected |
write a SPIDER header to spider_file
dict | the dictionary contain header information |
area | the region we want to write |
image_index | the image index inthe stack, it's 0-indexed |
offset | the offset in the spider_file |
hp | the SpiderHeader pointer all header info will write to, then the content of hp will write to spider file |
ISTACK | the istack field for SPIDER's header, 0 for dingle image, 2 for stacked image |
MAXIM | maxim field for header, only used for overall header |
IMGNUM | imgnum for header, only used for stacked image header |
use_host_endian | use host machine's endian, set to false will swap the byte order |
ImageWriteException |
Definition at line 400 of file spiderio.cpp.
References EMAN::SpiderIO::SpiderHeader::angvalid, EMAN::ImageIO::check_region(), EMAN::ImageIO::check_write_access(), copy(), EMAN::SpiderIO::SpiderHeader::date, EMAN::SpiderIO::SpiderHeader::dx, EMAN::SpiderIO::SpiderHeader::dy, EMAN::SpiderIO::SpiderHeader::dz, ENTERFUNC, EXITFUNC, EMAN::ImageIO::file, EMAN::ImageIO::filename, EMAN::SpiderIO::SpiderHeader::gamma, EMAN::Transform::get_params(), EMAN::Dict::has_key(), EMAN::SpiderIO::SpiderHeader::headlen, EMAN::SpiderIO::SpiderHeader::headrec, IMAGE_2D, IMAGE_3D, ImageWriteException, EMAN::SpiderIO::SpiderHeader::imgnum, EMAN::SpiderIO::SpiderHeader::irec, is_new_file, EMAN::SpiderIO::SpiderHeader::istack, EMAN::SpiderIO::SpiderHeader::max, EMAN::SpiderIO::SpiderHeader::maxim, EMAN::SpiderIO::SpiderHeader::mean, EMAN::SpiderIO::SpiderHeader::min, EMAN::SpiderIO::SpiderHeader::mmvalid, EMAN::SpiderIO::SpiderHeader::nrow, EMAN::SpiderIO::SpiderHeader::nsam, EMAN::SpiderIO::SpiderHeader::nslice, NUM_FLOATS_IN_HEADER, OVERALL_STACK_HEADER, EMAN::SpiderIO::SpiderHeader::phi, portable_fseek(), EMAN::SpiderIO::SpiderHeader::reclen, EMAN::ImageIO::rw_mode, EMAN::SpiderIO::SpiderHeader::scale, EMAN::SpiderIO::SpiderHeader::sigma, EMAN::ByteOrder::swap_bytes(), EMAN::SpiderIO::SpiderHeader::theta, EMAN::SpiderIO::SpiderHeader::time, EMAN::SpiderIO::SpiderHeader::title, and EMAN::SpiderIO::SpiderHeader::type.
Referenced by EMAN::SingleSpiderIO::write_header().
|
protected |
Definition at line 243 of file spiderio.h.
Referenced by ~SpiderIO().
EMAN::SpiderIO::DEFINE_IMAGEIO_FUNC |
Definition at line 77 of file spiderio.h.
|
protected |
Definition at line 242 of file spiderio.h.
Referenced by get_nimg(), EMAN::SingleSpiderIO::write_data(), EMAN::SingleSpiderIO::write_header(), and ~SpiderIO().
|
protected |
Definition at line 245 of file spiderio.h.
Referenced by need_swap().
|
protected |
Definition at line 246 of file spiderio.h.
Referenced by get_nimg(), need_swap(), SpiderIO(), write_single_data(), and write_single_header().