ImodLoader

class io.loaders.ImodLoader

Bases: io.loaders.BaseImageLoader

IMODLOADER - Loader for IMOD MRC/REC files (.mrc, .rec, .st, .pre, .ali), based on.

io.loaders.BaseImageLoader base class

This loader handles IMOD format files using the MRCImage class. It supports: - MRC/REC format (electron microscopy) - Tomogram stacks (.st, .preali, .ali) - Automatic conversion from signed/float to unsigned integers - Dimension permutation and vertical flipping

Constructor Summary
ImodLoader(options)

IMODLOADER - Constructor for ImodLoader class.

Syntax:
loader = io.loaders.ImodLoader(options)
Input Arguments:
  • options - (optional) struct with fields:

    • waitbar - [logical] show or not the waitbar; default: false

    • mibPath - [char] path to MIB directory

    • customSections - [logical] load custom sections only; default: false

    • customSectionsSettings - [struct] custom section parameters

    • imgStretch - [logical] stretch uint32 images to uint16; default: false

    • silentMode - [logical] do not ask user questions; default: false

    • verbose - [logical] show timing information; default: false

    • Font - [struct] font settings for dialogs

    • ParentFigure - handle of the main MIB window (parent for uiprogressdlg)

Output Arguments:
  • obj - instance of the ImodLoader class

Example 1 - create loader with options:

options.waitbar = true;
loader = io.loaders.ImodLoader(options);
Method Summary
static densityRangeToClass(minDensity, maxDensity)

DENSITYRANGETOCLASS - Pick an unsigned integer class fitting the density range.

Syntax:
imgClass = io.loaders.ImodLoader.densityRangeToClass(minDensity, maxDensity)

MRC files may store signed integer (mode 1) or floating point (mode 2) densities, while MIB operates with unsigned integers. This method selects the narrowest unsigned class that can accommodate the dynamic range of the densities; wider ranges are rescaled into uint32 during loading and further stretched to uint16 by finalizeImageLoading.

Input Arguments:
  • minDensity - [numeric] minimal density value stored in the file

  • maxDensity - [numeric] maximal density value stored in the file

Output Arguments:
  • imgClass - [char] 'uint8', 'uint16' or 'uint32'

Example 1 - class for a float32 tomogram:

imgClass = io.loaders.ImodLoader.densityRangeToClass(224940, 463090);   % -> 'uint32'
loadImages(files, imginfo, options)

LOADIMAGES - Load image data from IMOD MRC/REC files.

Syntax:
[img, imginfo] = obj.loadImages(files, imginfo, options)

This method uses MRCImage.getVolume() to load actual data. It handles:

  • Conversion from signed/float to unsigned integers

  • Dimension permutation (X,Y,Z → Y,X,Z)

  • Vertical flipping (MRC convention)

Input Arguments:
  • files - structure array from loadMetadata

  • imginfo - dictionary from loadMetadata

  • options - (optional) struct for image loading

Output Arguments:
  • img - loaded image dataset

  • imginfo - updated dictionary

Example 1 - load images from IMOD MRC file:

loader = io.loaders.ImodLoader();
[imginfo, files] = loader.loadMetadata({'dataset.mrc'}, options);
[img, imginfo] = loader.loadImages(files, imginfo, options);
loadMetadata(filenames, options)

LOADMETADATA - Load metadata for IMOD MRC/REC files.

Syntax:
[imginfo, files] = obj.loadMetadata(filenames, options)

This method uses MRCImage to read file headers and determine dimensions and data types.

Input Arguments:
  • filenames - cell array with filenames of IMOD files

  • options - (optional) struct with fields:

    • waitbar - [logical] show or not the waitbar; default: false

    • customSections - [logical] load part of the dataset; default: false

    • Font - [struct] font settings for dialogs

Output Arguments:
  • imginfo - dictionary with image metadata containing fields:

    • Height - image height in pixels

    • Width - image width in pixels

    • Colors - number of color channels

    • Depth - number of z-slices

    • Time - number of time points

    • imgClass - image class (uint8, uint16, etc.)

    • ColorType - 'grayscale', 'truecolor', or 'indexed'

    • ImageDescription - description with BoundingBox info

    • Format - HDF5 format type ('matlab.hdf5' or 'bdv.hdf5')

    • Levels - number of pyramid levels (for BDV only)

    • ReturnedLevel - selected pyramid level (for BDV only)

    • pixSize - struct with pixel sizes: .x, .y, .z, .t, .units, .tunits

    • other format-specific metadata fields

  • files - structure array with file information

Example 1 - load metadata from IMOD file:

loader = io.loaders.ImodLoader();
filenames = {'dataset.mrc'};
[imginfo, files] = loader.loadMetadata(filenames, options);