Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Attributes
EMAN::DM4IO Class Reference

Gatan DM$ was introduced with the GMS 2.0 release. More...

#include <dm4io.h>

Inheritance diagram for EMAN::DM4IO:
Inheritance graph
Collaboration diagram for EMAN::DM4IO:
Collaboration graph

List of all members.

Public Member Functions

 DM4IO (const string &filename, IOMode rw_mode=READ_ONLY)
 ~DM4IO ()
int get_nimg ()
 Return the number of images in this image file.

Static Public Member Functions

static bool is_valid (const void *first_block)

Public Attributes


Private Types

enum  { NUM_ID_INT = 4 }

Private Attributes

string filename
IOMode rw_mode
FILE * dm4file
bool is_big_endian
bool initialized

Detailed Description

Gatan DM$ was introduced with the GMS 2.0 release.

Each file starts with a TagGroupWithVersion record which saves the root TagGroup with some additional information.

Gatan DM4 file is a hierarchical binary image format. Everything in the image is a <key, value> pair, where key may be a container-type key which contains more key/value pairs. To read its header information, the whole file has to be parsed. During parsing, we check the keys that we are interested in and get their values.

The real binary data itself is also in this key/value hierarchy.

1 Gatan DM4 file contains 1 2D image.

All data is saved by default with big endian encoding.

Definition at line 253 of file dm4io.h.

Member Enumeration Documentation

anonymous enum [private]

Definition at line 264 of file dm4io.h.

{ NUM_ID_INT = 4 };     //actually its int+long+int=16 bytes

Constructor & Destructor Documentation

DM4IO::DM4IO ( const string &  filename,
IOMode  rw_mode = READ_ONLY 
) [explicit]

Definition at line 746 of file dm4io.cpp.

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

DM4IO::~DM4IO ( )

Definition at line 753 of file dm4io.cpp.

References dm4file, and tagtable.

        if (dm4file) {
                dm4file = 0;
        if (tagtable) {
                delete tagtable;
                tagtable = 0;

Member Function Documentation

int DM4IO::get_nimg ( ) [virtual]

Return the number of images in this image file.

Reimplemented from EMAN::ImageIO.

Definition at line 1041 of file dm4io.cpp.

References dm4file, EMAN::GatanDM4::TagTable::get_image_counted(), EMAN::ImageIO::init(), EMAN::GatanDM4::TagGroup::read_tag_group(), and tagtable.


        TagGroup root_group(dm4file, tagtable, "");
        root_group.read_tag_group(true, 0, 1);

        return tagtable->get_image_counted();
bool DM4IO::is_valid ( const void *  first_block) [static]

Definition at line 815 of file dm4io.cpp.

References data, ENTERFUNC, EMAN::ByteOrder::is_data_big_endian(), EMAN::ByteOrder::is_host_big_endian(), and EMAN::ByteOrder::swap_bytes().

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


        if (!first_block) {
                return false;

        const int *data = static_cast < const int *>(first_block);

        int img_ver = data[0];
        int byte_order = data[3];
        if (ByteOrder::is_data_big_endian(&img_ver) != ByteOrder::is_host_big_endian()) {

        if (img_ver != 4) {
                return false;

        if (byte_order != 0 && byte_order != 1) {
                return false;

        return true;

Member Data Documentation

Definition at line 259 of file dm4io.h.

FILE* EMAN::DM4IO::dm4file [private]

Definition at line 268 of file dm4io.h.

Referenced by get_nimg(), and ~DM4IO().

string EMAN::DM4IO::filename [private]

Definition at line 266 of file dm4io.h.

bool EMAN::DM4IO::initialized [private]

Definition at line 270 of file dm4io.h.

Definition at line 269 of file dm4io.h.

Referenced by DM4IO().

Definition at line 267 of file dm4io.h.

Definition at line 271 of file dm4io.h.

Referenced by DM4IO(), get_nimg(), and ~DM4IO().

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