Iimage modules

These modules contain functions for identifying and doing I/O from MRC and other file types defined in an image-type independent manner in the ImodImageFile structure.

Header to include: iimage.h

Functions in iimage.c


void iiAddCheckFunction(IIFileCheckFunction func)
void iiInsertCheckFunction(IIFileCheckFunction func, int index)
void iiDeleteCheckList()
void iiRegisterQuitCheck(int (*func)(int))
int iiCheckForQuit(int param)
ImodImageFile *iiNew()
int iiInit(ImodImageFile *i, int xsize, int ysize, int zsize, int file, int format, int type)
ImodImageFile *iiOpen(const char *filename, const char *mode)
ImodImageFile *iiOpenNew(const char *filename, const char *mode, int fileKind)
int iiReopen(ImodImageFile *inFile)
int iiSetMM(ImodImageFile *inFile, float inMin, float inMax, float scaleMax)
void iiClose(ImodImageFile *inFile)
void iiDelete(ImodImageFile *inFile)
ImodImageFile *iiCopyOpen(ImodImageFile *inFile)
int iiUseTiffThreads(ImodImageFile *inFile, int maxThreads)
int iiUseTiffThreadsForFP(FILE *fp, int maxThreads)
void iiCloseTiffCopies(ImodImageFile *inFile)
void iiCloseTiffCopiesForFP(FILE *fp)
int iiOpenCopiesForThreads(ImodImageFile **fileCopies, int maxThreads)
int iiFillMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)
int iiSimpleFillMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)
void iiSyncFromMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)
int iiDefaultMinMaxMean(int type, float *amin, float *amax, float *amean)
int iiWriteHeader(ImodImageFile *inFile)
void iiFileChangeAddress(ImodImageFile *oldFile, ImodImageFile *newFile)
FILE *iiFOpen(const char *filename, const char *mode)
ImodImageFile *iiLookupFileFromFP(FILE *fp)
void iiFClose(FILE *fp)
FILE *iiFOpenVolume(ImodImageFile *inFile, int volIndex)
FILE *iiFOpenNewVolume(ImodImageFile *inFile)
void iiAllowMultiVolume(int allow)
int iiSetChunkSizes(ImodImageFile *inFile, int xSize, int ySize, int zSize)
int iiGetAdocIndex(ImodImageFile *inFile, int global, int openMdocOrNew)
int iiTransferAdocSections(ImodImageFile *fromFile, ImodImageFile *toFile)
int iiReadSection(ImodImageFile *inFile, char *buf, int inSection)
int iiReadSectionByte(ImodImageFile *inFile, char *buf, int inSection)
int iiReadSectionUShort(ImodImageFile *inFile, char *buf, int inSection)
int iiReadSectionFloat(ImodImageFile *inFile, char *buf, int inSection)
int iiReadSectionAny(ImodImageFile *inFile, char *buf, int inSection, int convertTo)
int iiWriteSection(ImodImageFile *inFile, char *buf, int inSection)
int iiWriteSectionFloat(ImodImageFile *inFile, char *buf, int inSection)
float iiReadPoint(ImodImageFile *inFile, int x, int y, int z)
int iiLoadPCoord(ImodImageFile *inFile, int useMdoc, IloadInfo *li, int nx, int ny, int nz)
char *iiMakeBufferConvertIfFloat(ImodImageFile *inFile, char *buf, int ifFloat, int *inverted, const char *routine)
void iiConvertLineOfFloats(float *fbufp, unsigned char *bdata, int nx, int mrcMode, int bytesSigned, int pack4bits)
void iiSaveLoadParams(ImodImageFile *iiFile, ImodImageFile *iiSave)
int iiRestoreLoadParams(int retVal, ImodImageFile *iiFile, ImodImageFile *iiSave)
void iiBestTileSize(int imSize, int *tileSize, int *numTiles, int multipleOf)
int hdfWriteGlobalAdoc(ImodImageFile *inFile)
int hdfWriteDummySection(ImodImageFile *inFile, char *buf, int cz)
int iiTestIfHDF(const char *filename)

Functions in iilikemrc.c


