AmiraMeshSaver

class io.savers.AmiraMeshSaver

Bases: io.savers.BaseSaver

AMIRAMESHSAVER - Saver for Amira Mesh binary format output.

Handles five format variants: ‘Amira Mesh binary (*.am)’ - full 3-D volume, binary encoding, image layer ‘Amira Mesh binary file sequence (*.am)’ - per-slice .am files, binary encoding, image layer ‘Amira mesh binary (*.am)’ - alias for labels/masks ‘Amira mesh binary RLE compression SLOW (*.am)’ - run-length encoded, binary, labels/masks only ‘Amira mesh ascii (*.am)’ - ASCII text encoding, labels/masks only

The active layer type (image vs. mask/labels) is determined by options.layerType (default ‘image’). Image data is passed to the legacy helper bitmap2amiraMesh(); mask and labels data are passed to bitmap2amiraLabels().

DATA DIMENSIONS Input data : [H, W, D, C, T] (MIB3 native order) bitmap2amiraMesh() expects [H, W, C, D] - permuted via obj.permuteMib3ToHWCD() for the first time point. bitmap2amiraLabels() expects [H, W, D] - squeezed from data.

PIXEL-SIZE STRUCT (pixStr) For bitmap2amiraLabels the pixStr is extended with bounding-box origin fields: pixStr = metadata.pixSize pixStr.minx = boundingBox(1) pixStr.miny = boundingBox(3) pixStr.minz = boundingBox(5)

COMPRESSION STRINGS Format string compression arg ‘Amira Mesh binary (*.am)’ → ‘binary’ ‘Amira Mesh binary file sequence (*.am)’ → ‘binary’ ‘Amira mesh binary (*.am)’ → ‘binary’ ‘Amira mesh binary RLE compression SLOW (*.am)’ → ‘binaryRLE’ ‘Amira mesh ascii (*.am)’ → ‘ascii’

USAGE EXAMPLES

%% 1. Save image volume as Amira Mesh binary
saver = io.SaverFactory.create('Amira Mesh binary (``*.am``)');

opts.Format         = 'Amira Mesh binary (``*.am``)';
opts.showWaitbar    = false;
opts.silent         = true;
opts.overwrite      = true;
opts.layerType      = 'image';

meta.filename       = 'source_stack.tif';
meta.colorType      = 'grayscale';
meta.lutColors      = [1 1 1];
meta.dataClass      = 'uint8';
meta.maxInt         = 255;
meta.pixSize        = struct('x',0.065,'y',0.065,'z',0.2, ...
                             'units','um','t',1,'tunits','s');
meta.boundingBox    = [0 33.3 0 33.3 0 10];

data = uint8(rand(512,512,50,1,1)*255);  % [H W D C T]
fnOut = saver.save(data, meta, '/output/myStack.am', opts);
fprintf('Saved: %s\n', fnOut);
%% 2. Save segmentation labels as Amira mesh binary
saver = io.SaverFactory.create('Amira mesh binary (``*.am``)');

opts.Format         = 'Amira mesh binary (``*.am``)';
opts.showWaitbar    = false;
opts.silent         = true;
opts.overwrite      = true;
opts.layerType      = 'labels';

meta.filename       = 'source_stack.tif';
meta.pixSize        = struct('x',0.065,'y',0.065,'z',0.2, ...
                             'units','um','t',1,'tunits','s');
meta.boundingBox    = [0 33.3 0 33.3 0 10];
meta.materialNames  = {'Nucleus'; 'ER'};
meta.materialColors = [0 0 1; 0 1 0];

labels = uint8(rand(512,512,50,1,1) * 2);  % [H W D C T]
fnOut = saver.save(labels, meta, '/output/Labels_myStack.am', opts);
%% 3. Save labels with RLE compression
saver = io.SaverFactory.create( ...
    'Amira mesh binary RLE compression SLOW (``*.am``)');

opts.Format      = 'Amira mesh binary RLE compression SLOW (``*.am``)';
opts.layerType   = 'labels';
opts.showWaitbar = true;
opts.silent      = true;
opts.overwrite   = true;

fnOut = saver.save(labels, meta, '/output/Labels_RLE.am', opts);

SEE ALSO io.SaverFactory, io.savers.BaseSaver, io.savers.TiffSaver, core.MibImage.save, core.MibDataset.save, models.MibModel.save

Constructor Summary
AmiraMeshSaver(options)

AMIRAMESHSAVER - Constructor for AmiraMeshSaver class.

Syntax:
saver = io.savers.AmiraMeshSaver(options)
Input Arguments:
  • options - (optional) struct, saver-level options (usually empty; per-save options are passed to save() instead)

Output Arguments:
  • obj - instance of the AmiraMeshSaver class

Method Summary
getSupportedFormats(~)

GETSUPPORTEDFORMATS - Return format strings handled by AmiraMeshSaver.

Syntax:
formats = obj.getSupportedFormats()
Input Arguments:

(none)

Output Arguments:
  • formats - cell array of format strings for Amira Mesh output

save(data, metadata, filename, options)

SAVE - Write data as an Amira Mesh file (image or labels/mask).

Syntax:
fnOut = obj.save(data, metadata, filename, options)
Input Arguments:
  • data - [H, W, D, C, T] numeric array

  • metadata - struct with fields:

    • colorType - 'grayscale' | 'multichannel' | 'indexed'

    • lutColors - [C x 3] per-channel LUT colours (0..1)

    • dataClass - 'uint8' | 'uint16' | …

    • maxInt - maximum intensity value

    • pixSize - struct {.x, .y, .z, .units, .t, .tunits}

    • boundingBox - [xmin xmax ymin ymax zmin zmax]

    • materialNames - cell array of material name strings (labels mode only)

    • materialColors - [M x 3] material RGB colours (labels mode)

  • filename - full output path, e.g. '/out/stack.am'

  • options - struct with fields:

    • Format - format string (selects encoding)

    • layerType - 'image' | 'mask' | 'labels'; default: 'image'

    • showWaitbar - logical; default: true

    • silent - logical, suppress dialogs; default: false

    • overwrite - logical; default: true

Output Arguments:
  • fnOut - [char] path of the saved .am file, or [cell of char] the per-slice paths for the file-sequence format; [] on failure

Example - see class-level documentation above.