MatModelLoader

class io.loaders.MatModelLoader

Bases: io.loaders.BaseImageLoader

MATMODELLOADER - Loader for MATLAB-format segmentation model files.

Handles three on-disk formats written by core.MibLabels.save: .model - MIB3/MIB2 native MATLAB format (modelVariable, modelMaterialNames, …) .mat - MIB v1 legacy format (model_var, material_list, color_list, …) .mibCat - MATLAB categorical format (imgOut as categorical, options struct)

The loader caches the raw model array in files(i).data during loadMetadata to avoid re-reading the file in loadImages.

Constructor Summary
MatModelLoader(options)

MATMODELLOADER - Constructor for MatModelLoader class.

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

    • mibPath - [char] path to MIB directory

    • ParentFigure - handle to parent figure for dialogs

Output Arguments:
  • obj - instance of MatModelLoader

Method Summary
loadImages(~, files, imginfo, ~)

LOADIMAGES - Assemble cached model data from files into a 5-D array.

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

Reads the pre-cached data from files(i).data and stacks them along the Z dimension into a [H W D 1 T] array.

Input Arguments:
  • files - structure array from loadMetadata with data, noLayers, etc.

  • imginfo - dictionary from loadMetadata

  • options - (optional) struct (unused, kept for interface conformance)

Output Arguments:
  • img - [H W totalZ 1 T] model array

  • imginfo - unchanged dictionary

Example 1 - load model images:

loader = io.loaders.MatModelLoader();
[imginfo, files] = loader.loadMetadata({'Labels.model'});
[img, imginfo]   = loader.loadImages(files, imginfo);
loadMetadata(filenames, options)

LOADMETADATA - Load both metadata and raw pixels for MATLAB-format model files.

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

Reads each MAT/model/mibCat file, determines the labelsVariable, extracts all model metadata (material names, colors, type, annotations), and caches the raw array in files(i).data.

Input Arguments:
  • filenames - cell array with full path filenames to load

  • options - (optional) struct for metadata loading

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

    • modelMaterialNames - cell array of material names

    • modelMaterialColors - Nx3 RGB matrix (values 0..1)

    • modelType - numeric type (63/255/65535/4294967295)

    • labelsVariable - variable name used in the MAT file

    • labelText - annotation text (or [])

    • labelPosition - annotation positions (or [])

    • labelValue - annotation values (or [])

    • BoundingBox - [1x6] bounding box (or [])

    • numEntries - number of successfully loaded files

  • files - structure array with per-file information:

    • filename - [char] full path

    • height, width, noLayers - dimensions

    • color, time - always 1

    • imgClass - MATLAB class of the raw array

    • data - raw model array (cached)

Example 1 - load model metadata:

loader = io.loaders.MatModelLoader();
[imginfo, files] = loader.loadMetadata({'path/to/Labels.model'});