void iiAddRawCheckFunction(IIRawCheckFunction func, const char *name)
void iiDeleteRawCheckList()
int iiLikeMRCCheck(ImodImageFile *inFile)
int iiSetupRawHeaders(ImodImageFile *inFile, RawImageInfo *info)
int analyzeDM3(FILE *fp, char *filename, int dmformat, RawImageInfo *info, int *dmtype)

Structures and Definitions for ImodImageFiles


ImodImageFile definitions
Raw mode codes
ImodImageFile structure
RawImageInfo structure

Functions in iimage.c

void iiAddCheckFunction(IIFileCheckFunction func)

Adds the given function to the end of the list of functions that iiOpen will call to check a file.  The format of the function is
  int iiFormatCheck(ImodImageFile *inFile)

void iiInsertCheckFunction(IIFileCheckFunction func, int index)

Insert the given function into the list of functions that iiOpen will call to check a file at position index in the list.  The format of the function is
  int iiFormatCheck(ImodImageFile *inFile)

void iiDeleteCheckList()

Frees the checking list to avoid memory leaks

void iiRegisterQuitCheck(int (*func)(int))

Registers a callback function that can be used for periodic updates or to check for quitting during loading from an MRC-like or HDF file.

int iiCheckForQuit(int param)

This function is called periodically during loading of a large section from an MRC-like or HDF file and calls the registered function if any.

ImodImageFile *iiNew()

Creates a new image file structure and initialize it to default or null values.  Returns 1 for error.

int iiInit(ImodImageFile *i, int xsize, int ysize, int zsize, int file, int format, int type)

Initializes the image file structure i for the given size and other characteristics

ImodImageFile *iiOpen(const char *filename, const char *mode)

Tries to open an image file with name filename and with the fopen mode mode (e.g. "rb"), using the file format check functions on the list. If filename is NULL or an empty string, then it assigns stdin to the file pointer.  Returns NULL for error; it and all checking routines should call b3dError with their error strings.

ImodImageFile *iiOpenNew(const char *filename, const char *mode, int fileKind)

Opens a new file whose name is in filename with the given mode, which must contain 'w'.  The type of file is specified by fileKind, which can be either IIFILE_MRC, IIFILE_TIFF, IIFILE_HDF, or IIFILE_DEFAULT for the type defined by calling b3dOutputFileType.  Adds the file to the list of opened files and returns the opened file pointer.

int iiReopen(ImodImageFile *inFile)

Reopen a file that has already been opened and analyzed.  Returns 1 if the file is already open or 2 for other errors.

int iiSetMM(ImodImageFile *inFile, float inMin, float inMax, float scaleMax)

Sets the scaling min and max (smin and smax in the image file structure inFile and computes the scaling slope and offset that will map smin to and smax to scaleMax by scaling with value * slope + offset. Uses the input values inMin and inMax, or the file min and max if these values are equal.  Returns 0.

void iiClose(ImodImageFile *inFile)

Closes an image file inFile and removes it from the list of opened files

void iiDelete(ImodImageFile *inFile)

Deletes an image file inFile after closing and calling any cleanup functions

ImodImageFile *iiCopyOpen(ImodImageFile *inFile)

Makes a copy of the image file structure for inFile and opens the file with iiReopen to take advantage of the previous analysis of the file properties.  Returns the opened file copy or NULL for various errors.  For a TIFF file, copies can be used to access a file from multiple threads; this may or may not work with other file types.

int iiUseTiffThreads(ImodImageFile *inFile, int maxThreads)

Enables parallel reading from a TIFF file open on inFile, using a fixed array of ImodImageFile pointers in this module.  Returns 0 if parallel reading is already set up for a different file, or if the file size is such that only one thread would be used; otherwise returns the number of threads for full-sized reading.  The maximum number of threads to use can be passed in maxThreads; if this is 0 the default will used, 16.

int iiUseTiffThreadsForFP(FILE *fp, int maxThreads)

Enables parallel reading from a TIFF file using a file pointer fp returned after opening it with iiFOpen.  Calls iiUseTiffThreads and returns its return value.

void iiCloseTiffCopies(ImodImageFile *inFile)

Closes all the copies of the TIFF file in inFile opened by iiUseTiffThreads; has no effect if no copies were opened or if called with a different file.

void iiCloseTiffCopiesForFP(FILE *fp)

Closes all the copies of a TIFF file opened by calling iiUseTiffThreadsForFP with fp. Has no effect if no copies were opened or if called with a different file.

int iiOpenCopiesForThreads(ImodImageFile **fileCopies, int maxThreads)

Calls iiCopyOpen maxThreads - 1 times with the first element in the array fileCopies, putting the additional open files in fileCopies, thus allowing access from multiple threads.  Returns the number of threads that can be used, which will be less than maxThreads if the opening of a copy fails.

int iiFillMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)

