MibDataset

class core.MibDataset

Bases: matlab.mixin.Copyable

MIBDATASET - Container for a single open dataset with image and annotation layers.

MibDataset represents one open dataset in MIB3. Each dataset contains multiple layers (image, labels, mask, selection) and associated metadata. Supports Standard, Virtual, and BigData dataset types with comprehensive layer management and coordinate conversion utilities.

Constructor Summary
MibDataset(img, meta, datasetType, modelType)

MIBDATASET - Constructor for a dataset container with image and annotation layers.

Syntax:
obj = core.MibDataset()
obj = core.MibDataset(img)
obj = core.MibDataset(img, meta)
obj = core.MibDataset(img, meta, datasetType)
obj = core.MibDataset(img, meta, datasetType, modelType)
Input Arguments:
  • img (optional) - [numeric] matrix with the image data; can be empty or omitted

  • meta (optional) - [dictionary] metadata dictionary with optional fields:

    • .filename - [char] full path to the dataset

    • .sliceName - [cell] cell array with slice names

    • .lutColors - [numeric] LUT colors matrix (colChannel, RGB) in range [0-1]

    • .pixSize - [dictionary] physical pixel size with sub-fields:

      • .x - [numeric] physical width of a pixel

      • .y - [numeric] physical height of a pixel

      • .z - [numeric] physical thickness of a voxel

      • .t - [numeric] time between frames for 2D movies

      • .tunits - [char] time units (e.g., 'sec', 'ms')

      • .units - [char] spatial units: 'm', 'cm', 'mm', 'um', or 'nm'

    • .viewPort - [dictionary] viewing parameters with sub-fields:

      • .min - [numeric] minimal value for intensity stretching per channel

      • .max - [numeric] maximal value for intensity stretching per channel

      • .gamma - [numeric] gamma factor for contrast adjustment per channel

  • datasetType (optional) - [char] dataset type (default: 'Standard'):

    • 'Standard' - image loaded completely into memory

    • 'Virtual' - image loaded on demand

    • 'BigData' - big-data compatible dataset

  • modelType (optional) - [char] labels layer type (default: 'imageOnly'):

    • 'imageOnly' - initialize with image only; other layers are NaN

    • 'labels' - initialize model with 255 materials; mask and selection same dimensions as labels

    • 'labels63' - initialize model with 63 materials; mask and selection are NaN

Output Arguments:
  • obj - [core.MibDataset] initialized dataset instance

Example 1 - Minimal: create an empty dataset:

ds = core.MibDataset();

Example 2 - Create from a raw uint8 volume (grayscale):

vol = imread('myImage.tif');    % [H, W] or [H, W, C]
ds = core.MibDataset(vol);

Example 3 - Create from a 3D stack with 63-material labels:

vol = zeros(512, 512, 40, 'uint8');    % [H, W, Z]
ds = core.MibDataset(vol, dictionary(), 'Standard', 'labels63');
ds.image.pixSize.x = 0.013;
ds.image.pixSize.y = 0.013;
ds.image.pixSize.z = 0.030;
ds.image.sliceName = {'myStack.tif'};
ds.updateBoundingBox([], [0 0 0]);

Example 4 - Create with pre-filled metadata:

meta = dictionary();
meta('filename') = 'C:\data\myImage.tif';
ds = core.MibDataset(vol, meta, 'Standard', 'labels63');

Example 5 - Replace active dataset in model with fresh volume:

vol = imread('newdata.tif');
obj.mibModel.I{obj.mibModel.id} = core.MibDataset(vol, dictionary(), 'Standard', 'labels63');
obj.mibModel.I{obj.mibModel.id}.image.sliceName = {'newdata.tif'};
notify(obj.mibModel, 'NewDataset');
notify(obj.mibModel, 'ShowImage');
Property Summary
annotations

selection layer

axesX

other properties

axesY

a vector [min, max] with minimal and maximal coordinates of the axes X of the ‘obj.mibController.cImageDoc{setId}.handles.imViewAxes’ axes; use @code obj.mibModel.getAxesLimits() @endcode to read this property

bioFormatsMemoizerMemoDir

a vector [min, max] with minimal and maximal coordinates of the axes Y of the ‘obj.mibController.cImageDoc{setId}.handles.imViewAxes’ axes; use @code obj.mibModel.getAxesLimits() @endcode to read this property

blockModeSwitch

path to directory where BioFormats Memoizer is storing memo files

current_yxz

a variable to hold a status of the block mode (mibView.handles.toolbarBlockModeSwitch), 1 - enabled, 0 - disabled

datasetType

a vector to remember last selected slice number of each ‘yx’, ‘zx’, ‘zy’ planes. Dimensions: [1 1 1]

dim_yxzct

'Standard'), one of:

  • 'Standard' - standard image, loaded to memory completely

  • 'Virtual' - virtual dataset, loaded upon demand

  • 'BigData' - big-data compatible dataset

Type:

[char] type of the dataset (default

enableSelection

a matrix with dimensions of the dataset [height, width, depth, colors, time] equal to size obj.image{1} for non-virtual datasets

hROI

a handle to class to keep measurements

image

layers

instanceIndex

Statistics for the ‘Mask’ layer with the ‘PixelList’ info returned by ‘regionprops’ Matlab function

labels

image layer, instance of core.MibImage

lastSegmSelection

a switch (0/1) to enable or not the selection, mask, model layers

lines3D

a handle to class for keeping annotations

magFactor

a vector with 2 elements of two previously selected materials for use with the ‘e’ key shortcut

mask

label layer for the model, instance of core.MibLabels or core.MibLabels63

maskExist

magnification factor for the datasets, 1=100%, 1.5 = 150%; use @code mibModel.getMagFactor() @endcode to read this property

maskStats

a switch to indicate presence of the ‘Mask’ layer. Can be 0 (no mask) or 1 (mask exist)

measure

a handle to class for keeping 3D Lines and skeletons

modelExist

Cached per-object index of an instance model (65535/4294967295 types), built by obj.buildInstanceIndex() and used by controllers.InstanceEditor so that split/merge/connect touch only one object’s bounding box instead of scanning the whole volume. See utils.instances.objectIndex for the fields. Empty when not built. @note it goes STALE on any edit made outside the editor (brush, undo, a new model). The editor watches the SetData and Undo events and marks it; acting on a stale bounding box writes the wrong voxels, so a stale index must be rebuilt rather than used.

movieFilename

filename for the snapshot, used by controllers.Snapshot; initialized on first open

orientation

a switch to indicate presence of the ‘Model’ layer. Can be 0 (no model) or 1 (model exist)

restrictSelectionToMask

Orientation of the currently shown dataset, @li @b 3 = the ‘yz’ plane, @b default @li @b 1 = the ‘zx’ plane @li @b 2 = the ‘zy’ plane

restrictSelectionToMaterial

a switch indicating the value of the obj.view.handles.panels.segmentation.handles.restrictMask

roiShow

a switch indicating the value of the obj.view.handles.panels.segmentation.handles.restrictMaterial

selectedAddToMaterial

a switch to show or not ROI on the image axes

selectedColorChannel

index of selected Add to Material, where the Selection layer should be targeted, assigned in the AddTo column of the obj.view.handles.panels.segmentation.handles.materialsTable @b 1 - Mask; @b 2 - Exterior; @b 3 - first material of the model, @b 4 - second material etc

selectedMaterial

color channel selected in the Color channel dropdown (obj.view.handles.panels.selection.handles.colChannel) of the Selection panel. 0 - all colors, 1, 2 - 1st, 2nd …

selectedROI

index of material selected in obj.view.handles.panels.segmentation.handles.materialsTable: @b 1 - Mask; @b 2 - Exterior; @b 3 - first material of the model, @b 4 - second material etc

selection

mask layer

showAllMaterials

coordinates of the shown part of the dataset @note dimensions are @code ([height, width, color, depth, time],[min max]) @endcode @li (1,[min max]) - height @li (2,[min max]) - width @li (3,[min max]) - z - value @li (4,[min max]) - colors , array of color channels to show, for example [1, 3, 4] @li (5,[min max]) - t - time point

slices

a vector of indices (as stored in mibRoiRegion class) of the selected ROI in the mibView.handles.mibRoiList table; -1 -> roi is not shown; [1, 3] -> first and third…

snapshotFilename

unlink materials in the segmentation table, when true click on the segmentation table selects individually Materials or addTo columns

unlinkMaterials

use or not LUT for visualization of image, a number @b 0 - do not use; @b 1 - use a status of obj.view.handles.panels.selection.handles.lutColors

useLUT

a switch to show all materials of the model in the image view axes, or only a single one; defined in context menu of obj.cSegmentation.handles.materialsTable

Method Summary
addFrame(BatchOpt, parentFigure)

ADDFRAME - Add a frame around the dataset using dX/dY padding.

Syntax:
obj.addFrame(BatchOpt, parentFigure)

Ported from MIB2 @mibModel/addFrame.m.

Input Arguments:
  • BatchOpt - [struct] parameters for the frame operation:

    • .FrameWidth - [numeric cell] frame width in pixels (may be negative to trim); {1} value, {2} limits [-Inf, Inf], {3} 'on' (integer)

    • .FrameHeight - [numeric cell] frame height in pixels (may be negative to trim); {1} value, {2} limits [-Inf, Inf], {3} 'on' (integer)

    • .IntensityPadValue - [numeric cell] fill intensity when method is 'use the pad value'; {1} value, {2} limits [0, Inf], {3} 'off'

    • .Method - [cell] one of: {'use the pad value'}, {'replicate'}, {'circular'}, {'symmetric'}

    • .Direction - [cell] one of: {'both'}, {'pre'}, {'post'}

    • .showWaitbar - [logical] show progress dialog (default: true)

  • parentFigure (optional) - handle to the parent figure for the progress dialog; pass [] to suppress the progress dialog

Output Arguments:

none

Usage:

Example 1 - add a 10-pixel symmetric frame

BatchOpt.FrameWidth = '10';
BatchOpt.FrameHeight = '10';
BatchOpt.IntensityPadValue = '0';
BatchOpt.Method = {'use the pad value'};
BatchOpt.Direction = {'both'};
BatchOpt.showWaitbar = true;
obj.mibModel.I{id}.addFrame(BatchOpt, obj.mibModel.mibGUI);
addFrameToImage(BatchOpt, parentFigure)

ADDFRAMETOIMAGE - Add a frame to the dataset by specifying new absolute width and height.

Syntax:
obj.addFrameToImage(BatchOpt, parentFigure)

Ported from MIB2 @mibImage/addFrameToImage.m.

Input Arguments:
  • BatchOpt - [struct] parameters for the frame operation:

    • .Position - [cell] one of: {'Center'}, {'Left-upper corner'}, {'Center-top'}, {'Right-upper corner'}, {'Left-bottom corner'}, {'Center-bottom'}, {'Right-bottom corner'}

    • .NewImageWidth - [numeric cell] new image width in pixels; {1} value, {2} limits [1, Inf], {3} 'on' (integer)

    • .NewImageHeight - [numeric cell] new image height in pixels; {1} value, {2} limits [1, Inf], {3} 'on' (integer)

    • .FrameColorIntensity - [numeric cell] fill intensity for the frame pixels; {1} value, {2} limits [0, Inf], {3} 'off'

    • .showWaitbar - [logical] show progress dialog (default: true)

  • parentFigure (optional) - handle to the parent figure for the progress dialog; pass [] to suppress the progress dialog

Output Arguments:

none

Usage:

Example 1 - add a frame centering the image in 600×500

BatchOpt.Position = {'Center'};
BatchOpt.NewImageWidth = '600';
BatchOpt.NewImageHeight = '500';
BatchOpt.FrameColorIntensity = '0';
BatchOpt.showWaitbar = true;
obj.mibModel.I{id}.addFrameToImage(BatchOpt, obj.mibModel.mibGUI);
addMaterial(materialName, newMaterialIndex, wb)

ADDMATERIAL - Add a material to the model - low-level data layer.

Syntax:
[result, newMaterialIndex] = obj.addMaterial(materialName)
[result, newMaterialIndex] = obj.addMaterial(materialName, newMaterialIndex)
[result, newMaterialIndex] = obj.addMaterial(materialName, newMaterialIndex, wb)

Creates the model when it does not yet exist. For small model types (63/255) the new name is appended to the materialNames list and a colour row is generated. For large model types (65535/4294967295) the next unused index is found by rescanning the pixel data for the highest label currently in use (unless the caller supplies it via newMaterialIndex), capacity is verified, and the new index is registered.

In all cases obj.labels.materialsCount is incremented by 1 on success.

Input Arguments:
  • materialName (optional) - [char] name for the new material (default: 'NewMaterial'):

    • For types 63/255 - human-readable label appended to the list

    • For types 65535/4294967295 - overridden with string representation of the assigned index

  • newMaterialIndex (optional) - [double] next unused 1-based material index; when empty the method uses obj.labels.countMaterials() + 1, i.e. one above the highest label present in the data. With 2D objects (obj.labels.objects3D false) it is one above the highest label on the shown XY slice instead, and only that slice is read - the numbering of such a model restarts on every slice. Ignored for types 63/255

  • wb (optional) - [uiprogressdlg] handle to a progress dialog for displaying progress; when empty no progress is reported

Output Arguments:
  • result - [logical] true on success; false when the model is full (capacity exceeded)

  • newMaterialIndex - [double] material index that was actually assigned; relevant for large model types (65535/4294967295); empty for small types (63/255)

Example 1 - Add material to a small model (type 63/255):

obj.addMaterial('Nucleus');

Example 2 - Add material to a large model with auto-indexing:

[ok, idx] = obj.addMaterial('', [], wb);
allocateMask()

ALLOCATEMASK - allocate a zero-filled Mask layer when it is missing.

For datasets with a MibLabels63 model the mask is stored in bit 7 of the packed labels array and needs no separate container - the method returns without action. For all other model types, when obj.mask is an empty placeholder (obj.mask.exists == false) it is replaced with a zero-filled core.MibLabels container matching the image dimensions, so the mask can be read and written via getData/setData without size-mismatch errors. Sets obj.maskExist = true after allocation.

Syntax:
obj.allocateMask()
Input Arguments:

(none)

Output Arguments:

(none)

Usage:
% ensure the mask container exists before adding data to it
obj.mibModel.I{id}.allocateMask();
applySizeMismatch(rawArray, imgH, imgW, action, offsetY, offsetX)

APPLYSIZEMISMATCH - Crop/place or resize a Model/Mask array to [imgH, imgW].

Syntax:
outArray = core.MibDataset.applySizeMismatch(rawArray, imgH, imgW, action, offsetY, offsetX)

Pure data transform (no dialogs, no obj state) used by core.MibDataset.loadModel and core.MibDataset.loadMask after the user (or the unattended/batch fallback) has decided how to resolve a Model/Mask size mismatch against the currently open image.

Input Arguments:
  • rawArray - [numeric|logical] Model/Mask array; the first two dimensions are height/width. Any number of trailing dimensions (depth, time, …) are carried through unchanged.

  • imgH, imgW - [numeric] target height/width (the open image’s).

  • action - [char] 'Crop' or 'Resize'.

  • offsetY, offsetX - [numeric] non-negative pixel offsets, only used when action == 'Crop'. Meaning depends on which side is bigger on that axis: when the source is bigger, the offset selects where the crop window starts within the source; when the source is smaller, it selects where the data is placed within the destination. Callers are expected to keep these within [0, abs(imgSize - itemSize)] so the item stays fully inside the larger of the two - this function does not clamp or validate them.

Output Arguments:
  • outArray - array of size [imgH, imgW, <trailing dims>], same class as rawArray.

Usage:

Example 1 - crop/place with an offset

outArray = core.MibDataset.applySizeMismatch(rawModel, imgH, imgW, 'Crop', offsetY, offsetX);

Example 2 - resize (nearest-neighbor, preserves label/mask values)

outArray = core.MibDataset.applySizeMismatch(rawModel, imgH, imgW, 'Resize', 0, 0);
buildInstanceIndex(options, wb)

BUILDINSTANCEINDEX - Build or refresh the cached per-object index of the instance model.

Syntax:
index = obj.buildInstanceIndex()
index = obj.buildInstanceIndex(options)
[index, cancelled] = obj.buildInstanceIndex(options, wb)

Reads the labels layer of one time point and hands it to utils.instances.objectIndex, storing the result in obj.instanceIndex. The index is what lets controllers.InstanceEditor answer “where is object N” without a volume scan, and what confines every edit to one bounding box.

The whole volume is read with the fast path of getData3D (Standard dataset, XY orientation, all materials, no block mode), which returns a copy-on-write alias of the labels array rather than a copy. Nothing here writes to it.

Input Arguments:
  • options - (optional) structure:

    • .timePoint - time point to index (default: the currently shown one). The index describes one time point at a time; the field is recorded in the returned struct so a caller can tell when it no longer applies

    • .objectIds - refresh only these objects in the existing obj.instanceIndex instead of rebuilding (default: [] = full build). Ignored when there is no index yet, or when it belongs to a different time point, in which case a full build is done instead

    • .bbox - [yMin yMax xMin xMax zMin zMax] region the edit changed, passed through to utils.instances.objectIndex

    • .previousCrop - labels of .bbox as they were before the edit (default: []). Makes the refresh a difference over the whole slices bbox(5):bbox(6), which never reads the rest of the volume - see previousSlices of utils.instances.objectIndex, built here by putting this crop back into the current slices. The edit must not have changed anything outside .bbox. This is how a 2-D edit stays at the cost of one slice when its objects span the stack, as they do on an unstitched model; such a refresh never narrows a bounding box

    • .computeSliceCount - fill .sliceCount (default: true)

  • wb - (optional) handle of a caller-owned cancelable uiprogressdlg, or [].

Output Arguments:
  • index - the index structure, also stored in obj.instanceIndex. It carries two fields this method owns on top of the utility’s:

    • .timePoint - the time point it describes

    • .stale - always false on return. Set it to true from outside when the model is edited by anything other than the editor

    Empty when the model is missing or the run was cancelled.

  • cancelled - logical, true when the user pressed Cancel. obj.instanceIndex is then left as it was rather than replaced by a partial index.

Usage:

Example 1 - build the index for the shown time point

index = obj.mibModel.I{id}.buildInstanceIndex();

Example 2 - refresh two objects after an edit

refreshOptions.objectIds = [7, 12];
refreshOptions.bbox = [120 180 300 420 4 19];
obj.mibModel.I{id}.buildInstanceIndex(refreshOptions);

See also: utils.instances.objectIndex, models.MibModel.editInstanceObjects

clearLayer(layer, y, x, z, t, blockModeSwitch)

CLEARLAYER - Clear data from a layer (wrapper for layer-specific clear methods).

Syntax:
obj.clearLayer(layer)
obj.clearLayer(layer, y, x, z, t)
obj.clearLayer(layer, y, x, z, t, blockModeSwitch)

Routes to obj.labels.clearLayer for core.MibLabels63 or obj.(layer).clearLayer for other types.

Input Arguments:
  • layer - [char] target layer to clear:

    • 'selection' or [] - clear the selection layer (default)

    • 'mask' - clear the mask layer

    • 'labels' - clear the labels layer

    • 'everything' - clear selection, mask, labels layers (core.MibLabels63 only)

    • 'image' - clear the image layer

  • y (optional) - [numeric or char] y-coordinates or clear mode:

    • [] - clear complete dataset in '4D' mode (default)

    • [minY, maxY] - numeric vector of Y-min and Y-max

    • '2D' - clear current slice only

    • '3D' - clear full z-stack at current time

    • '4D' - clear entire 4D dataset

  • x (optional) - [numeric] X-min and X-max values [minX, maxX]; [] for full range

  • z (optional) - [numeric] Z-min and Z-max values [minZ, maxZ]; [] for full range

  • t (optional) - [numeric] T-min and T-max values [minT, maxT]; [] for full range

  • blockModeSwitch (optional) - [logical] enable/disable block mode:

    • [] - use currently selected value obj.blockModeSwitch (default)

    • true - enable block mode; clear only the shown area

    • false - disable block mode; clear the full dataset

Output Arguments:

Example 1 - Clear the selection layer completely:

obj.clearLayer('selection');

Example 2 - Clear only the current 2D slice:

obj.clearLayer('selection', '2D');

Example 3 - Clear with block mode enabled (visible area only):

obj.clearLayer('selection', '4D', [], [], [], true);
closeVirtualDataset()

CLOSEVIRTUALDATASET - Close virtual dataset readers to release file locks.

Syntax:
obj.closeVirtualDataset()

Closes all opened virtual dataset readers. Necessary to release file locks on virtual datasets before closing or switching datasets. No effect if the dataset is not a virtual image (core.MibVirtualImage instance).

Input Arguments:

(none)

Output Arguments:

(none)

convertModel(newType, wb)

CONVERTMODEL - Convert the segmentation model to a different storage type.

Syntax:
obj.convertModel(newType)
obj.convertModel(newType, wb)

Converts the pixel data and layer objects between the packed type-63 representation (core.MibLabels63) and the separate-layer representations (core.MibLabels, types 255 / 65535 / 4294967295). Also performs connected-component labelling to generate indexed-object models (types 2.4, 2.8, 3.6, 3.26).

Type-63 models store material, mask, and selection in a single uint8 array (bits 1-6 = material index 0-63, bit 7 = mask, bit 8 = selection). Converting to a higher type unpacks these bits into separate layer objects. Converting back packs them again.

Input Arguments:
  • newType - numeric target model type:

    • 63 - packed uint8 (core.MibLabels63)

    • 255 - separate uint8 labels (core.MibLabels)

    • 65535 - separate uint16 labels (core.MibLabels)

    • 4294967295 - separate uint32 labels (core.MibLabels)

    • 2.4 - 2D connected components, connectivity 4

    • 2.8 - 2D connected components, connectivity 8

    • 3.6 - 3D connected components, connectivity 6

    • 3.26 - 3D connected components, connectivity 26

    The result records how its objects are numbered in labels.objects3D: false for 2.4/2.8 (the labelling restarts on every slice), true for 3.6/3.26 and for 63/255 converted to 65535 or 4294967295 (a material spans the volume), and kept as it was between 65535 and 4294967295

  • wb (optional) - uiprogressdlg handle; pass [] to skip progress reporting

Output Arguments:

(none)

Example 1 - convert to 255-material type

obj.convertModel(255);

Example 2 - detect 2D connected components (connectivity 8)

obj.convertModel(2.8);
convertPixelIdxListCrop2Full(PixelIdxListCrop, options)

CONVERTPIXELIDXLISTCROP2FULL - Convert PixelIdxList of a cropped sub-volume to the full dataset.

Syntax:
PixelIdxList = obj.convertPixelIdxListCrop2Full(PixelIdxListCrop, options)
Input Arguments:
  • PixelIdxListCrop - vector of linear indices within the cropped sub-volume (column-major order: Y varies fastest, then X, then Z)

  • options - struct with crop-region boundaries:

    • .y - [yMin, yMax] Y-extent of the cropped region (rows)

    • .x - [xMin, xMax] X-extent of the cropped region (columns)

    • .z - (optional) [zMin, zMax] Z-extent; when absent the current slice is used (XY orientation 3 only)

Output Arguments:
  • PixelIdxList - vector of linear indices in the full dataset

convertPixelsToUnits(x, y, z)

CONVERTPIXELSTOUNITS - [x, y, z] = convertPixelsToUnits(obj, x, y, z).

Syntax:
[x, y, z] = obj.convertPixelsToUnits(x, y, z)

Convert pixel coordinates to physical imaging units using pixSize and boundingBox.

Input Arguments:
  • x - double, x-coordinate(s) in pixels

  • y - double, y-coordinate(s) in pixels

  • z - double, z-coordinate(s) in pixels

Output Arguments:
  • x - double, x-coordinate(s) in physical units (e.g. um)

  • y - double, y-coordinate(s) in physical units (e.g. um)

  • z - double, z-coordinate(s) in physical units (e.g. um)

Usage:

Example 1

[xU, yU, zU] = obj.mibModel.I{obj.mibModel.getActiveId()}.convertPixelsToUnits(xPx, yPx, zPx);
convertUnitsToPixels(x, y, z)

CONVERTUNITSTOPIXELS - [x, y, z] = convertUnitsToPixels(obj, x, y, z).

Syntax:
[x, y, z] = obj.convertUnitsToPixels(x, y, z)

Convert coordinates from physical imaging units to pixels using pixSize and boundingBox.

Input Arguments:
  • x - double, x-coordinate(s) in physical units (e.g. um)

  • y - double, y-coordinate(s) in physical units (e.g. um)

  • z - double, z-coordinate(s) in physical units (e.g. um)

Output Arguments:
  • x - double, x-coordinate(s) in pixels

  • y - double, y-coordinate(s) in pixels

  • z - double, z-coordinate(s) in pixels

Usage:

Example 1

[xPx, yPx, zPx] = obj.mibModel.I{obj.mibModel.getActiveId()}.convertUnitsToPixels(xU, yU, zU);
copyModelLayers()

COPYMODELLAYERS - Take an independent copy of the label, selection and mask layers.

Syntax:
snapshot = obj.copyModelLayers()

Returns deep copies of the three segmentation layer objects together with the flags that describe them. Unlike a pixel snapshot taken with core.MibDataset.getData3D(), this keeps the layer objects themselves - so the model type (63 / 255 / 65535 / 4294967295), the material names and colours and the selected material all travel with the snapshot.

This is what makes the 'modelLayers' undo entry immune to model-type changes: in a type-63 model the mask and selection live in bits 7-8 of obj.labels, in the larger types they are standalone layers, and a pixel snapshot taken under one arrangement cannot be written back under the other.

Only meaningful for 'Standard' datasets - the Virtual and BigData label layers are backed by on-demand readers that must not be duplicated.

Output Arguments:
  • snapshot - structure with fields labels, selection, mask (independent copies of the layer objects), maskExist, modelExist, selectedMaterial, selectedAddToMaterial

Example - snapshot the layers, then restore them

snapshot = obj.mibModel.I{1}.copyModelLayers();
% ... an operation that replaces obj.labels with a different model type
obj.mibModel.I{1}.restoreModelLayers(snapshot);

See also core.MibDataset.restoreModelLayers()

copySlice(sliceFrom, sliceTo, orient)

COPYSLICE - Copy slice(s) from one position to another in all image layers.

Syntax:
result = obj.copySlice(sliceFrom, sliceTo, orient)

Orchestrates a within-dataset slice copy across all active layers: the primary image, labels (model), mask, and selection. Delegates actual array manipulation to core.MibImage.copySlice for each layer. The dataset size does not change; this is an in-place overwrite of the destination slice with the source slice contents.

Input Arguments:
  • sliceFrom - index or index vector of source slices

  • sliceTo - index or index vector of destination slices; must be the same length as sliceFrom

  • orient - (optional) dimension to operate on: 1 = height (y), 2 = width (x), 3 = depth (z), 5 = time (t). Default: obj.orientation

Output Arguments:
  • result - 1 on success, 0 on failure

Usage:

Example 1

result = obj.mibModel.I{id}.copySlice(3, 10);

Example 2

result = obj.mibModel.I{id}.copySlice([1,2], [5,6], 3);
createModel(modelType, modelMaterialNames)

CREATEMODEL - Create an empty model: allocate memory for a new model.

Syntax:
obj.createModel()
obj.createModel(modelType)
obj.createModel(modelType, modelMaterialNames)

This function reinitializes the labels layer (obj.labels) with a zero-filled matrix of the appropriate class and dimensions. When switching between the packed type-63 model (core.MibLabels63) and the separate-layer models (core.MibLabels, types 255/65535/4294967295), the selection and mask layers are converted automatically.

Input Arguments:
  • modelType (optional) - [numeric] model type (default: current model type):

    • 63 - packed type-63 model with up to 63 materials; ‘Labels’, ‘Mask’, and ‘Selection’ layers packed in single uint8 matrix (core.MibLabels63) to reduce memory

    • 255 - separate-layer type-255 model with up to 255 materials (core.MibLabels)

    • 65535 - large-capacity type-65535 model with up to 65535 materials

    • 4294967295 - very-large-capacity type-4294967295 model with up to 4294967295 materials

  • modelMaterialNames (optional) - [cell] cell array with names of materials; only used for model types 63 and 255; ignored for larger types

Output Arguments:

(none)

Example 1 - Create a type-63 model (memory-efficient):

obj.createModel(63);

Example 2 - Create a type-255 model with material names:

obj.createModel(255, {'Nucleus', 'Cytoplasm'});

Example 3 - Create a large-capacity type-65535 model:

obj.createModel(65535);
cropDataset(cropF, options)

CROPDATASET - Crop image and all corresponding layers of the opened dataset.

Syntax:
result = obj.cropDataset(cropF, options)

Orchestrates cropping across the image, labels, mask and selection layers, handles the Virtual → Standard conversion for virtual datasets, resets viewing coordinates, and updates the physical bounding box.

Input Arguments:
  • cropF - a vector [x1, y1, dx, dy, z1, dz, t1, dt] in pixels

    • x1, y1 - top-left corner of the crop region

    • dx, dy - width and height of the crop region

    • z1, dz - first slice index and number of slices

    • t1, dt - first time point and number of time points

    • when numel(cropF) < 7, t1 and dt default to [1, obj.image.time]

  • options - (optional) structure with additional parameters

    • .showWaitbar - logical, show a progress dialog (default: true)

    • .UIFigure - handle to the parent UIFigure for the progress dialog; when empty or absent the dialog is silently skipped

    • .pyramidLevel - numeric, OME-Zarr pyramid level for virtual datasets (default: 1)

The progress dialog is cancelable. Cancel is honoured up to the point where the Virtual/BigData buffer starts being rebuilt; past that the operation runs to the end rather than leaving a half-cropped dataset. The region read itself is a single uninterruptible call, so a cancel pressed during it takes effect when it returns.

Output Arguments:
  • result - 1 on success, 0 on cancel or error

Usage:

Example 1

result = obj.mibModel.I{obj.mibModel.id}.cropDataset([10 20 100 200 1 5 1 1]);% crop Standard dataset

Example 2

result = obj.mibModel.I{bufferId}.cropDataset(crop_factor, BatchOptLoc);% call from CropDataset controller
cropToBigData(cropF, options)

CROPTOBIGDATA - Crop a BigData dataset and write the result to a new Zarr pyramid.

Syntax:
result = obj.cropToBigData(cropF, options)

Reads the cropped image region from the source BigData (on-demand, only the crop footprint is loaded into memory), writes it as a new OME-Zarr v3 pyramid at options.outputPath via io.savers.Zarr3Saver (its bounding box is the source bounding box shifted to the crop origin, so the crop keeps its physical position), and copies the BigData model pyramid (if one exists) to a sibling file whose name is the same as the image output but with a Labels_ prefix:

  • image → options.outputPath (e.g. crop.zarr3)

  • model → <dir>/Labels_<stem><ext> (e.g. Labels_crop.zarr3)

Input Arguments:
  • cropF - a vector [x1, y1, dx, dy, z1, dz, t1, dt] in pixels

    • x1, y1 - top-left corner of the crop region

    • dx, dy - width and height of the crop region

    • z1, dz - first slice index and number of slices

    • t1, dt - first time point and number of time points

    • when numel(cropF) < 7, t1 and dt default to [1, obj.image.time]

  • options - (optional) structure with additional parameters

    • .outputPath - [char] path to the destination zarr folder (required)

    • .showWaitbar - logical, show a progress dialog (default: true)

    • .UIFigure - handle to the parent UIFigure for the progress dialog

The progress dialog is cancelable up to the point where the output store starts being written; past that the operation runs to the end rather than leaving a partial pyramid on disk. The region read is a single uninterruptible call, so a cancel pressed during it takes effect when it returns.

Output Arguments:
  • result - 1 on success, 0 on cancel or error

Usage:

Example

opts.outputPath  = 'C:\data\crop.zarr3';
opts.showWaitbar = true;
opts.UIFigure    = obj.view.gui;
result = obj.mibModel.I{id}.cropToBigData(crop_factor, opts);
deleteSlice(sliceNumbers, orient, options)

DELETESLICE - Delete specified slice(s) from the dataset across all layers.

Syntax:
result = obj.deleteSlice(sliceNumbers, orient)
result = obj.deleteSlice(sliceNumbers, orient, options)

Orchestrates deletion of slices from the primary image, labels (model), mask, and selection layers, then shifts annotation positions and updates dimension-related properties.

Input Arguments:
  • sliceNumbers - index or index vector of slices to delete

  • orient - (optional) dimension to operate on: 1 = height (y), 2 = width (x), 3 = depth (z), 5 = time (t). Default: obj.orientation

  • options - (optional) struct with fields:

    • .showWaitbar - logical; true (default) shows a progress waitbar

    • .ParentFigure - parent figure handle for the waitbar

Output Arguments:
  • result - 1 on success, 0 on failure

Usage:

Example 1

result = obj.mibModel.I{id}.deleteSlice(5, 3);  % delete z-slice 5

Example 2

result = obj.mibModel.I{id}.deleteSlice([2,5,8], 3);  % delete multiple z-slices

Example 3

result = obj.mibModel.I{id}.deleteSlice(1, 5);  % delete time-frame 1
flipDataset(mode, parentFigure, showWaitbar)

FLIPDATASET - Flip the dataset and all layers horizontally, vertically, along Z, or along T.

Syntax:
obj.flipDataset(mode, parentFigure, showWaitbar)

Ported from MIB2 @mibModel/flipDataset.m.

Input Arguments:
  • mode - [char] flipping mode:

    • 'Flip horizontally' - flip along the X (width) axis

    • 'Flip vertically' - flip along the Y (height) axis

    • 'Flip Z' - flip along the Z (depth) axis

    • 'Flip T' - reverse the time-point order

  • parentFigure (optional) - handle to the parent figure for the progress dialog; pass [] to suppress the progress dialog

  • showWaitbar (optional) - logical, true to show a progress dialog (default: true)

Output Arguments:

none

Usage:

Example 1 - flip horizontally from a MibModel context

id = obj.mibModel.getActiveId();
obj.mibModel.I{id}.flipDataset('Flip horizontally', obj.mibModel.mibGUI, true);
getAxesLimits()

GETAXESLIMITS - get axes limits for the dataset.

Syntax:
[axesX, axesY] = obj.getAxesLimits()

Input Arguments:

Output Arguments:
  • axesX - a vector [min, max] for the X

  • axesY - a vector [min, max] for the Y

Usage:

Example 1

[axesX, axesY] = obj.mibModel.I{obj.mibModel.id}.getAxesLimits();% call from mibController: get axes limits for the currently shown dataset

Example 2

[axesX, axesY] = obj.mibModel.I{2}.getAxesLimits();% call from mibController: get axes limits for dataset 2 (global index)
getCoordinatesOfShownImage(transposeTo3)

GETCOORDINATESOFSHOWNIMAGE - Return minimal and maximal coordinates (XY) of the image that is.

Syntax:
[yMin, yMax, xMin, xMax, zMin, zMax] = obj.getCoordinatesOfShownImage(transposeTo3)

currently shown.

Input Arguments:
  • transposeTo3 - - (optional) when true, transpose dataset to the orientation 3, when looking on the XY plane of the dataset false, do not transpose

Output Arguments:
  • yMin - - minimal Y coordinate

  • yMax - - maximal Y coordinate

  • xMin - - minimal Y coordinate

  • xMax - - maximal Y coordinate

  • zMin - - minimal Z coordinate

  • zMax - - maximal Z coordinate

Note: it is also possible to get coordinates from .slices field of mibImage class

Usage:

Example 1

[yMin, yMax, xMin, xMax] = obj.mibModel.I{obj.mibModel.id}.getCoordinatesOfShownImage();% get coordinates
getCurrentSliceNumber()

GETCURRENTSLICENUMBER - Get slice number of the currently shown image.

Syntax:
slice_no = obj.getCurrentSliceNumber()

Input Arguments:

Output Arguments:
  • slice_no - index of the currently shown slice

Usage:

Example 1

slice_no = obj.mibModel.I{obj.mibModel.id}.getCurrentSliceNumber();% Call from MibController
getCurrentTimePoint()

GETCURRENTTIMEPOINT - Get time point of the currently shown image.

Syntax:
timePnt = obj.getCurrentTimePoint()

Input Arguments:

Output Arguments:
  • timePnt - index of the currently shown slice

Usage:

Example 1

timePnt = obj.mibModel.I{obj.mibModel.id}.getCurrentTimePoint();% get the time point
getData2D(type, slice_no, orient, col_channel, options)

GETDATA2D - Get the a 2D slice with colors: height:width:colors.

Syntax:
dataset = obj.getData2D(type, slice_no, orient, col_channel, options)
Input Arguments:
  • type - type of the dataset layer to retrieve:

    • 'image' - [default] the image layer

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer, supporting segmentation

    • 'selection' - selection layer, a temporary layer for segmentation

    • 'everything' - ('model', 'mask' and 'selection' for obj.labels.maxMaterials == 63 only)

  • slice_no - [optional, can be []], an index of the slice to get:

    • [] - get the current slice (default)

    • any index - get slice with that index at the current time point (use options to define the time point)

  • orient - [optional, can be []]

    • [] - returns transposed dataset in the currently shown orientation (default)

    • 1 - returns transposed dataset in the zx configuration: [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - returns transposed dataset in the zy configuration: [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - returns the original dataset in the yx configuration: [y,x,z,c,t]

  • col_channel - [optional] color channel(s) to retrieve; can be [] or NaN:

    • when type is 'image': a vector of color channel indices:

      • [] - (default) take color channels from obj.slices{4}

      • NaN - take all color channels of the dataset

      • index - get specific color channel(s) with provided index(s)

    • when type is 'labels': the material selection:

      • [] - (default) take all materials of the model

      • NaN - take all materials of the model

      • index - get specific material; the selected material will have index = 1

  • options - (optional), a structure with extra parameters

    • .blockModeSwitch [logical] override the block mode switch obj.blockModeSwitch; use or not the block mode (false - return full dataset, true - return only the shown part)

    • .roiId [integer] use or not the ROI mode when missing or less than 0, return full dataset, without ROI when [] - currently selected when 0 - return all ROIs of the dataset when Index - return ROI with the index (Attention: see also fillBg parameter!)

    • .fillBg filling color for ROI when NaN (default) crops the dataset as a rectangle; when a number fills the areas out of the ROI area with this intensity number

    • .y (optional), [ymin, ymax] of the part of the slice to take (sets .blockModeSwitch to 0)

    • .x (optional), [xmin, xmax] of the part of the slice to take (sets .blockModeSwitch to 0)

    • .t (optional), [tmin, tmax] indicate the time point to take, when missing return the currently selected time point

    • .level (optional), an index of image level from the image pyramid

Output Arguments:
  • dataset - a cell array with 2D image with colors. For the ‘image’ type: {roiId}[1:height, 1:width, 1:colors]; for all other types: {roiId}[1:height, 1:width]

Usage:

Example 1

slice = obj.mibModel.I{obj.mibModel.id}.getData2D('image', 5);% Call from mibController: get the 5-th slice of the current stack orientation

Example 2

slice = obj.mibModel.I{obj.mibModel.id}.getData2D('image', 5, 3, 2);% Call from mibController:  get the 5-th slice of the XY-orientation, color channel=2

Attention: sensitive to the obj.cQuickAccessBar.view.handles.blockMode; to override the blockMode use options.blockModeSwitch=false

Attention: NOT sensitive to the shown ROI (obj.cQuickAccessBar.view.handles.roiMode), if areas under ROIs are required use options.roiId and options.fillBg parameters

getData3D(type, time, orient, col_channel, options)

GETDATA3D - Get the a 3D dataset with colors: height:width:depth:colors.

Syntax:
dataset = obj.getData3D(type, time, orient, col_channel, options)
Input Arguments:
  • type - type of the dataset layer to retrieve:

    • 'image' - [default] the image layer

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer, supporting segmentation

    • 'selection' - selection layer, a temporary layer for segmentation

    • 'everything' - ('model', 'mask' and 'selection' for obj.labels.maxMaterials == 63 only)

  • time - [optional, can be []], an index of the time point to get:

    • [] - get the current time point (default)

    • any index - get dataset with that time point

  • orient - [optional, can be []]

    • [] - returns transposed dataset in the currently shown orientation (default)

    • 1 - returns transposed dataset in the zx configuration: [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - returns transposed dataset in the zy configuration: [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - returns the original dataset in the yx configuration: [y,x,z,c,t]

  • col_channel - [optional] color channel(s) to retrieve; can be [] or NaN:

    • when type is 'image': a vector of color channel indices:

      • [] - (default) take color channels from obj.slices{4}

      • NaN - take all color channels of the dataset

      • index - get specific color channel(s) with provided index(s)

    • when type is 'labels': the material selection:

      • [] - (default) take all materials of the model

      • NaN - take all materials of the model

      • index - get specific material; the selected material in dataset will have index = 1

  • options - (optional), a structure with extra parameters

    • .blockModeSwitch [logical] override the block mode switch obj.blockModeSwitch; use or not the block mode (false - return full dataset, true - return only the shown part)

    • .roiId [integer] use or not the ROI mode when missing or less than 0, return full dataset, without ROI when [] - currently selected when 0 - return all ROIs of the dataset when Index - return ROI with the index (Attention: see also fillBg parameter!)

    • .fillBg filling color for ROI when NaN (default) crops the dataset as a rectangle; when a number fills the areas out of the ROI area with this intensity number

    • .y (optional), [ymin, ymax] of the part of the dataset to take (sets .blockModeSwitch to 0)

    • .x (optional), [xmin, xmax] of the part of the dataset to take (sets .blockModeSwitch to 0)

    • .z (optional), [zmin, zmax] of the part of the dataset to take (sets .blockModeSwitch to 0)

Output Arguments:
  • dataset - a cell array with 3D dataset with colors. For the ‘image’ type: {roiId}[1:height, 1:width, 1:depth, 1:colors]; for all other types: {roiId}[1:height, 1:width, 1:depth]

Usage:

Example 1

dataset = obj.mibModel.I{obj.mibModel.id}.getData3D('image');% Call from mibController: get the 4D dataset for the current time point, in the shown orientation

Example 2

dataset = obj.mibModel.I{obj.mibModel.id}.getData3D('image', 5, 3, 2);% Call from mibController: get the 4D dataset for the 5-th time point in the XY orientation

Attention: sensitive to the obj.cQuickAccessBar.view.handles.blockMode; to override the blockMode use options.blockModeSwitch=false

Attention: NOT sensitive to the shown ROI (obj.cQuickAccessBar.view.handles.roiMode), if areas under ROIs are required use options.roiId and options.fillBg parameters

getData4D(type, orient, col_channel, options)

GETDATA4D - Get the a 4D dataset with colors: [height:width:depth:colors:time].

Syntax:
dataset = obj.getData4D(type, orient, col_channel, options)
Input Arguments:
  • type - type of the dataset layer to retrieve:

    • 'image' - [default] the image layer

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer, supporting segmentation

    • 'selection' - selection layer, a temporary layer for segmentation

    • 'everything' - ('model', 'mask' and 'selection' for obj.labels.maxMaterials == 63 only)

  • orient - [optional, can be []]

    • [] - returns transposed dataset in the currently shown orientation (default)

    • 1 - returns transposed dataset in the zx configuration: [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - returns transposed dataset in the zy configuration: [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - returns the original dataset in the yx configuration: [y,x,z,c,t]

  • col_channel - [optional] color channel(s) to retrieve; can be [] or NaN:

    • when type is 'image': a vector of color channel indices:

      • [] - (default) take color channels from obj.slices{4}

      • NaN - take all color channels of the dataset

      • index - get specific color channel(s) with provided index(s)

    • when type is 'labels': the material selection:

      • [] - (default) take all materials of the model

      • NaN - take all materials of the model

      • index - get specific material; the selected material in dataset will have index = 1

  • options - (optional), a structure with extra parameters

    • .blockModeSwitch [logical] override the block mode switch obj.blockModeSwitch; use or not the block mode (false - return full dataset, true - return only the shown part)

    • .roiId [integer] use or not the ROI mode when missing or less than 0, return full dataset, without ROI when [] - currently selected when 0 - return all ROIs of the dataset when Index - return ROI with the index (Attention: see also fillBg parameter!)

    • .fillBg filling color for ROI when NaN (default) crops the dataset as a rectangle; when a number fills the areas out of the ROI area with this intensity number

    • .y (optional), [ymin, ymax] of the part of the dataset to take (sets .blockModeSwitch to 0)

    • .x (optional), [xmin, xmax] of the part of the dataset to take (sets .blockModeSwitch to 0)

    • .z (optional), [zmin, zmax] of the part of the dataset to take (sets .blockModeSwitch to 0)

    • .t (optional), [tmin, tmax] of the part of the dataset to take

Output Arguments:
  • dataset - a cell array with 4D image with colors. For the ‘image’ type: {roiId}[1:height, 1:width, 1:depth, 1:color, 1:time]; for all other types: {roiId}[1:height, 1:width, 1:depth, 1:time]

Usage:

Example 1

dataset = obj.mibModel.I{obj.mibModel.id}.getData4D('image');% Call from mibController: get the 4D dataset for the current time point, in the shown orientation

Example 2

dataset = obj.mibModel.I{obj.mibModel.id}.getData4D('image', 5, 3, 2);% Call from mibController: get the 4D dataset for the 5-th time point in the XY orientation

Attention: sensitive to the obj.cQuickAccessBar.view.handles.blockMode; to override the blockMode use options.blockModeSwitch=false

Attention: NOT sensitive to the shown ROI (obj.cQuickAccessBar.view.handles.roiMode), if areas under ROIs are required use options.roiId and options.fillBg parameters

getDatasetDimensions(type, orient, options)

GETDATASETDIMENSIONS - Get dimensions of the dataset.

Syntax:
varargout = obj.getDatasetDimensions(type, orient, options)
Input Arguments:
  • type - type of the dataset to retrieve dimensions, ‘image’ (default), ‘model’, ‘mask’, ‘selection’

  • orient - (optional), orientation of the returned dimensions:

    • [] - return dimensions in the current orientation (default)

    • 1 - dimensions transposed to the zx configuration: [y,x,z,c,t] → [z,x,y,c,t]

    • 2 - dimensions transposed to the zy configuration: [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - dimensions of the original yx configuration: [y,x,z,c,t]

  • options - (optional), a structure with extra parameters

    • .blockModeSwitch - 0 return dimensions of the full dataset, 1 return dimensions of the shown part only

    • .splitDims - logical:

      • true - (default) split dimensions into individual output variables (height, width, depth, color, time)

      • false - return a single array [height, width, depth, color, time]

Output Arguments:
  • height - height of the dataset

  • width - width of the dataset

  • depth - number of z-layers of the dataset

  • colors - vector of colors of the dataset

  • time - number of time points or vector with all those numbers when options.splitDims == true

Usage:

Example 1

[height width depth color time] = obj.mibModel.I{obj.mibModel.id}.getDatasetDimensions('image')% get dimensions of the complete dataset

Example 2

[height width depth color time] = obj.mibModel.I{obj.mibModel.id}.getDatasetDimensions('image', 1)% get dimensions of the transposed dataset

Attention: not sensitive to the shown ROI

getDisplayStretch(orient)

GETDISPLAYSTRETCH - Aspect-ratio stretch of the shown slice along the screen axes.

A slice is rendered with one image pixel per data pixel, then stretched on screen so that anisotropic voxels keep their physical proportions. The stretch is applied through the image XData/YData (see controllers.MibController.showImage()) and must be undone by every conversion between axes and data coordinates.

Exactly one screen axis is stretched, the one that carries Z in the ZX/ZY views:

  • 3 (YX): horizontal X relative to vertical Y, [pixSize.x / pixSize.y, 1]

  • 2 (ZY): horizontal Z relative to vertical Y, [pixSize.z / pixSize.y, 1]

  • 1 (ZX): vertical Z relative to horizontal X, [1, pixSize.z / pixSize.x]; ZX slices are [z, x] (rows = Z, columns = X, see core.MibImage.getData()), so X stays horizontal as in the other two views

Syntax:
[stretchX, stretchY] = obj.getDisplayStretch()
[stretchX, stretchY] = obj.getDisplayStretch(orient)
Input Arguments:
  • orient - (optional) [numeric] orientation 1 (ZX), 2 (ZY) or 3 (YX); [] or missing uses the current obj.orientation

Output Arguments:
  • stretchX - [double] axes units per data pixel along the horizontal axis

  • stretchY - [double] axes units per data pixel along the vertical axis

Usage:

Example 1 - stretch of the currently shown slice:

[stretchX, stretchY] = obj.mibModel.I{obj.mibModel.id}.getDisplayStretch();
getPixelIdxList(type, PixelIdxList, options)

GETPIXELIDXLIST - Get pixel values at a list of linear indices from the active dataset layer.

Syntax:
dataset = obj.getPixelIdxList(type, PixelIdxList, options) %#ok<INUSD>

Wrapper method on MibDataset that routes the read request to the correct layer object (obj.image, obj.labels, obj.mask, obj.selection) and then delegates to core.MibImage.getPixelIdxList.

Routing rules (mirror getData3D):
  • 'image' - routes to obj.image

  • 'labels' or 'model' - routes to obj.labels (returns [] when modelExist==0)

  • 'mask' - routes to obj.labels (MibLabels63) or obj.mask (MibLabels); returns [] when maskExist==0

  • 'selection' - routes to obj.labels (MibLabels63) or obj.selection (MibLabels)

  • 'everything' - routes to obj.labels (MibLabels63 only)

The PixelIdxList must be linear indices into the full 3D volume in XY orientation (i.e. as returned by bwconncomp / regionprops).

Input Arguments:
  • type - [char] layer type to read:

    • 'image' - pixel values from the image layer

    • 'labels' - material indices from the labels layer

    • 'model' - synonym for 'labels'

    • 'mask' - mask layer values (0/1)

    • 'selection' - selection layer values (0/1)

    • 'everything' - raw packed byte (MibLabels63 only)

  • PixelIdxList - [numeric] vector of linear pixel indices into the full dataset in XY orientation (standard MATLAB column-major order from bwconncomp / regionprops)

  • options (optional) - [struct] reserved for future use; currently unused

Output Arguments:
  • dataset - [numeric] column vector of values at the requested indices; returns [] when the layer does not exist (modelExist==0 or maskExist==0)

Example 1 - Query selection values inside connected component 1:

I = cell2mat(obj.mibModel.getData3D('mask'));
CC = bwconncomp(I, 26);
vals = obj.mibModel.I{id}.getPixelIdxList('selection', CC.PixelIdxList{1});

Example 2 - Read material indices for a set of pixels:

matIdx = obj.mibModel.I{id}.getPixelIdxList('labels', pixIdx);
getRoiBoundingBox(roiIndex)

GETROIBOUNDINGBOX - Return the bounding box for a ROI at its native orientation.

Syntax:
bb = obj.getRoiBoundingBox(roiIndex)

Wraps core.RoiRegion.getBoundingBox and maps the 4-element [xmin xmax ymin ymax] result to a 6-element vector [minX maxX minY maxY minZ maxZ] consistent with dataset pixel coordinates (X = columns, Y = rows, Z = depth).

The mapping depends on the orientation stored in the ROI:
  • 3 (YX plane) - X/Y from bounding box, Z spans 1 to full depth

  • 1 (ZX plane) - ROI X-axis = X, ROI Y-axis = Z; Y spans full height

  • 2 (ZY plane) - ROI X-axis = Z, ROI Y-axis = Y; X spans full width

Input Arguments:
  • roiIndex (optional) - [numeric] index of the ROI to query; when omitted, obj.selectedROI is used; when negative or empty, returns [] immediately

Output Arguments:
  • bb - [numeric] [minX maxX minY maxY minZ maxZ] in pixels, or [] when no ROI is selected

Example 1 - Get bounding box of the selected ROI:

bb = obj.getRoiBoundingBox();

Example 2 - Get bounding box of a specific ROI by index:

bb = obj.getRoiBoundingBox(2);
getSelectedMaterialIndex(target)

GETSELECTEDMATERIALINDEX - return the index of the currently selected material in the mibView.handles.materialsTable.

Syntax:
index = obj.getSelectedMaterialIndex(target)
Input Arguments:
  • target - a string specifying the target column of the materials table:

    • 'Material' - (default) the selected row in the material column

    • 'AddTo' - the selected row in the AddTo column

Output Arguments:
  • index - index of the currently selected material:

    • -1 - Mask

    • 0 - Exterior

    • 1 - 1st material of the model

    • 2, 3, … - 2nd, 3rd, … material of the model

Usage:

Example 1

selcontour = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex();% call from mibController class; return the index of the currently selected material

Example 2

selcontour = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex('AddTo');% call from mibController class; return the index of the currently selected material in the AddTo column
getSliceLabels(sliceNumber, timePoint, options)

GETSLICELABELS - [labelsList, labelValues, labelPositions, indices] = getSliceLabels(obj, sliceNumber, timePoint, options).

Syntax:
[labelsList, labelValues, labelPositions, indices] = obj.getSliceLabels(sliceNumber, timePoint, options)

Get list of labels (mibImage.annotations) shown at the specified slice

Input Arguments:
  • sliceNumber - (optional), a slice number to get labels

  • timePoint - (optional), a time point to get the labels

  • options - (optional), structure with additional parameters:

    • .blockModeSwitch - (optional), optionally return labels that are seen only in the current view

    • .shiftCoordinates - (optional), shift coordinates so that they are corrected relative to the crop introduces by blockModeSwitch

Output Arguments:
  • labelsList - a cell array with labels

  • labelPositions - a matrix with coordinates of the labels [labelIndex, z x y]

  • indices - indices of the labels

Usage:

Example 1

[labelsList, labelValues, labelPositions, indices] = obj.mibModel.I{obj.mibModel.id}.getSliceLabels(15);% call from mibController; get all labels from the slice 15

Example 2

[labelsList, labelValues, labelPositions, indices] = obj.mibModel.I{obj.mibModel.id}.getSliceLabels();% call from mibController;  get all labels from the currently shown slice
initialize(img, meta, datasetType, modelType, enableSelection)

INITIALIZE - init MibDataset class and set all elements of the class to default values.

Syntax:
obj.initialize(img, meta, datasetType, modelType, enableSelection)
Input Arguments:
  • img - matrix with the image to initialize the class, can be empty

  • meta - a dictionary with default settings for the class, can be empty; the following fields are used:

    • .filename - full path to the dataset

    • .sliceName - cell array with slice names, can be empty

    • .lutColors - matrix with LUT colors (colChannel × R G B) in range 0-1

    • .pixSize - structure with physical voxel size:

      • .x - physical width of a pixel

      • .y - physical height of a pixel

      • .z - physical thickness of a pixel

      • .t - time between the frames for 2D movies

      • .tunits - time units

      • .units - physical units for x, y, z; possible values: m, cm, mm, um, nm

    • .viewPort - structure with viewing parameters:

      • .min - vector with minimal value for intensity stretching per color channel

      • .max - vector with maximal value for intensity stretching per color channel

      • .gamma - vector with gamma factor for contrast adjustment per color channel

  • datasetType - [char] type of the dataset, one of:

    • 'Standard' - (default) standard image loaded to memory completely

    • 'Virtual' - virtual dataset loaded upon demand

    • 'BigData' - big-data compatible dataset

  • modelType - type of the labels layer; when empty, 'imageOnly' is used:

    • 'imageOnly' - (default) init with the provided image, keep other layers as NaN

    • 'labels' - init with model with 255 materials; obj.mask, obj.selection have the same dimensions as labels

    • 'labels63' - init with model with 63 materials; obj.mask, obj.selection are NaN

  • enableSelection - a logical (true/false) switch to enable/disable the selection layer; when false the labels container is left empty (obj.labels.exists == false) and no memory is allocated for it, so a browse-only dataset costs only the image itself. Turning the layer back on (Preferences -> Enable selection) allocates labels.data then

insertMaterial(materialIndex, materialName, wb)

INSERTMATERIAL - Insert a new material at the specified position - MibDataset wrapper.

Syntax:
obj.insertMaterial(materialIndex, materialName, wb)

Delegates to obj.labels.insertMaterial which handles both the pixel data shifting (via direct obj.data access) and the metadata update (names, colours, materialsCount).

Input Arguments:
  • materialIndex - double, 1-based position where the new material is inserted.

  • materialName - char, name of the new material (used for small models; ignored for large models).

  • wb - (optional) handle to a uiprogressdlg for progress display; when empty no progress is reported.

Output Arguments:

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.insertMaterial(3, 'Nucleus');% insert at position 3

Example 2

obj.mibModel.I{obj.mibModel.id}.insertMaterial(5, 'New', wb);% with progress bar
insertSlice(img, insertPosition, meta, options)

INSERTSLICE - Insert a slice or a dataset into the existing volume.

Syntax:
obj.insertSlice(img, insertPosition, meta, options)

This is the interactive wrapper: it handles user dialogs, a waitbar and annotation bookkeeping, then delegates the actual array manipulation to core.MibImage.insertSlice (standard) or core.MibVirtualImage.insertSlice (virtual) for the image layer, and to MibImage.insertSlice for each auxiliary layer (labels, mask, selection).

Input Arguments:
  • img - new 2D-5D image stack to insert, dimensions [height, width, depth, colors, time]

  • insertPosition - (optional) position where to insert the new slice/volume starting from 1. When omitted, NaN, or 0 - appends to the end

  • meta - (optional) dictionary with dataset parameters, used to retrieve 'SliceName' and 'SliceSize' entries for the inserted slices; can be []. When not provided and the dataset already has per-slice filenames, slice names are auto-generated from the neighboring slice name with an _empty_NNN suffix.

  • options - (optional) structure with additional parameters

    • .dim - string defining insertion dimension: ‘depth’ (default) or ‘time’

    • .BackgroundColorIntensity - background fill value for dimension mismatches

    • .silentMode - logical; when true no dialogs are shown

    • .showWaitbar - logical; true (default) shows a progress waitbar

    • .ParentFigure - handle to parent figure for dialog centering (default: [])

    • .mibPath - path to MIB installation directory

Output Arguments:

none

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.insertSlice(img, 1);% insert img at the beginning

Example 2

obj.mibModel.I{obj.mibModel.id}.insertSlice(img, NaN);% append img to the end

Example 3

options.dim = 'time'; obj.mibModel.I{obj.mibModel.id}.insertSlice(img, 1, [], options);
loadMask(filenames, options)

LOADMASK - Load a binary mask into this dataset from files or a raw array.

Syntax:
result = obj.loadMask(filenames, options)

Dataset-level orchestrator for mask loading. Called by MibModel.loadMask after BatchOpt processing, virtual-mode guarding, and file browsing are done.

FILE PATH - filenames is a cell array of full file paths.

.mask files are loaded with load(); other formats use LoaderFactory. Multiple files are stacked slice-by-slice into a 3D volume.

IMPORT PATH - options.mask contains the raw array. filenames is empty ([]).

After the array is obtained the method validates dimensions against the open image, binarises the data, rebuilds obj.mask as a new MibLabels instance, and sets obj.maskExist = true.

Input Arguments:
  • filenames - cell array of full file paths, or [] for the import path

  • options - struct with loading parameters

    • .mask - raw array to import (import path only)

    • .loaderType - 'matlab_mask' when loading .mask MAT files

    • .loaderInfo - struct from ExtensionRegistryLoad.resolveLoader (required for non-mask image formats)

    • .batchModeSwitch - [logical, false] suppress interactive dialogs

    • .preferences - MIB preferences struct

    • .ParentFigure - parent figure handle for dialogs

    • .mibPath - path to MIB installation directory

    • .showWaitbar - [logical, true] show progress dialog

Output Arguments:
  • result - struct (non-empty) on success; [] on error or user cancel

Usage:

Example 1 - file path

dsOpts.loaderType   = 'matlab_mask';
dsOpts.showWaitbar  = true;
dsOpts.ParentFigure = obj.mibGUI;
result = obj.mibModel.I{id}.loadMask({'C:\data\Mask_stack.mask'}, dsOpts);

Example 2 - import path

dsOpts.mask = myBinaryVolume;
result = obj.mibModel.I{id}.loadMask([], dsOpts);
loadModel(filenames, options)

LOADMODEL - Load a segmentation model into this dataset from files or a raw array.

Syntax:
result = obj.loadModel(filenames, options)

This is the dataset-level orchestrator for model loading. It is called by MibModel.loadModel after BatchOpt processing, virtual-mode guarding, and file browsing have been completed. It handles:

FILE PATH - filenames is a cell array of full file paths. Dispatches to the loader identified by options.loaderInfo.

IMPORT PATH - options.model contains the raw array (workspace import). filenames is empty ([]); the loader is bypassed entirely.

After the array is obtained the method validates dimensions against the open image, calls createModel(), writes the data, and populates all label metadata properties.

Input Arguments:
  • filenames - cell array with full file paths, or [] for the import path

  • options - struct with loading parameters

    • .loaderInfo - struct returned by ExtensionRegistryLoad.resolveLoader (required for the file path; ignored for import)

    • .model - raw array to import (import path only)

    • .modelMaterialNames - cell array of names for the import path

    • .modelMaterialColors - Nx3 RGB matrix for the import path

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

    • .labelText - annotation text cell array (or [])

    • .labelPosition - annotation positions (or [])

    • .labelValue - annotation values (or [])

    • .batchModeSwitch - [logical, {false}] suppress interactive dialogs

    • .preferences - MIB preferences struct (for color fallback)

    • .ParentFigure - parent figure handle for dialogs

    • .mibPath - path to MIB installation directory

    • .showWaitbar - [logical, {true}] show progress dialog

Output Arguments:
  • result - struct with loaded metadata, or [] on error or user cancel

    • .materialNames - cell array of material names

    • .materialColors - Nx3 RGB color matrix

    • .modelType - numeric type used

    • .labelsVariable - variable name

Usage:

Example 1

options.loaderInfo = obj.mibModel.extensionRegistryLoad.resolveLoader('file.model','Model','Default');
options.preferences = obj.mibModel.preferences;
result = obj.mibModel.I{obj.mibModel.id}.loadModel({'C:\data\Labels.model'}, options);

Example 2 - import path

% import path
options.model = myModelArray;
options.modelMaterialNames = {'Cell','Nucleus'};
result = obj.mibModel.I{obj.mibModel.id}.loadModel([], options);
moveMaskToModelDataset(action_type, options)

MOVEMASKTOMODELDATASET - Move the Mask layer to the Model layer for the full dataset.

Syntax:
obj.moveMaskToModelDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - a type of the desired action:

    • 'add' - add mask to the selected material (Add to)

    • 'remove' - remove mask from the model

    • 'replace' - replace the selected (Add to) material with mask

  • options - a structure with additional parameters

    • .contSelIndex - index of the Select from material

    • .contAddIndex - index of the Add to material

    • .selected_sw - [0/1] limit actions to the selected material only

Output Arguments:

Usage:

Example 1

options.contSelIndex = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex();
options.contAddIndex = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex('AddTo');
options.selected_sw = 0;
obj.mibModel.I{obj.mibModel.id}.moveMaskToModelDataset('add', options);% add mask to model

Attention: NOT sensitive to the blockModeSwitch

Attention: NOT sensitive to the shown ROI

moveMaskToSelectionDataset(action_type, options)

MOVEMASKTOSELECTIONDATASET - Move the Mask layer to the Selection layer for the full dataset.

Syntax:
obj.moveMaskToSelectionDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - a type of the desired action:

    • 'add' - add mask to selection

    • 'remove' - remove mask from selection

    • 'replace' - replace selection with mask

  • options - a structure with additional parameters

    • .contSelIndex - index of the Select from material

    • .contAddIndex - index of the Add to material

    • .selected_sw - [0/1] limit actions to the selected material only

Output Arguments:

Usage:

Example 1

options.contSelIndex = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex();
options.contAddIndex = obj.mibModel.I{obj.mibModel.id}.getSelectedMaterialIndex('AddTo');
options.selected_sw = 0;
obj.mibModel.I{obj.mibModel.id}.moveMaskToSelectionDataset('add', options);% add mask to selection

Attention: NOT sensitive to the blockModeSwitch

Attention: NOT sensitive to the shown ROI

moveModelToMaskDataset(action_type, options)

MOVEMODELTOMASKDATASET - Move the selected Material to the Mask layer for the full dataset.

Syntax:
obj.moveModelToMaskDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - [char] type of the desired action:

    • 'add' - add the selected material to mask

    • 'remove' - remove the selected material from mask

    • 'replace' - replace mask with the selected material

  • options - [struct] structure with additional parameters:

    • .contSelIndex - [numeric] index of the “Select from” material

    • .contAddIndex - [numeric] index of the “Add to” material%

Output Arguments:

(none)

Example - Move selected material to mask by adding:

options.contSelIndex = obj.getSelectedMaterialIndex();
options.contAddIndex = obj.getSelectedMaterialIndex('AddTo');
obj.moveModelToMaskDataset('add', options);

Note

This is a fast-path function that operates on complete 4D datasets only. It is not sensitive to blockModeSwitch or visible ROI selections.

moveModelToSelectionDataset(action_type, options)

MOVEMODELTOSELECTIONDATASET - Move the selected Material to the Selection layer for the full dataset.

Syntax:
obj.moveModelToSelectionDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - [char] type of the desired action:

    • 'add' - add the selected material to selection

    • 'remove' - remove the selected material from selection

    • 'replace' - replace selection with the selected material

  • options - [struct] structure with additional parameters:

    • .contSelIndex - [numeric] index of the “Select from” material

    • .contAddIndex - [numeric] index of the “Add to” material

    • .maskedAreaSw - [logical] limit actions to masked areas only (0 or 1)%

Output Arguments:

(none)

Example - Move selected material to selection by adding:

options.contSelIndex = obj.getSelectedMaterialIndex();
options.contAddIndex = obj.getSelectedMaterialIndex('AddTo');
options.maskedAreaSw = 0;
obj.moveModelToSelectionDataset('add', options);

Note

This is a fast-path function that operates on complete 4D datasets only. It is not sensitive to blockModeSwitch or visible ROI selections.

moveSelectionToMaskDataset(action_type, options)

MOVESELECTIONTOMASKDATASET - Move the Selection layer to the Mask layer for the full dataset.

Syntax:
obj.moveSelectionToMaskDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - [char] type of the desired action:

    • 'add' - add selection to mask

    • 'remove' - remove selection from mask

    • 'replace' - replace mask with selection

  • options - [struct] structure with additional parameters:

    • .contSelIndex - [numeric] index of the “Select from” material

    • .contAddIndex - [numeric] index of the “Add to” material

    • .selected_sw - [logical] limit actions to the selected material only (0 or 1)

    • .maskedAreaSw - [logical] limit actions to masked areas only (0 or 1)%

Output Arguments:

(none)

Example - Move selection to mask by adding:

options.contSelIndex = obj.getSelectedMaterialIndex();
options.contAddIndex = obj.getSelectedMaterialIndex('AddTo');
options.selected_sw = 0;
options.maskedAreaSw = 0;
obj.moveSelectionToMaskDataset('add', options);

Note

This is a fast-path function that operates on complete 4D datasets only. It is not sensitive to blockModeSwitch or visible ROI selections.

moveSelectionToModelDataset(action_type, options)

MOVESELECTIONTOMODELDATASET - Move the Selection layer to the Model layer for the full dataset.

Syntax:
obj.moveSelectionToModelDataset(action_type, options)

Fast-path function for moving complete datasets between layers without ROI or block mode. Operates directly on packed data arrays for maximum performance.

Input Arguments:
  • action_type - a type of the desired action:

    • 'add' - add selection to the selected material (Add to)

    • 'remove' - remove selection from the model

    • 'replace' - replace the selected (Add to) material with selection

  • options - [struct] structure with additional parameters:

    • .contSelIndex - [numeric] index of the “Select from” material

    • .contAddIndex - [numeric] index of the “Add to” material

    • .selected_sw - [logical] limit actions to the selected material only (0 or 1)

    • .maskedAreaSw - [logical] limit actions to masked areas only (0 or 1)%

Output Arguments:

(none)

Example - Move selection to model by adding:

options.contSelIndex = obj.getSelectedMaterialIndex();
options.contAddIndex = obj.getSelectedMaterialIndex('AddTo');
options.selected_sw = 0;
options.maskedAreaSw = 0;
obj.moveSelectionToModelDataset('add', options);

Note

This is a fast-path function that operates on complete 4D datasets only. It is not sensitive to blockModeSwitch or visible ROI selections.

moveView(x, y, orient)

function moveView(obj, x, y, orient) Center the image view at the provided coordinates: x, y

Syntax:
obj.moveView(x);
obj.moveView(x, y);
obj.moveView(x, y, orient);
Description:

Pans the image display so that the given pixel coordinate (x, y) becomes the center of the visible axes area. The current zoom level and axes span are preserved - only the center position shifts.

When only a single value is provided for x, it is treated as a linear pixel index into the dataset at the given orientation. The corresponding (y, x) coordinates are then derived via ind2sub using the full dataset dimensions (blockModeSwitch = 0).

Input Arguments:
  • obj - handle to the MibDataset model object

  • x - X coordinate of the desired view center in pixels, or a linear pixel index when y is omitted or NaN

  • y - (optional) Y coordinate of the desired view center in pixels. Use NaN or omit to treat x as a linear index. Default: NaN

  • orient - (optional) orientation of the input coordinates. Default: obj.orientation (currently displayed orientation). Supported values:

    • 0 - current orientation (same as obj.orientation)

    • 1 - ZX plane

    • 2 - ZY plane

    • 3 - XY plane

Usage:

Example 1 - Center view on pixel (50, 75) in the current orientation:

obj.mibModel.I{obj.mibModel.id}.moveView(50, 75);

Example 2 - Center view using a linear pixel index (pixel 3820):

obj.mibModel.I{obj.mibModel.id}.moveView(3820);

Example 3 - Center view on pixel (100, 200) in the XY plane:

obj.mibModel.I{obj.mibModel.id}.moveView(100, 200, 3);

Example 4 - Center view on a point known in ZX orientation:

obj.mibModel.I{obj.mibModel.id}.moveView(64, 32, 1);
promptSizeMismatch(itemLabel, curH, curW, imgH, imgW, boundingBox, options)

PROMPTSIZEMISMATCH - Ask the user how to resolve a Model/Mask size mismatch.

Syntax:
choice = obj.promptSizeMismatch(itemLabel, curH, curW, imgH, imgW, boundingBox, options)

Builds and shows a single utils.dlgs.inputUniversalDlg with an action dropdown and, only for axes that actually mismatch, Y/X offset spinners shown alongside it (not a multi-step wizard - the spinner values are simply unused by the caller when the chosen action doesn’t need them).

Input Arguments:
  • itemLabel - [char] 'Model' or 'Mask', used in dialog text.

  • curH, curW - [numeric] height/width of the loaded item.

  • imgH, imgW - [numeric] height/width of the open image.

  • boundingBox - [numeric|[]] the loaded model’s 6-element [xmin xmax ymin ymax zmin zmax], or [] when unavailable (masks never have one). When non-empty, a 'Use bounding box' action is offered as the default choice.

  • options - struct with .ParentFigure and .mibPath.

Output Arguments:
  • choice - struct with fields:

    • .action - [char] 'Use bounding box', 'Crop / Place', or 'Resize'

    • .offsetY, .offsetX - [numeric] only meaningful when .action == 'Crop / Place'; 0 otherwise

    • .cancelled - [logical] true when the dialog was cancelled

removeMaterial(materialIndices, wb)

REMOVEMATERIAL - Remove materials from the model - low-level data layer.

Syntax:
obj.removeMaterial(materialIndices, wb)

Modifies pixel data across all time-points and then updates the model metadata (materialNames, materialColors, selection state).

For types 63 and 255 the remaining materials are remapped to contiguous indices 1..N and the corresponding name/colour entries are deleted.

For types 65535 and 4294967295 the pixels belonging to the removed materials are zeroed out. The materialNames and materialColors arrays are indexed directly by material value, so row-deletion would shift colours of unrelated materials; they are therefore left unchanged.

Input Arguments:
  • materialIndices - double vector, 1-based indices of materials to remove. Must already be validated by the caller (MibModel.removeMaterial).

  • wb - (optional) handle to a uiprogressdlg used for progress display; when empty no progress is reported.

Output Arguments:

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.removeMaterial([2 4]);% remove materials 2 and 4

Example 2

obj.mibModel.I{obj.mibModel.id}.removeMaterial([1 3], wb);% with progress bar
reorderMaterials(newOrder, wb)

REORDERMATERIALS - Reorder materials in the model - low-level data layer.

Syntax:
obj.reorderMaterials(newOrder, wb)

Remaps pixel values according to newOrder across every time-point. Only supported for small models (maxMaterials < 256). The mapping is built so that pixel value newOrder(k) becomes k for k = 1..N. After remapping, material names and colours are reordered via obj.labels.reorderMaterials.

Input Arguments:
  • newOrder - double vector, permutation of 1:numel(materialNames) specifying the desired arrangement. For example [3 1 2] means: old material 3 becomes new material 1, old 1 becomes new 2, old 2 becomes new 3.

  • wb - (optional) handle to a uiprogressdlg for progress display; when empty no progress is reported.

Output Arguments:

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.reorderMaterials([3 1 2]);% rotate materials

Example 2

obj.mibModel.I{obj.mibModel.id}.reorderMaterials([2 1 3], wb);% swap first two, with progress
resliceDataset(sliceNumbers, orient, options)

RESLICEDATASET - Keep only specified slices, removing all others from all layers.

Syntax:
result = obj.resliceDataset(sliceNumbers, orient)
result = obj.resliceDataset(sliceNumbers, orient, options)

Orchestrates stride-reslicing of the primary image, labels (model), mask, and selection layers, then updates dimension-related properties.

Input Arguments:
  • sliceNumbers - index or index vector of slices to keep; all other slices are removed

  • orient - (optional) dimension to operate on: 1 = height (y), 2 = width (x), 3 = depth (z), 5 = time (t). Default: obj.orientation

  • options - (optional) struct with fields:

    • .showWaitbar - logical; true (default) shows a progress waitbar

    • .ParentFigure - parent figure handle for the waitbar

Output Arguments:
  • result - 1 on success, 0 on failure

Usage:

Example 1

result = obj.mibModel.I{id}.resliceDataset(1:2:end, 3);  % keep every other z-slice

Example 2

result = obj.mibModel.I{id}.resliceDataset([1,5,10,20], 3);  % keep 4 specific z-slices
restoreModelLayers(snapshot)

RESTOREMODELLAYERS - Put back label, selection and mask layers taken with copyModelLayers.

Syntax:
obj.restoreModelLayers(snapshot)

Replaces the three segmentation layer objects with the copies held in snapshot, restoring the model type along with the pixel data. The snapshot is copied again on the way in, so the same entry can be restored more than once (undo → redo → undo) without the history and the live dataset ending up sharing the same handle objects.

Input Arguments:

Example

snapshot = obj.mibModel.I{1}.copyModelLayers();
obj.mibModel.I{1}.restoreModelLayers(snapshot);

See also core.MibDataset.copyModelLayers()

rotateDataset(mode, parentFigure, showWaitbar)

ROTATEDATASET - Rotate the dataset and all layers by 90 or -90 degrees.

Syntax:
obj.rotateDataset(mode, parentFigure, showWaitbar)

Ported from MIB2 @mibModel/rotateDataset.m.

Input Arguments:
  • mode - [char] rotation mode:

    • 'Rotate 90 degrees' - clockwise 90° rotation (height ↔ width swap)

    • 'Rotate -90 degrees' - counter-clockwise 90° rotation

  • parentFigure (optional) - handle to the parent figure for the progress dialog; pass [] to suppress the progress dialog

  • showWaitbar (optional) - logical, true to show a progress dialog (default: true)

Output Arguments:

none

Usage:

Example 1 - rotate 90° clockwise from a MibModel context

id = obj.mibModel.getActiveId();
obj.mibModel.I{id}.rotateDataset('Rotate 90 degrees', obj.mibModel.mibGUI, true);
saveImage(layerType, filename, options)

SAVEIMAGE - Save a data layer from a MibDataset to a file.

Syntax:
fnOut = obj.saveImage(layerType, filename, options)

This is the INTERMEDIATE-LEVEL save entry point. It sits between models.MibModel.saveImage() (which handles batch processing, filename policies and directory resolution) and the low-level core.MibImage.save() / core.MibLabels.save() methods.

Responsibilities of MibDataset.saveImage():
  1. Validate that the requested layer exists (e.g., mask must exist).

  2. Inject dataset-level metadata that the layer objects lack:

    • .pixSize - from obj.image.pixSize

    • .boundingBox - from obj.image.boundingBox

    • .layerType - for format-dispatch (AmiraMesh, HDF5, etc.)

  3. Delegate to the appropriate layer object:

    • 'image' - routes to obj.image.save(filename, options)

    • 'labels' - routes to obj.labels.save(filename, options)

    • 'mask' - directly assemble data + dispatch via SaverFactory (stored as raw numeric array, not MibImage subclass)

This method works WITHOUT a MibModel - it is the natural entry point for scripted pipelines that load or create a MibDataset object directly.

Input Arguments:
  • layerType - [char] which layer to save:

    • 'image' - pixel intensity data (obj.image)

    • 'labels' - segmentation model (obj.labels)

    • 'mask' - binary mask layer (obj.mask)

  • filename - [char] full output path including extension (e.g., '/data/stack.tif', 'C:\data\Labels_stack.model'); when [] or '', falls back to dataset’s own filename with appropriate prefix/suffix

  • options (optional) - [struct] passed through to the layer saver:

    • .Format - [char] format string; inferred from extension when absent

    • .Saving3DPolicy - [char] '3D stack' (default) or '2D sequence'

    • .showWaitbar - [logical] default true

    • .silent - [logical] default false

    • .overwrite - [logical] default true

    • .FilenameGenerator - [char] filename policy for 2-D sequences

    • .MaterialIndex - [numeric or []] for labels: [] = all materials, integer = single material

    • .Compression - [char] compression type (TIF/JPG)

    • .Quality - [numeric] JPEG quality 0-100

    • .ParentFigure - [handle] main MIB application window; injected automatically by MibModel.saveImage() when called from GUI; omit for standalone/scripted use

    • .mibPath - [char] path to MIB installation directory; used by savers for resource lookup; injected automatically by MibModel.saveImage()

    • .MaskColor - [numeric] mask overlay RGB colour [R G B] in range [0-1] (default: [1 0 1]); mask-specific

    • .annotations - [struct] with fields .labelText, .labelValue, .labelPosition to include annotation data in .model files; labels-specific

Output Arguments:
  • fnOut - [char or cell] saved path(s); [] on failure

Example 1 - Save image layer as a 3-D TIFF stack:

opts.Format         = 'TIF format uncompressed (*.tif)';
opts.Saving3DPolicy = '3D stack';
opts.showWaitbar    = false;
opts.silent         = true;
opts.overwrite      = true;
opts.ParentFigure   = obj.mibGUI;
opts.mibPath        = obj.mibPath;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('image', '/output/stack.tif', opts);
fprintf('Saved: %s\n', fnOut);

Example 2 - Save segmentation model in MIB native format:

opts.Format      = 'Matlab format (*.model)';
opts.showWaitbar = false;
opts.silent      = true;
opts.overwrite   = true;
opts.ParentFigure   = obj.mibGUI;
opts.mibPath        = obj.mibPath;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('labels', '/output/Labels_stack.model', opts);

Example 3 - Save binary mask as TIFF 2-D sequence:

opts.Format            = 'TIF format (*.tif)';
opts.Saving3DPolicy    = '2D sequence';
opts.FilenameGenerator = 'Use sequential filename';
opts.MaskColor         = [1 0 1];
opts.showWaitbar       = false;
opts.silent            = true;
opts.overwrite         = true;
opts.ParentFigure   = obj.mibGUI;
opts.mibPath        = obj.mibPath;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('mask', '/output/Mask_slice.tif', opts);

Example 4 - Save labels, export single material only:

opts.Format        = 'TIF format (*.tif)';
opts.MaterialIndex = 2;    % export material index 2 as binary 0/1
opts.showWaitbar   = false;
opts.silent        = true;
opts.overwrite     = true;
opts.ParentFigure   = obj.mibGUI;
opts.mibPath        = obj.mibPath;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('labels', '/output/Labels_mat2.tif', opts);

Example 5 - Save labels with annotations:

[lText, lValue, lPos] = dataset.annotations.getLabels();
opts.annotations.labelText     = lText;
opts.annotations.labelValue    = lValue;
opts.annotations.labelPosition = lPos;
opts.Format    = 'Matlab format (*.model)';
opts.overwrite = true;
opts.ParentFigure   = obj.mibGUI;
opts.mibPath        = obj.mibPath;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('labels', '/output/Labels_annotated.model', opts);

Example 6 - Fall back on dataset filename when none provided:

opts.Format    = 'Matlab format (*.mask)';
opts.overwrite = true;
fnOut = obj.mibModel.I{BatchOpt.id}.saveImage('mask', '', opts);
% Uses dataset.image.maskFilename or generates 'Mask_<imageName>.mask'

See also

core.MibImage.save, core.MibLabels.save, models.MibModel.saveImage, io.SaverFactory

setAxesLimits(axesX, axesY)

SETAXESLIMITS - set axes limits for the dataset.

Syntax:
obj.setAxesLimits(axesX, axesY)
Input Arguments:
  • axesX - a vector [min, max] for for X

  • axesY - a vector [min, max] for for Y

Output Arguments:

Usage:

Example 1

[axesX, axesY] = obj.mibModel.I{obj.mibModel.id}.setAxesLimits([1 512],  [1, 512]);% call from mibController: set axes limits for the currently shown dataset

Example 2

[axesX, axesY] = obj.mibModel.I{2}.setAxesLimits([1 512],  [1, 512]);% call from mibController: set axes limits for dataset 2
setData2D(dataset, type, slice_no, orient, col_channel, options)

SETDATA2D - set the 2D slice with colors: height:width:colors to the dataset.

Syntax:
result = obj.setData2D(dataset, type, slice_no, orient, col_channel, options)
Input Arguments:
  • dataset - [numeric or cell] 2D image with colors to set:

    • When options.roiId is not used (negative): numeric array or cell {1} with dimensions:

      • Image: [height, width, colors]

      • Other types: [height, width]

    • When options.roiId is used: cell array {roiId} with dimensions:

      • Image: [height, width, colors]

      • Other types: [height, width]

  • type - [char] layer type to set:

    • 'image' - image layer (default)

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer for segmentation support

    • 'selection' - selection layer (temporary segmentation layer)

    • 'everything' - packed data ('labels', 'mask', 'selection' for maxMaterials==63 only)

  • slice_no (optional) - [numeric or []] slice index to set:

    • [] - set the current slice (default)

    • integer - set slice at the specified index for current time point

  • orient (optional) - [numeric or []] orientation for dataset update:

    • [] - use currently shown orientation (default)

    • 1 - ZX plane: transpose [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - ZY plane: transpose [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - YX plane: native orientation [y,x,z,c,t]

  • col_channel (optional) - [numeric, [], or NaN] channel(s) or material(s) to update:

    • When type is 'image' (color channel indices):

      • [] - use channels from obj.slices{4} (default)

      • NaN - update all color channels

      • integer or vector - update specific channel(s)

    • When type is 'labels' (material selection):

      • [] or NaN - update all materials (default)

      • integer - update specific material (data with value 1 will get this material index)

  • options (optional) - [struct] additional parameters:

    • .blockModeSwitch - [logical] override block mode (false = full dataset, true = visible area only)

    • .roiId - [numeric or []] ROI mode control:

      • -1 or missing - full dataset without ROI (default)

      • [] - currently selected ROI

      • 0 - all ROIs

      • integer - specific ROI by index

    • .fillBg - [numeric or NaN] fill color for ROI background:

      • NaN - crop to rectangular ROI bounding box (default)

      • number - fill areas outside ROI with this intensity

    • .y (optional) - [numeric] [ymin, ymax] of slice region to set

    • .x (optional) - [numeric] [xmin, xmax] of slice region to set

    • .t (optional) - [numeric] [tmin, tmax] time point range (default: current time point)

Output Arguments:
  • result - [logical] true on success, false on failure

Example 1 - Set the 5th slice of current stack orientation:

result = obj.setData2D(dataset, 'image', 5);

Example 2 - Set the 5th slice in XY orientation, color channel 2:

result = obj.setData2D(dataset, 'image', 5, 3, 2);

Note

This function is sensitive to obj.blockModeSwitch. To override block mode, use options.blockModeSwitch=false. It is not sensitive to visible ROI selections; to work with ROI areas, use options.roiId and options.fillBg parameters.

setData3D(dataset, type, time, orient, col_channel, options)

SETDATA3D - set the 3D dataset with colors: height:width:depth:colors to the dataset.

Syntax:
result = obj.setData3D(dataset, type, time, orient, col_channel, options)
Input Arguments:
  • dataset - [numeric or cell] 3D image with colors to set:

    • When options.roiId is not used (negative): numeric array or cell {1} with dimensions:

      • Image: [height, width, depth, colors]

      • Other types: [height, width, depth]

    • When options.roiId is used: cell array {roiId} with dimensions:

      • Image: [height, width, depth, colors]

      • Other types: [height, width, depth]

  • type - [char] layer type to set:

    • 'image' - image layer (default)

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer for segmentation support

    • 'selection' - selection layer (temporary segmentation layer)

    • 'everything' - packed data ('labels', 'mask', 'selection' for maxMaterials==63 only)

  • time (optional) - [numeric or []] time point index to set:

    • [] - set the current time point (default)

    • integer - set dataset at the specified time point

  • orient (optional) - [numeric or []] orientation for dataset update:

    • [] - use currently shown orientation (default)

    • 1 - ZX plane: transpose [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - ZY plane: transpose [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - YX plane: native orientation [y,x,z,c,t]

  • col_channel (optional) - [numeric, [], or NaN] channel(s) or material(s) to update:

    • When type is 'image' (color channel indices):

      • [] - use channels from obj.slices{4} (default)

      • NaN - update all color channels

      • integer or vector - update specific channel(s)

    • When type is 'labels' (material selection):

      • [] or NaN - update all materials (default)

      • integer - update specific material (data with value 1 will get this material index)

  • options (optional) - [struct] additional parameters:

    • .blockModeSwitch - [logical] override block mode (false = full dataset, true = visible area only)

    • .roiId - [numeric or []] ROI mode control:

      • -1 or missing - full dataset without ROI (default)

      • [] - currently selected ROI

      • 0 - all ROIs

      • integer - specific ROI by index

    • .fillBg - [numeric or NaN] fill color for ROI background:

      • NaN - crop to rectangular ROI bounding box (default)

      • number - fill areas outside ROI with this intensity

    • .y (optional) - [numeric] [ymin, ymax] of dataset region to set

    • .x (optional) - [numeric] [xmin, xmax] of dataset region to set

    • .z (optional) - [numeric] [zmin, zmax] of dataset region to set

    • .level (optional) - [numeric] image pyramid level index

    • .PixelIdxList (optional) - [numeric vector] pixel indices to update (XY orientation). When used, all other spatial parameters are ignored and dataset should be a vector. Not implemented for ‘image’ type

Output Arguments:
  • result - [logical] true on success, false on failure

Example 1 - Set 3D dataset for current time point in current orientation:

result = obj.setData3D(dataset, 'image');

Example 2 - Set 3D dataset for time point 5 in XY orientation:

result = obj.setData3D(dataset, 'image', 5, 3);

Example 3 - Set selection for time point 5 in ZX orientation, color channel 2:

result = obj.setData3D(dataset, 'selection', 5, 1, 2);

Example 4

dataset = obj.mibModel.I{obj.mibModel.id}.setData3D(dataset, 'image', dataset, [], 3);% Call from mibController: set the 4D dataset for the current time point in the XY orientation

Attention: sensitive to the obj.cQuickAccessBar.view.handles.blockMode; to override the blockMode use options.blockModeSwitch=false

Attention: NOT sensitive to the shown ROI (obj.cQuickAccessBar.view.handles.roiMode), if areas under ROIs are required use options.roiId and options.fillBg parameters

setData4D(dataset, type, orient, col_channel, options)

SETDATA4D - result = setData4D(obj, dataset, type, orient, col_channel, options).

Syntax:
result = obj.setData4D(dataset, type, orient, col_channel, options)

Set complete 4D dataset with colors [height:width:depth:colors:time]

Input Arguments:
  • dataset - 4D dataset with colors

  • if options.roiId is not used, slice can be either a cell for images ({1}[1:height, 1:width, 1:depth, 1:colors, 1:time]; for all other types: {1}[1:height, 1:width, 1:depth, 1:time]) or a matrix for images ([1:height, 1:width, 1:depth, 1:colors, 1:time]; for all other types: [1:height, 1:width, 1:depth, 1:time])

  • if options.roiId is used, slice should be a cell array ({roiId}[1:height, 1:width, 1:depth, 1:colors, 1:time]; for all other types: {roiId}[1:height, 1:width, 1:depth, 1:time])

  • type - type of the dataset layer to retrieve:

    • 'image' - [default] the image layer

    • 'labels' - labels layer with segmentation

    • 'mask' - mask layer, supporting segmentation

    • 'selection' - selection layer, a temporary layer for segmentation

    • 'everything' - ('model', 'mask' and 'selection' for obj.labels.maxMaterials == 63 only)

  • orient - [optional, can be []]

    • [] - updates transposed dataset in the currently shown orientation (default)

    • 1 - updates transposed dataset in the zx configuration: [y,x,z,c,t] → [z,x,y,c,t] (rows = Z, columns = X: X stays horizontal as in the yx view)

    • 2 - updates transposed dataset in the zy configuration: [y,x,z,c,t] → [y,z,x,c,t]

    • 3 - updates the original dataset in the yx configuration: [y,x,z,c,t]

  • col_channel - [optional] color channel(s) to update; can be [] or NaN:

    • when type is 'image': a vector of color channel indices:

      • [] - (default) update color channels from obj.slices{4}

      • NaN - update all color channels of the dataset

      • index - update specific color channel(s) with provided index(s)

    • when type is 'labels': the material selection:

      • [] - (default) update all materials of the model

      • NaN - update all materials of the model

      • index - update specific material; the selected material in slice will have index = 1

  • options - (optional), a structure with extra parameters

    • .blockModeSwitch [logical] override the block mode switch obj.blockModeSwitch; use or not the block mode (false - return full dataset, true - return only the shown part)

    • .roiId [integer] use or not the ROI mode when missing or less than 0, return full dataset, without ROI when [] - currently selected when 0 - return all ROIs of the dataset when Index - return ROI with the index (Attention: see also fillBg parameter!)

    • .fillBg filling color for ROI when NaN (default) crops the dataset as a rectangle; when a number fills the areas out of the ROI area with this intensity number

    • .y (optional), [ymin, ymax] coordinates of the dataset to take after transpose, height (sets .blockModeSwitch to 0)

    • .x (optional), [xmin, xmax] coordinates of the dataset to take after transpose, width (sets .blockModeSwitch to 0)

    • .z (optional), [zmin, zmax] coordinates of the dataset to take after transpose, depth (sets .blockModeSwitch to 0)

    • .t (optional), [tmin, tmax] coordinates of the dataset to take after transpose, time

    • .replaceDatasetSwitch (optional), force to replace dataset completely with a new dataset

    • .keepModel (optional), do not resize the model/selection layers when type=’image’ and submitting complete dataset; as result the selection/model layers have to be modified manually layer. Used in mibResampleController. Default = true;

Output Arguments:
  • result - true-success, false-fail, result of function execution

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.setData4D(dataset, 'image');% Call from mibController: update the complete dataset in the shown orientation

Example 2

obj.mibModel.I{obj.mibModel.id}.setData4D(dataset, 'image', NaN, NaN, options.blockModeSwitch=1);% Call from mibController: update the croped to the viewing window dataset, with shown colors

Example 3

obj.mibModel.I{obj.mibModel.id}.setData4D(dataset, 'image', 3, 2);% Call from mibController: update complete dataset in the XY orientation with only second color channel

Attention: sensitive to the obj.cQuickAccessBar.view.handles.blockMode; to override the blockMode use options.blockModeSwitch=false

Attention: NOT sensitive to the shown ROI (obj.cQuickAccessBar.view.handles.roiMode), if areas under ROIs are required use options.roiId and options.fillBg parameters

setPixSize(val)

function setPixSize(obj, val) Propagate a new pixSize struct to all four dataset layers.

Usage:
obj.setPixSize(newPixSize)

This is the ONLY sanctioned write path for voxel size on a MibDataset. After the call every layer that has its own save/load method (image, labels, mask, selection) holds the same up-to-date pixSize, so those methods never need to receive pixSize via an options argument.

To READ the current voxel size use:

pixSize = obj.image.pixSize; % authoritative copy

Parameters:

.tunits (val  struct with fields .x .y .z .t .units)

setPixelIdxList(type, dataset, PixelIdxList, options)

SETPIXELIDXLIST - Write pixel values at a list of linear indices into the active dataset layer.

Syntax:
result = obj.setPixelIdxList(type, dataset, PixelIdxList, options) %#ok<INUSD>

Wrapper method on MibDataset that routes the write request to the correct layer object (obj.image, obj.labels, obj.mask, obj.selection) and then delegates to core.MibImage.setPixelIdxList.

Routing rules (mirror setData3D):
  • 'image' - routes to obj.image

  • 'labels' or 'model' - routes to obj.labels; sets obj.modelExist = true

  • 'mask' - routes to obj.labels (MibLabels63) or obj.mask (MibLabels); sets obj.maskExist = true

  • 'selection' - routes to obj.labels (MibLabels63) or obj.selection (MibLabels)

  • 'everything' - routes to obj.labels (MibLabels63 only)

The PixelIdxList must be linear indices into the full 3D volume in XY orientation (i.e. as returned by bwconncomp / regionprops).

Input Arguments:
  • type - char, layer type to write:

    • 'image' - pixel values of the image layer

    • 'model' - synonym for 'labels'

    • 'labels' - material indices into the labels layer

    • 'mask' - mask layer values (0/1)

    • 'selection' - selection layer values (0/1)

    • 'everything' - raw packed byte (MibLabels63 only)

  • dataset - numeric vector of values to write; must match numel(PixelIdxList)

  • PixelIdxList - numeric vector of linear pixel indices into the full dataset in the XY orientation (standard MATLAB column-major order)

  • options - (optional) struct; reserved for future use, not used currently

Output Arguments:
  • result - logical true on success, false on error

Usage:

Example 1 - move object 1 pixels into the selection layer

I = cell2mat(obj.mibModel.getData3D('mask'));
CC = bwconncomp(I, 26);
val = zeros(numel(CC.PixelIdxList{1}), 1, 'uint8') + 1;
% move object 1 pixels into the selection layer:
obj.mibModel.I{id}.setPixelIdxList('selection', val, CC.PixelIdxList{1});

Example 2 - clear the model label at a set of pixel positions

% clear the model label at a set of pixel positions:
obj.mibModel.I{id}.setPixelIdxList('labels', zeros(numel(idx),1,'uint8'), idx);
stitchModelInstances(options, wb)

STITCHMODELINSTANCES - Stitch per-slice 2D instance labels into a 3D instance model.

Syntax:
stats = obj.stitchModelInstances()
stats = obj.stitchModelInstances(options)
stats = obj.stitchModelInstances(options, wb)

Treats the current labels layer as a stack of independently generated 2D instance segmentations (each z-slice carries its own instance indices, not consistent across slices) and links objects that overlap between neighbouring slices into single 3D instances with one consistent index through the whole stack. The heavy lifting is done by utils.instances.stitch2Dto3D(); this method wraps it with the per-timepoint read/write and rebuilds the labels object at a capacity large enough for the resulting instance count (mirrors the indexed-object branch of core.MibDataset.convertModel()). When the source model is the bit-packed type-63 layer, the selection and mask layers are unpacked into standalone layers first, because the new indexed model can no longer carry them in its bits.

Unlike the connected-component options in convertModel (which turn a semantic model into indexed objects), this expects a model whose slices are already per-slice indexed 2D instances - typically the raw output of a 2D instance-segmentation prediction.

The filename of the source model is carried over to the stitched one with options.filenameSuffix ('_3d') added, so the result stays associated with the data it came from without being able to overwrite it on save.

Input Arguments:
  • options (optional) - structure passed through to utils.instances.stitch2Dto3D() (method, splitDisconnected2D, iouThreshold, ioaThreshold, minOverlapPixels, absOverlapPixels, zLookback, minObjectVoxels, minObjectSlices, bidirectional); missing fields take that function’s defaults. One field is consumed here rather than passed on:

    • .filenameSuffix - appended to the stem of the current model filename, which is otherwise carried over unchanged [default '_3d']. Labels_stack.model becomes Labels_stack_3d.model, so a save after stitching does not silently overwrite the 2D instance model the result was built from. Pass '' to keep the name as it is. A model that was never loaded or saved has no name to propagate and is left alone, as is a stem that already ends with the suffix

  • wb (optional) - uiprogressdlg handle; pass [] to skip progress reporting. When it was created with 'Cancelable', 'on' the stitching can be interrupted - the handle is forwarded to utils.instances.stitch2Dto3D(), which polls it in its own loops

Output Arguments:
  • stats - structure from the last processed timepoint with .numInput2DObjects, .numOutput3DObjects, .objectVoxelCounts and .cancelled. When .cancelled is true the method returns without touching the dataset, so a cancelled run leaves the model exactly as it was - nothing is half-stitched

Example - stitch the current model with default settings

obj.stitchModelInstances();
swapMaterials(material1, material2, wb)

SWAPMATERIALS - Swap two materials in the model - low-level data layer.

Syntax:
obj.swapMaterials(material1, material2, wb)

Exchanges all pixel values equal to material1 with material2 and vice versa across every time-point, then updates material names and colours via obj.labels.swapMaterials (for small models only; large models have no meaningful name/colour metadata to swap).

Input Arguments:
  • material1 - double, 1-based index of the first material.

  • material2 - double, 1-based index of the second material.

  • wb - (optional) handle to a uiprogressdlg for progress display; when empty no progress is reported.

Output Arguments:

Usage:

Example 1

obj.mibModel.I{obj.mibModel.id}.swapMaterials(1, 3);% swap materials 1 and 3

Example 2

obj.mibModel.I{obj.mibModel.id}.swapMaterials(2, 5, wb);% with progress bar
swapSlices(sliceFrom, sliceTo, orient)

SWAPSLICES - Swap slice(s) between two positions across all image layers.

Syntax:
result = obj.swapSlices(sliceFrom, sliceTo, orient)

Orchestrates a within-dataset slice swap across all active layers: the primary image, labels (model), mask, and selection. Delegates actual array manipulation to core.MibImage.swapSlices for each layer. The dataset size does not change.

Input Arguments:
  • sliceFrom - index or index vector of source slices

  • sliceTo - index or index vector of destination slices; must be the same length as sliceFrom

  • orient - (optional) dimension to operate on: 1 = height (y), 2 = width (x), 3 = depth (z), 5 = time (t). Default: obj.orientation

Output Arguments:
  • result - 1 on success, 0 on failure

Usage:

Example 1

result = obj.mibModel.I{id}.swapSlices(3, 10);

Example 2

result = obj.mibModel.I{id}.swapSlices([1,2], [5,6], 3);
switchDatasetMode(newMode, enableSelection, initWithImage)

SWITCHDATASETMODE - Function to switch between loading datasets to different modes, defined.

Syntax:
newModeOut = obj.switchDatasetMode(newMode, enableSelection, initWithImage)

in bj.handles.panels.activeDataset.handles.datasetType as ‘Standard’, ‘Virtual’, ‘BigData’

Input Arguments:
  • newMode - (optional) target dataset mode:

    • 1 - memory-resident mode (Standard), images loaded to memory

    • 2 - HDD-resident mode (Virtual), images kept on hard drive

    • 3 - BigData mode, images loaded on demand

  • enableSelection - (optional) logical switch to enable/disable the selection layer; set based on mibModel.preferences.System.EnableSelection

  • initWithImage - (optional) initialise the class with a provided image:

    • for 'Standard': numeric matrix (preloaded image data)

    • for 'Virtual': cell array with full path(s) to the dataset

Output Arguments:
  • newModeOut - result of the function:

    • [] - nothing was changed

    • 1 - switched to the memory-resident (Standard) mode

    • 2 - switched to the virtual stacking mode

    • 3 - switched to the BigData mode

Usage:

Example 1

result = obj.mibModel.I{obj.mibModel.Id}.switchDatasetMode(1, obj.mibModel.preferences.System.EnableSelection);% enable the virtual stacking mode
transpose(new_orient)

TRANSPOSE - Change orientation of the image to the YX, XZ, or YZ plane.

Syntax:
obj.transpose(new_orient)

Converted from MIB2 @mibImage/transpose.m

Note: This function updates only the slices and orientation fields; it does NOT rearrange the underlying image data in memory.

Input Arguments:
  • new_orient - desired orientation:

    • 1 - XZ plane (xz)

    • 2 - YZ plane (yz)

    • 3 - YX plane (yx, default view)

Output Arguments:

none

Usage:

Example 1

obj.transpose(1);   % switch to XZ plane
obj.transpose(2);   % switch to YZ plane
obj.transpose(3);   % switch to YX plane
obj.mibModel.I{obj.mibModel.id}.transpose(3);   % call from MibController
transposeDataset(mode, parentFigure, showWaitbar, noColorChannels)

TRANSPOSEDATASET - Transpose the dataset between dimensions.

Syntax:
obj.transposeDataset(mode, parentFigure, showWaitbar)
obj.transposeDataset('Transpose Z<->C', parentFigure, showWaitbar, noColorChannels)

Ported from MIB2 @mibModel/transposeDataset.m and @mibModel/transposeZ2T.m.

Input Arguments:
  • mode - [char] transpose mode:

    • 'Transpose YX -> YZ' - YX plane becomes YZ plane

    • 'Transpose YX -> XZ' - YX plane becomes XZ plane

    • 'Transpose YX -> XY' - YX plane becomes XY plane

    • 'Transpose YX -> ZX' - YX plane becomes ZX plane

    • 'Transpose Z<->T' - swap Z (depth) and T (time) dimensions

    • 'Transpose Z<->C' - swap Z (depth) and C (color) dimensions

  • parentFigure (optional) - handle to the parent figure for the progress dialog; pass [] to suppress the progress dialog

  • showWaitbar (optional) - logical, true to show a progress dialog (default: true)

  • noColorChannels (optional) - [numeric] for 'Transpose Z<->C' only: number of color channels in the output; pass NaN to use all Z-sections as channels

Output Arguments:

none

Usage:

Example 1 - transpose YX to YZ from a MibModel context

id = obj.mibModel.getActiveId();
obj.mibModel.I{id}.transposeDataset('Transpose YX -> YZ', obj.mibModel.mibGUI, true);

Example 2 - transpose Z to C with 3 output channels

id = obj.mibModel.getActiveId();
obj.mibModel.I{id}.transposeDataset('Transpose Z<->C', obj.mibModel.mibGUI, true, 3);
updateBoundingBox(newBB, xyzShift, imgDims)

UPDATEBOUNDINGBOX - Delegate bounding-box update to the image layer.

Syntax:
obj.updateBoundingBox(newBB, xyzShift, imgDims)

After the call obj.image.pixSize and obj.image.boundingBox are updated. The other layers (labels, mask, selection) share the same pixSize because setPixSize() was called by the controller prior to this call (see BoundingBox.applyButton_Callback for the canonical usage pattern).

Parameters: identical to core.MibImage.updateBoundingBox - see that file.