For the image file inFile, initializes the MRC header structure hdata and fills in as many fields as possible with file-specific values.  For an MRC file, it simply copies the already read-in header.  Returns -1 if a header filling function is not defined or 1 if there is some other problem filling the header in.

int iiSimpleFillMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)

Set up an MRC header with the size, mode, and other critical information

void iiSyncFromMrcHeader(ImodImageFile *inFile, MrcHeader *hdata)

For the image file inFile, synchronizes numerous values in the ImodImageFile structure from values in hdata, including size, mode, scale, origin, rotation, and min/max/mean values.

int iiDefaultMinMaxMean(int type, float *amin, float *amax, float *amean)

Returns default min/max/mean values for the data type type into amin, amax, and amean.  Returns an actual file value for signed bytes, to be shifted up later in a header-reading routine.

int iiWriteHeader(ImodImageFile *inFile)

Writes header and other metadata to inFile if the file type has a function defined for doing so.  Returns 1 for error.

void iiFileChangeAddress(ImodImageFile *oldFile, ImodImageFile *newFile)

Manages the list of open files, volume pointers in iiVolumes, and the fp entry after the ImodImageFile structure has been copied from oldFile to newFile.  The old address no longer needs to be useable.

FILE *iiFOpen(const char *filename, const char *mode)

Opens an old or new ImodImageFile with the given filename and mode, adds it to the list of opened files, and returns the file pointer.  When this function is used instead of fopen to open an image file, then most MRC file reading and writing functions listed in TOP, as well as mrc_head_read and mrc_head_write, will look up the file pointer in the list of opened files and perform the operation appropriate for the particular file type.

ImodImageFile *iiLookupFileFromFP(FILE *fp)

Returns the open ImodImageFile that has fp as its fp member.

void iiFClose(FILE *fp)

Closes the file with pointer fp either by calling iiDelete for its corresponding ImodImageFile, or by simply closing it if it is not in the list of opened files. This function must be called for a newly written file if there is a possibility that it is a TIFF file.

FILE *iiFOpenVolume(ImodImageFile *inFile, int volIndex)

Opens the volume at index volIndex in a multi-volume HDF file, where the index is numbered from 0 and must be at least 1; i.e., this should not be called on the initial volume accessed by iiFOpen.

FILE *iiFOpenNewVolume(ImodImageFile *inFile)

Creates a new volume in an HDF file open on inFile that was not opened read-only and has volume datasets rather than a stack of single-image datasets.  Sets the zChunkSize member of inFile to 1 to ensure that a volume dataset will be created later, but you can still change chunk properties with iiSetChunkSizes. ; Returns the fp member of the new ImodImageFile structure, or NULL for error.

void iiAllowMultiVolume(int allow)

Sets a flag to allow opening of multi-volume HDF files.  There is a Fortran wrapper iiallowmultivolume.

int iiSetChunkSizes(ImodImageFile *inFile, int xSize, int ySize, int zSize)

For the HDF file or volume dataset in inFile, sets the tile (chunk) sizes in X and Y to xSize and ySize, and the chunk size in Z to zSize.  Pass 0 for xSize or ySize to avoid tiling in those dimensions.  zSize must be 1 or greater.  This function must be called before the volume or its header is written.  Returns 1 for error.

int iiGetAdocIndex(ImodImageFile *inFile, int global, int openMdocOrNew)

Returns an autodoc index for inFile.  Set global non-zero for accessing or storing information that applies to all volumes of a multi-volume HDF file or information stored in sections other than in the ZValue collection.  If the file is not an HDF file, it will return the existing value of the adocIndex member if it is non-negative or if openMdocOrNew is 0; otherwise it will attempt to open a metadata autodoc file by adding ".mdoc" to the filename if openMdocOrNew is positive or it will open a new autodoc if openMdocOrNew is negative.  Returns -1 if there is no autodoc, or -2 for more serious errors.

int iiTransferAdocSections(ImodImageFile *fromFile, ImodImageFile *toFile)

Transfers all but Z-slice specific information from the autodoc structures associated with fromFile to those of toFile.  The adocIndex member must be non-negative for both files.  Global data (in the PreData section) are transferred between these two specific autodocs.  Data in other sections, except for sections of type ZValue, are also transferred.  For an HDF file, the autodoc index used in each case is the one in globalAdocIndex, if it is non-negative; otherwise it is the one in adocIndex. Returns 1 for errors.

int iiReadSection(ImodImageFile *inFile, char *buf, int inSection)

Reads the section inSection from the file inFile as raw data into buffer buf.  Returns -1 for undefined reading function or failure to reopen file, otherwise passes along return value of the reading function.

int iiReadSectionByte(ImodImageFile *inFile, char *buf, int inSection)

Reads the section inSection from the file inFile as scaled byte data into buffer buf.  Returns -1 for undefined reading function or failure to reopen file, otherwise passes along return value of the reading function.

int iiReadSectionUShort(ImodImageFile *inFile, char *buf, int inSection)

Reads the section inSection from the file inFile as scaled unsigned short data into buffer buf.  Returns -1 for undefined reading function or failure to reopen file, otherwise passes along return value of the reading function.

int iiReadSectionFloat(ImodImageFile *inFile, char *buf, int inSection)

Reads the section inSection from the file inFile as unscaled floating point values into buffer buf.  Returns -1 for undefined reading function or failure to reopen file, otherwise passes along return value of the reading function.

int iiReadSectionAny(ImodImageFile *inFile, char *buf, int inSection, int convertTo)

Reads the section inSection from the file inFile into buffer buf with conversion specified by convertTo, which must be one of MRSA_NOPROC, MRSA_BYTE, MRSA_USHORT, and MRSA_FLOAT.  Returns -1 for undefined reading function, failure to reopen file, or invalide convertTo, otherwise passes along return value of the reading function.

int iiWriteSection(ImodImageFile *inFile, char *buf, int inSection)

Write data in the buffer buf to section inSection of the file inFile. Returns -1 for undefined writing function or failure to reopen file; otherwise passes along return value of the writing function.

int iiWriteSectionFloat(ImodImageFile *inFile, char *buf, int inSection)

Write floating point or complex data in the buffer buf to section inSection of the file inFile.  Returns -1 for undefined writing function or failure to reopen file; otherwise passes along return value of the writing function.

float iiReadPoint(ImodImageFile *inFile, int x, int y, int z)

Returns the value of a single pixel at x, y, z from the image file inFile. Gives the value directly for byte, short, and float data, (by calling mrcReadZFloat) and the magnitude for complex data (after calling mrcReadZ).  Returns the file minimum hdata->amin for coordinates out of bounds or if there is no function for reading floats for a file type.

int iiLoadPCoord(ImodImageFile *inFile, int useMdoc, IloadInfo *li, int nx, int ny, int nz)

Loads piece coordinates from an MRC file inFile of size nx, ny, nz and places them in the LoadInfo structure li.  If no coordinates are found and useMdoc is non-zero, it then tries to load coordinates from a metadata file named as the image filename plus .mdoc.  Returns 0 regardless of whether there are piece coordinates or errors.

char *iiMakeBufferConvertIfFloat(ImodImageFile *inFile, char *buf, int ifFloat, int *inverted, const char *routine)

If ifFloat is set and the mode of the file inFile is not float, it makes a new buffer for the full contents of buf and converts the floats in buf to integer or byte, inverting the lines in Y and setting inverted to 1.  Returns the new buffer in this case, or just returns buf.  The name of the calling routine should be in routine.

void iiConvertLineOfFloats(float *fbufp, unsigned char *bdata, int nx, int mrcMode, int bytesSigned, int pack4bits)

Converts nx floating point values in the array fbufp to values in the mode specified by mrcMode, with signed bytes produced if byteSigned is nonzero. Values are placed in bdata.

void iiSaveLoadParams(ImodImageFile *iiFile, ImodImageFile *iiSave)

Copies the parameters with loading information from iiFile to iiSave: ll and ur members for x, y, and z, axis, padLeft, padRight, slope, and offset.

int iiRestoreLoadParams(int retVal, ImodImageFile *iiFile, ImodImageFile *iiSave)

Restores the parameters copied by iiSaveLoadParams from iiSave back to iiFile and returns the value in retVal for convenience.

void iiBestTileSize(int imSize, int *tileSize, int *numTiles, int multipleOf)

Given an image size in one dimension in imSize, a target tile size in tileSize, and a factor that the tile size must be a multiple of in multipleOf, returns an optimal tile size that minimizes extra total image size in tileSize and the number of tiles in numTiles.  It picks a tile size less than or equal to the target, unless the tile size with one fewer tile gives both less extra total image size and a tile size closer to the target.  Fortran wrapper iibesttilesize.

int hdfWriteGlobalAdoc(ImodImageFile *inFile)

Writes global autodoc information and autodoc information contained in sections other than of type ZValue to the top images group of the HDF file opened in inFile. This function is called automatically when the header is written for an HDF file containing a stack of single images or only one volume, so it needs to be called only when working with a multi-volume file.

int hdfWriteDummySection(ImodImageFile *inFile, char *buf, int cz)

Adds a dataset for section cz to an HDF file open on inFile without writing data; buf should be defined but need not be more than a few bytes.  Returns error values from the writing routine or 1 if the package does not support HDF.

int iiTestIfHDF(const char *filename)

Tests if the file filename is an HDF file without opening it extensively; this function can be used when a file may be open for writing in another process.  Returns -2 if the package does not support HDF, -1 for an error opening the file, 0 if file is not HDF, or 1 if it is.  Fortran wrapper iitestifhdf

Functions in iilikemrc.c

An MRC-like file consists of images that are all of equal size, where each image is a continuous series of numbers organized as one horizontal line after another. The images start after a header of a defined size and there can be a fixed amount to skip between each image.

void iiAddRawCheckFunction(IIRawCheckFunction func, const char *name)

Add the given raw-type checking function func to the front of the checking list; name is a name for the format.  The definition of such a function is
  int checkMyFormat(FILE *fp, char *filename, RawImageInfo *info)

void iiDeleteRawCheckList()

Frees the checking list and all its data to avoid memory leaks

int iiLikeMRCCheck(ImodImageFile *inFile)

Checks the image file in inFile for one known MRC-like (raw-type) format after another. Returns IIERR codes for errors.  b3dError is called with a message for all errors that occur during checking, except for IIERR_NOT_FORMAT.

int iiSetupRawHeaders(ImodImageFile *inFile, RawImageInfo *info)

Creates an MRC header and fills it and the items in inFile from the information in info; specifically the nx, ny, nz, swapBytes, headerSize, sectionSkip, yInverted, and type members. Returns IOERR_MEMORY_ERR for error allocating header.

int analyzeDM3(FILE *fp, char *filename, int dmformat, RawImageInfo *info, int *dmtype)

Analyzes a file known to be a DigitalMicrograph version 3 or 4, as indicated in dmformat; the file pointer is in fp and the filename in filename.  Returns size, type, and other information in info; specifically the nx, ny, nz, swapBytes, headerSize, and type members.  Returns the DM data type number in dmtype. Returns IOERR_IO_ERROR for errors reading the file or IOERR_NO_SUPPORT for other errors in analyzing the file.

Structures and Definitions for ImodImageFiles

ImodImageFile definitions

Values for the file member of ImodImageFile, describing kind of file
  /* Except IIFILE_DEFAULT means use the default output file type */
#define IIFILE_DEFAULT -1
#define IIFILE_UNKNOWN 0
#define IIFILE_TIFF    1
#define IIFILE_MRC     2
#define IIFILE_QIMAGE  3
#define IIFILE_RAW     4
#define IIFILE_HDF     5
#define IIFILE_JPEG    6

  /* Values for the format member of ImodImageFile, describing kind data */
#define IIFORMAT_LUMINANCE 0
#define IIFORMAT_RGB       1
#define IIFORMAT_RGBA      2
#define IIFORMAT_COMPLEX   3
#define IIFORMAT_COLORMAP  4

  /* Values for the type member of ImodImageFile, describing numeric type */
#define IITYPE_UBYTE   0
#define IITYPE_BYTE  1
#define IITYPE_SHORT  2
#define IITYPE_USHORT 3
#define IITYPE_INT    4
#define IITYPE_UINT   5
#define IITYPE_FLOAT  6

  /* Values for the state member of ImodImageFile, describing file state */
#define IISTATE_NOTINIT 0
#define IISTATE_PARK    1
#define IISTATE_READY   2
#define IISTATE_UNUSED  3
#define IISTATE_BUSY    4

  /* Recognized values for the tiffCompression member of ImodImageFile, a 
     copy of TIFF definitions.  Other compressions will have other values. */
#define IICOMPRESSION_NONE  1
#define IICOMPRESSION_LZW   5
#define IICOMPRESSION_JPEG  7
#define IICOMPRESSION_ZIP   8

  /* Error codes, used by check routines */
#define IIERR_BAD_CALL  -1
#define IIERR_NOT_FORMAT 1
#define IIERR_IO_ERROR   2
#define IIERR_MEMORY_ERR 3
#define IIERR_NO_SUPPORT 4
#define IIERR_QUITTING   5

  /* Codes for source of HDF files */
#define IIHDF_IMOD       1
#define IIHDF_OTHER_MRC  2
#define IIHDF_EMAN       3
#define IIHDF_CHIMERA    4
#define IIHDF_UNKNOWN    5

  /* Codes for data conversion type in "ReadSectionAny" functions */
#define MRSA_NOPROC 0
#define MRSA_BYTE   1
#define MRSA_FLOAT  2
#define MRSA_USHORT 3

  /* Flags for userData */
#define IIFLAG_BYTES_SWAPPED   1
#define IIFLAG_TVIPS_DATA      2

Raw mode codes

Yet another set of mode values, which define the order for radio buttons in a raw type selector dialog
#define RAW_MODE_SBYTE         0
#define RAW_MODE_BYTE          1
#define RAW_MODE_SHORT         2
#define RAW_MODE_USHORT        3
#define RAW_MODE_FLOAT         4
#define RAW_MODE_COMPLEX_FLOAT 5
#define RAW_MODE_RGB           6

ImodImageFile structure

typedef struct ImodImageFileStruct ImodImageFile;
  typedef int (*iiSectionFunc)(ImodImageFile *inFile, char *buf, int inSection);

  struct  ImodImageFileStruct
  {
    char *filename;
    char fmode[4];
    FILE *fp;
    char *description;
    int   state;

    /* Data set by new and open functions. */
    int   nx, ny, nz;
    int   file;       /* Type of file, i.e. MRC, TIF... */
    int   format;     /* Kind of data represented: i.e. gray, color, complex */
    int   type;       /* Type if numerical elements, i.e. byte, etc. */
    int   mode;       /* MRC mode value */
    int   newFile;    /* Newly created file */
    
    /* optional data to be set if input file supports it. */
    float amin, amax, amean, rms;
    float xscale, yscale, zscale;
    float xtrans, ytrans, ztrans;
    float xrot,   yrot,   zrot;
    int   time, wave;

    /* load info: change these for loading sub sections. */
    int   llx, lly, llz, urx, ury, urz;
    float slope, offset, smin, smax;
    int   axis;
    int   mirrorFFT;   /* Return mirrored FFT when scaling to bytes */
    int   padLeft;     /* Padding at start or end of line when reading or writing a */
    int   padRight;    /* subset of the array, in pixels not bytes */

    /* extra storage used by individual file format functions. */
    int   headerSize;
    int   sectionSkip;
    int   hasPieceCoords;    /* Flag that MRC file has piece coordinates in header */
    char *header;
    char *userData;
    unsigned int userFlags;  /* Flags for the userData */
    int userCount;           /* Number of bytes of userData */
    unsigned char *colormap;
    int  planesPerImage;     /* # of planes per TIFF image */
    int  contigSamples;      /* # of contiguous samples per pixel in plane */
    int  multipleSizes;      /* Flag that TIFF file has multiple sizes */
    int  rgbSamples;         /* Number of samples for RGB TIFF file */
    int  anyTiffPixSize;     /* Set non-0 to have TIFF pixel size put into [xyz]scale */
    int  rawPaletteBytes;    /* Set non-zero to have palette image returned as bytes */
    int  tiffCompression;    /* Compression type in tiff file */
    int  tileSizeX;          /* Tile size in X, or 0 if no tiles */
    int  tileSizeY;          /* Tile size in Y if tiles, strip size if not */
    int  lastWrittenZ;       /* Last Z written, needed if sequential writing only */
    int  packed4bits;        /* Data in file are 4-bit, packed 2 pixels per byte */
    int fillOrder;           /* Fill order for the 4-bit data */

    /* HDF variables */
    Ilist *stackSetList;     /* Names, ID's for stack of single-image datasets */
    int *zToDataSetMap;      /* Map from Z value to index in dataset list */
    int zMapSize;            /* Allocated size of Z map */
    char *datasetName;       /* Dataset name for single volume open in this iifile */
    int datasetID;           /* ID for dataset of single volume */
    int datasetIsOpen;       /* Flag that it is open */
    int numVolumes;          /* Number of volume datasets in the HDF file */
    ImodImageFile **iiVolumes;  /* Array of pointers to iifiles open in the HDF file */
    int adocIndex;           /* Index of autodoc with metadata for this iifile */
    int globalAdocIndex;     /* Index for global metadata in multifile case */
    int hdfSource;           /* Apparent source of file (IIHDF_ value) */
    int hdfFileID;           /* File ID */
    int zChunkSize;          /* Size of chunk in Z; must be nonzero for a volume */

    /* Callback functions used by different file formats. */
    iiSectionFunc readSection;
    iiSectionFunc readSectionByte;
    iiSectionFunc readSectionUShort;
    iiSectionFunc readSectionFloat;
    iiSectionFunc writeSection;
    iiSectionFunc writeSectionFloat;
    void (*cleanUp)(ImodImageFile *inFile);
    void (*close)(ImodImageFile *inFile);
    int (*reopen)(ImodImageFile *inFile);
    int (*fillMrcHeader)(ImodImageFile *inFile, MrcHeader *hdata);
    int (*syncFromMrcHeader)(ImodImageFile *inFile, MrcHeader *hdata);
    int (*writeHeader)(ImodImageFile *inFile);

  };

RawImageInfo structure

A structure for passing bare-bones information about an MRC-like (raw) file to a routine that makes an MRC header
  typedef struct raw_image_info {
    int type;           /* Data type, one of the RAW_MODE_* values */
    int nx, ny, nz;     /* Size of file in X, Y, Z */
    int swapBytes;      /* Whether bytes are swapped */
    int headerSize;     /* Offset to data */
    float amin, amax;   /* Data min and max, set to 0 if unknown */
    int scanMinMax;     /* Flag that scan is needed, used internally */
    int allMatch;       /* Flag that all files match, used internally */
    int sectionSkip;    /* Padding after each section - there may be no padding
                           after last section */
    int yInverted;      /* Lines are inverted in Y */
    float pixel;        /* Pixel size in Angstroms, set to 0. if unknown */
    float zPixel;       /* Pixel size in Z if different, set to 0. otherwise */
  } RawImageInfo;