models — Application Model¶
The +models package holds the central application state.
models.MibModel owns the array of open core.MibDataset
instances and fires events (NewDataset, ShowImage,
SliceChanged, …) that all controllers observe.
- class models.MibModel¶
Bases:
handleMIBMODEL - the main model class of MIB.
- Constructor Summary
- MibModel(cpuParallelLimitMax, mibPath, mibVersion, options)¶
MIBMODEL - Construct an instance of this class.
- Syntax:
function obj = MibModel(cpuParallelLimitMax, mibPath, mibVersion, options)
- Input Arguments:
cpuParallelLimitMax - integer, maximal number of possible workers for parallel processing; when empty (default) the value is computed lazily on the first access of
obj.cpuParallelLimitMaxviautils.getMaxParpoolWorkersmibPath - char with the location of MIB3
mibVersion - char with the MIB version, by default the string returned by
utils.getMibVersion(), which is the only place the version is written down. Pass a value only to emulate another version - a version older than the one recorded inmib3.matmakesinitializePreferencesfall back to the defaults and ignore the saved preferences. ATTENTION! it is important to have the version number between “ver.” and “/” Release syntax example: “ver. 2025.11 / 04.11.2025” Beta syntax example: “ver. 2025.11 (beta 4) / 04.11.2025”options.Verbose - logical, default true; when false the model is constructed silently, i.e.
initializePreferencesdoes not print which preferences file, override file and user statistics folder were picked up. Tests build a model per test method, so they pass false to keep the test output readable; warnings and errors are printed regardless of this settingoptions.Preferences - char,
'saved'(default) or'defaults'.'saved'restores the preferences of the previous session frommib3.mat, applies an override file when present and loads the user statistics shards.'defaults'keeps the freshly generated defaults and reads or writes no file belonging to the user, which is what tests need: the outcome of a test must not depend on a preference last saved from the GUI, and the statistics migration steps (which move real files) must never run from the suite
- Usage:
Example 1 - a silent, self-contained model, as built by the test helpers
mibModel = models.MibModel(1, mibFolder, Verbose = false, Preferences = 'defaults');
- Property Summary
- Backup¶
define whether or not display the model layer (used in obj.mibDataset.getRGBimage)
- I¶
- Iraw¶
variable for keeping instances of MibDataset
- IrawModel¶
raw image source for Ishown
- Ishown¶
raw model (material indices) raster for on-demand (Virtual/BigData) modes, aligned with Iraw; used by the cursor material readout
- Sets¶
cell array with the selected files in the Directory Contents panel
- applySegmentationIn3D¶
currently rendered images for visualization
- autoFillSelection¶
apply some segmentation tools in 3D, updated by press of obj.cSelection.handles.applySegmentationIn3D
- connImaris¶
n×2 double array of global dataset ID pairs that are linked for view synchronisation; each row [idA, idB] means dataset idA and idB always show the same position. Managed by controllers.MibActiveDataset.buffers_ContextMenu (link/unlink/close actions). Queried by MibController.showImage for live propagation.
- cpuParallelLimitMax¶
- currentDirectory¶
autofill the selection layer during segmentation, updated by press of obj.cSelection.handles.autoFillSelection
- differenceSelection¶
current working directory for MIB
- disableSegmentation¶
- extensionRegistryLoad¶
apply erode and dilate operations to get only a difference with the original selection, updated by press of obj.cSelection.handles.differenceSelection
- hideImage¶
class containing registry of filename extensions that can be loaded
- id¶
define whether or not display the image layer
- linkedPairs¶
use bio-formats reader
- matlabVersion¶
index of the selected dataset
- mibController¶
version of Matlab
- mibGUI¶
handle to controllers.MibController, used to reach the active image document (cImageDoc) when parenting progress dialogs (getProgressBarParent)
- mibPath¶
handle to the main MIB window, to be used in child controllers to align them relative to the main window (utils.moveWindowOutside) place
- mibVersion¶
path to MIB installation directory also available in MibController
- onFlyImageStretch¶
char with the current version of MIB
- preferences¶
enable/disable live stretching of image intensities
- preferencesMode¶
when true (default) initializePreferences prints which preferences and user statistics files were picked up; set to false via the Verbose name-value argument of the constructor to keep the model silent, as done by the test helpers that build a model per test method
- previouslySelectedDataset¶
a structure with program preferences
- pythonEnv¶
index of the previously selected dataset, to be toggled using Ctrl+E shortcut
- selectedFileFilter¶
file reader family selected in the Directory Contents panel: ‘Default’ (MIB-native), ‘BioFormats’, or ‘OpenSlide’. The BioFormats engine (MIB-Java vs MATLAB) is the separate preference IO.BioFormats.Library.
- selectedFiles¶
file filter selected in the Directory contents panel, cell, one per reader family (see MibModel.readerToIndex): selectedFileFilter{1} - Default reader selectedFileFilter{2} - BioFormats reader selectedFileFilter{3} - OpenSlide reader
- selectedReader¶
python environment started from MIB
- sessionSettings¶
structure with the set settings .selectedSet -> index of the selected set .names -> cell array with names of sets .selectedDataset -> array of the datasets selected in each set .datasetsInSet -> number of datasets in one set
- showAnnotations¶
a structure with settings for some tools used during the current session of MIB e.g.: .automaticAlignmentOptions -> a structure used in mibAlignmentController .guiImages - CData for images to be shown on some buttons
- showLines3D¶
enable/disable live stretching of image intensities
- showMask¶
enable/disable show of 3D lines
- showModel¶
define whether or not display the mask layer (used in obj.mibDataset.getRGBimage)
- storedSelection¶
handle to an active IceImarisConnector connection; [] when not connected
- useBioFormats¶
variable for Undo history, instance of core.MibBackup
- verboseStartup¶
buffer for the selection layer, used by selectionBuffer (copy/paste/clear)
- Method Summary
- addMaterial(BatchOptIn)¶
ADDMATERIAL - Add a material to the current model - wrapper around core.MibDataset.addMaterial.
- Syntax:
obj.addMaterial(BatchOptIn)
For models with 63 or 255 materials: prompts the user for a material name, verifies that the model type can accommodate one more material, then appends the new entry to the list.
For models with 65535 or 4294967295 materials: rescans the model data for the highest label in use to determine the next available index, checks that the model is not full, then asks MibDataset to register the new index. Pressing the button repeatedly therefore keeps offering the same free index until it is actually painted.
In all cases the model is created automatically when it does not yet exist. After a successful addition, UpdateGuiWidgets and ShowImage events are fired so the segmentation table and image view refresh.
- Input Arguments:
BatchOptIn - a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.MaterialName- char, name of the new material (used for types 63 and 255; for larger types the value is overridden with the next unused index string) [default ‘NewMaterial’].showWaitbar- logical, show or not the waitbar [default false].id- (optional), dataset index from 1 to 9, default = obj.id
Output Arguments:
- Usage:
Example 1 - interactive add with name dialog
obj.mibModel.addMaterial();Example 2 - scripted / batch call
BatchOpt.MaterialName = 'Nucleus'; BatchOpt.showWaitbar = false; obj.mibModel.addMaterial(BatchOpt);
- backup(type, switch3d, getDataOptions)¶
BACKUP - Store the dataset for Undo.
- Syntax:
obj.backup(type, switch3d, getDataOptions)
The dataset is stored in the MibBackup class (obj.Backup).
- Input Arguments:
type - ‘image’, ‘selection’, ‘mask’, ‘model’ (swapped to labels), ‘labels’, ‘everything’ (for MibLabels63 only), ‘modelLayers’, ‘lines3d’, ‘annotations’, ‘measurements’, ‘mibDataset’
'modelLayers'stores copies of the labels, selection and mask layer objects instead of a pixel snapshot, so the model type is restored together with the data. Use it before operations that replace the labels layer with a different model type (Standard datasets only)'image'is stored only for Standard datasets. On a Virtual or BigData dataset the call is a no-op: the snapshot has no coordinate ranges, so it would read the whole disk- or network-resident volume, and undo could not write it back into an image layer that holds file paths rather than pixelsswitch3d - a switch to define a 2D or 3D mode to store the dataset
0- 2D slice1- 3D dataset
getDataOptions - (optional) a structure with extra parameters
.blockModeSwitch- (optional), crop the stored dataset to the visible portion of the data, when true, overrides .y and .x fields.y- (optional), [ymin, ymax] of the part of the dataset to store.x- (optional), [xmin, xmax] of the part of the dataset to store.z- (optional), [zmin, zmax] of the part of the dataset to store.t- (optional), [tmin, tmax] of the part of the dataset to store.roiId- (optional), use or not the ROI mode (when missing or less than 0, return full dataset; 0 - return all shown ROIs dataset; Index or[]- return ROI with this index or currently selected).id- (optional), index of the dataset to backup.LinkedVariable- (optional) additional structure with variable names to store;.LinkedVariable.Fieldnamespecifies the variable name as seen from mibController, e.g.getDataOptions.LinkedVariable.Points = 'obj.mibModel.sessionSettings.SAMsegmenter.Points';.LinkedData- (optional) additional structure with data values to store; Fieldname must match Fieldname in.LinkedVariable, e.g.getDataOptions.LinkedData.Points.Position = [];andgetDataOptions.LinkedData.Points.Value = [];
Output Arguments:
- Usage:
Example 1 - store the current 2D selection slice before modifying it
obj.mibModel.backup('selection', 0);Example 2 - store the full 3D selection volume before a 3D operation
obj.mibModel.backup('selection', 1);Example 3 - store the mask layer for the current 2D slice
obj.mibModel.backup('mask', 0);Example 4 - store the model layer as 3D before batch processing
obj.mibModel.backup('labels', 1);Example 5 - for type-63 models, ‘selection’/’mask’/’labels’ are automatically converted to ‘everything’ (all three layers packed together)
obj.mibModel.backup('selection', 0);Example 6 - store image data (2D slice) - also saves full image metadata
obj.mibModel.backup('image', 0);Example 7 - store image data (3D volume)
obj.mibModel.backup('image', 1);Example 8 - store annotations before editing them
obj.mibModel.backup('annotations', 0);Example 9 - store 3D lines/skeletons before modification
obj.mibModel.backup('lines3d', 0);Example 10 - store the entire MibDataset (deep copy) for complex operations
obj.mibModel.backup('mibDataset', 1);Example 10b - store the segmentation layers before changing the model type
obj.mibModel.backup('modelLayers', 1);Example 11 - store only the visible block (block mode) of the selection
backupOpt.blockModeSwitch = true; obj.mibModel.backup('selection', 0, backupOpt);Example 12 - store a specific sub-region of the dataset
backupOpt.x = [100, 200]; backupOpt.y = [50, 150]; backupOpt.z = [10, 10]; obj.mibModel.backup('selection', 0, backupOpt);Example 13 - store backup for a specific dataset (not the currently shown one)
backupOpt.id = 2; obj.mibModel.backup('selection', 1, backupOpt);Example 14 - store with LinkedData for SAM segmenter undo support
backupOpt.LinkedData.Points.Position = [10, 10]; backupOpt.LinkedData.Points.Value = [5]; backupOpt.LinkedVariable.Points = 'obj.sessionSettings.SAMsegmenter.Points'; obj.mibModel.backup('selection', 0, backupOpt);
- changeImageMode(BatchOptIn)¶
CHANGEIMAGEMODE - Convert the active dataset to a different image mode or bit depth.
- Syntax:
status = obj.changeImageMode(BatchOptIn)
Orchestrates image format conversion for the active MibDataset. Validates preconditions (virtual mode, selection enabled), takes an undo backup, handles the multi-channel LUT blending confirmation dialog, then delegates to
core.MibImage.convertImage. Fully batch-compatible.- Input Arguments:
BatchOptIn - (optional) structure for batch processing mode; when
NaN, returns default options via theSyncBatchevent.Target- cell string,{'Grayscale'}with allowed values{'Grayscale','Multi-channel','HSV color','Indexed','8 bit','16 bit','32 bit'}.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default =obj.getActiveId()
- Output Arguments:
status -
1on success,0on failure or user cancel
Example 1 - convert current dataset to grayscale
obj.mibModel.changeImageMode();Example 2 - cast to 8-bit via batch call
BatchOpt.Target = {'8 bit'}; BatchOpt.showWaitbar = false; obj.mibModel.changeImageMode(BatchOpt);Example 3 - return default BatchOpt to the Batch Processing editor
obj.mibModel.changeImageMode(NaN);
- clearLayer(layer, sel_switch, BatchOptIn)¶
CLEARLAYER - clear the specified layer.
- Syntax:
obj.clearLayer(layer, sel_switch, BatchOptIn)- Input Arguments:
layer - a string with the target layer
[]- default ('selection')'selection'- clear the selection layer'mask'- clear the mask layer'labels'- clear the labels layer'everything'- clear selection, mask, and labels layers (core.MibLabels63 only)'image'- clear the image layer
sel_switch - a string to define the extent of the clear operation
'2D, Slice'- clear the currently shown slice only'3D, Stack'- clear the currently shown z-stack'4D, Dataset'- clear the whole dataset
BatchOptIn - (optional) structure with extra parameters for batch processing mode; when NaN, returns a structure with default options via
SyncBatchevent.Layer- cell with one of:'selection','mask','labels','everything','image'.DatasetType- cell with one of:'2D, Slice','3D, Stack','4D, Dataset'.showWaitbar- logical, show or not the waitbar
- Usage:
Example 1 - clear the selection layer for the whole dataset
obj.mibModel.clearLayer('selection');Example 2 - clear the selection layer of the shown slice
obj.mibModel.clearLayer('selection', '2D, Stack');
- clearMask(sel_switch, BatchOptIn)¶
CLEARMASK - Clear the Mask layer for the current dataset.
- Syntax:
obj.clearMask(sel_switch, BatchOptIn)
Clears all pixels in the Mask layer for the current slice, the whole z-stack, or the entire 4D dataset, depending on the requested scope. Supports batch-processing mode via BatchOptIn.
- Input Arguments:
sel_switch - (optional) string defining the clear scope
'2D, Slice'- clear the currently shown slice only (default)'3D, Stack'- clear the full z-stack at the current time point'4D, Dataset'- clear the entire dataset (all z and t)
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.DatasetType- cell{value, {choices}}selecting the clear scope.showWaitbar- logical, show or not the progress bar.id- dataset index 1-9; default = currently active dataset
- Output Arguments:
(none)
- Usage:
Example 1 - clear current slice
obj.mibModel.clearMask('2D, Slice');Example 2 - clear current z-stack
obj.mibModel.clearMask('3D, Stack');Example 3 - clear full dataset
obj.mibModel.clearMask('4D, Dataset');
- clearSelection(sel_switch, BatchOptIn)¶
CLEARSELECTION - Clear the Selection layer for the current dataset.
- Syntax:
obj.clearSelection(sel_switch, BatchOptIn)
Clears all pixels in the Selection layer for the current slice, the whole z-stack, or the entire 4D dataset, depending on the requested scope. Supports batch-processing mode via BatchOptIn.
- Input Arguments:
sel_switch - (optional) string defining the clear scope
‘2D, Slice’ - clear the currently shown slice only (default)
‘3D, Stack’ - clear the full z-stack at the current time point(s)
‘4D, Dataset’ - clear the entire dataset (all z and t)
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.DatasetType - cell {value, {choices}} selecting the clear scope
.showWaitbar - logical, show or not the progress bar
.id - dataset index 1-9; default = obj.id
- Output Arguments:
(none)
- Usage:
Example 1 - clear current slice
obj.mibModel.clearSelection('2D, Slice');Example 2 - clear current z-stack
obj.mibModel.clearSelection('3D, Stack');Example 3 - clear full dataset
obj.mibModel.clearSelection('4D, Dataset');
- colorChannelActions(mode, channel1, BatchOptIn)¶
COLORCHANNELACTIONS - Handle various color channel operations.
- Syntax:
obj.colorChannelActions() obj.colorChannelActions(mode) obj.colorChannelActions(mode, channel1) obj.colorChannelActions(mode, channel1, BatchOptIn)
Batch-compatible dispatcher. When called with only
mode, shows an interactive dialog pre-set to that action. When called with no arguments, shows the full action-selection dialog.- Input Arguments:
mode - (optional) char, pre-selects the action; pass
[]or omit to start with the action-selection step. One of:'Insert empty channel','Copy channel','Invert channel','Rotate channel','Shift channel','Swap channels','Delete channel'. PassNaNto return default options via theSyncBatchevent.channel1 - (optional) numeric scalar, pre-sets
BatchOpt.Channel1{1}(the primary / source channel index). Pass[]to use the currently selected channel.BatchOptIn - (optional) struct for batch processing mode
.Action- [cell] action to perform (default:{'Insert empty channel'}). Allowed values:{'Insert empty channel', 'Copy channel', 'Invert channel', 'Rotate channel', 'Shift channel', 'Swap channels', 'Delete channel'}.Channel1- [numeric cell]{value, [minLim maxLim], 'on'}source / primary channel index (default: currently selected channel).Channel2- [numeric cell]{value, [minLim maxLim], 'on'}target / secondary channel index; used by Copy and Swap. For Copy:0appends source as a new channel at the end. (default: currently selected channel).RotationAngle- [cell] rotation angle for Rotate action (default:{'90'}). Allowed:{'90', '180', '-90'}.dx- [numeric cell]{value, [minLim maxLim], 'on'}X-shift in pixels for Shift action (default:{0, [-maxDim maxDim], 'on'}).dy- [numeric cell]{value, [minLim maxLim], 'on'}Y-shift in pixels for Shift action (default:{0, [-maxDim maxDim], 'on'}).FillValue- [numeric cell]{value, [minLim maxLim], 'on'}Fill intensity for Shift action border (default:{0, [0 maxInt], 'on'}).showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Usage:
Example 1 - open Insert empty channel dialog
obj.mibModel.colorChannelActions('Insert empty channel');Example 2 - batch: delete color channel 2
BatchOpt.Action = {'Delete channel'}; BatchOpt.Channel1 = {2, [1 9], 'on'}; obj.mibModel.colorChannelActions('Delete channel', [], BatchOpt);Example 3 - batch: shift channel 1 by dx=10, dy=-5
BatchOpt.Action = {'Shift channel'}; BatchOpt.dx = {10, [-512 512], 'on'}; BatchOpt.dy = {-5, [-512 512], 'on'}; BatchOpt.FillValue = {0, [0 255], 'on'}; obj.mibModel.colorChannelActions('Shift channel', 1, BatchOpt);
- convertDataToMouseCoordinates(x, y, mode)¶
CONVERTDATATOMOUSECOORDINATES - Convert coordinates of a pixel in the dataset to the coordinates of the.
- Syntax:
[xOut, yOut] = obj.convertDataToMouseCoordinates(x, y, mode)
image axes (screen/mouse space).
This is the inverse of convertMouseToDataCoordinates. It takes pixel positions in the dataset coordinate frame and returns the corresponding positions in the axes coordinate frame used for rendering.
- Input Arguments:
x - numeric - x-coordinate(s) in dataset space
y - numeric - y-coordinate(s) in dataset space
mode - (optional) char - rendering mode, default ‘shown’
‘shown’ - standard viewport (most common)
‘full’ - full-image rendering during panning
- Output Arguments:
xOut - numeric - x-coordinate(s) in axes space
yOut - numeric - y-coordinate(s) in axes space
- Usage:
Example 1:
[xOut, yOut] = obj.mibModel.convertDataToMouseCoordinates(x, y); // from MibControllerExample 2:
[xOut, yOut] = obj.mibModel.convertDataToMouseCoordinates(x, y, 'shown'); // explicit mode
- convertModel(ModelType, BatchOptIn)¶
CONVERTMODEL - Convert the segmentation model to a different type.
- Syntax:
obj.convertModel() obj.convertModel(ModelType) obj.convertModel(ModelType, BatchOptIn)
Converts the segmentation model between capacity types (63, 255, 65535, 4294967295 materials) or generates a new model where each connected object receives a unique index (2D or 3D connectivity).
Changing between integer types adjusts memory usage and the maximum number of materials. Converting to an indexed-object type reruns connected-component labelling on all materials and replaces the model with per-object indices.
- Input Arguments:
ModelType (optional) - numeric model type to convert to:
63- packed uint8; mask and selection stored in bits 7-8255- separate uint8 labels layer65535- separate uint16 labels layer4294967295- separate uint32 labels layer2.4- detect 2D objects (connectivity 4) and index them2.8- detect 2D objects (connectivity 8) and index them3.6- detect 3D objects (connectivity 6) and index them3.26- detect 3D objects (connectivity 26) and index them
BatchOptIn (optional) - structure for batch processing; pass
NaNto return default options viaSyncBatchevent.ModelType- cell string dropdown, first element is selected value.showWaitbar- logical, show or not the waitbar [defaulttrue].id- (optional) dataset index 1-9; default = active dataset
- Output Arguments:
(none)
Example 1 - convert current model to 255-material type
obj.mibModel.convertModel(255);Example 2 - batch call
BatchOpt.ModelType = {'65535'}; obj.mibModel.convertModel([], BatchOpt);
- convertMouseToDataCoordinates(x, y, mode, permuteSw)¶
CONVERTMOUSETODATACOORDINATES - Convert coordinates under the mouse cursor to the coordinates of the dataset.
- Syntax:
[xOut, yOut, zOut, tOut] = obj.convertMouseToDataCoordinates(x, y, mode, permuteSw)- Input Arguments:
x - x - coordinate
y - y - coordinate
mode - (optional) string; default
'shown':'shown'- convert coordinates of the mouse above the image to dataset coordinates'full'- conversion for when the full image is rendered inhandles.imageAxes'blockmode'- returns coordinates under the mouse for the Block (blockface mode)
permuteSw - (optional), can be
[]:0- returns coordinates for the dataset in the original XY orientation1- (default) returns coordinates so that the currently selected orientation becomes XY
- Output Arguments:
xOut - x - coordinate with the dataset
yOut - y - coordinate with the dataset
zOut - z - coordinate with the dataset
tOut - t - time coordinate
- Usage:
Example 1
[xOut, yOut] = obj.mibModel.convertMouseToDataCoordinates(x, y);
- copySwapSlice(sourceSlice, targetSlice, mode, BatchOptIn)¶
COPYSWAPSLICE - Copy, insert, or swap slice(s) within the dataset.
- Syntax:
obj.copySwapSlice(sourceSlice, targetSlice, mode) obj.copySwapSlice(sourceSlice, targetSlice, mode, BatchOptIn)
Batch-compatible dispatcher. Shows an interactive dialog when called without
BatchOptIn. Delegates toMibDataset.copySlice,MibDataset.insertSlice, orMibDataset.swapSlices. In insert mode the image, labels, mask, and selection layers of the source slice are all copied into the newly inserted position.- Input Arguments:
sourceSlice - (optional) index of the source slice;
[]uses the current slicetargetSlice - (optional) index of the destination slice;
[]uses the current slicemode - (optional) one of
'replace'(default),'insert', or'swap'BatchOptIn - (optional) struct for batch processing mode; when
NaN, returns default options via theSyncBatchevent..Mode- [cell] operation mode (default:{'replace'}). Allowed values:{'replace', 'insert', 'swap'}.SourceSlice- [numeric cell]{value, [minLim maxLim], 'on'}index of the source slice.TargetSlice- [numeric cell]{value, [minLim maxLim], 'on'}index of the destination slice; for insert mode1= insert as first slice,0= append to the end.showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Usage:
Example 1 - copy slice 4 to slice 10
obj.mibModel.copySwapSlice(4, 10, 'replace');Example 2 - swap slices 4 and 10
obj.mibModel.copySwapSlice(4, 10, 'swap');Example 3 - batch mode
BatchOpt.Mode = {'replace'}; BatchOpt.SourceSlice = {4, [1, 100], 'on'}; BatchOpt.TargetSlice = {10, [1, 100], 'on'}; obj.mibModel.copySwapSlice([], [], [], BatchOpt);
- createModel(ModelType, ModelMaterialNames, BatchOptIn)¶
CREATEMODEL - Create a new model - wrapper around core.MibDataset.createModel.
- Syntax:
obj.createModel(ModelType, ModelMaterialNames, BatchOptIn)- Input Arguments:
ModelType - (optional), can be empty: []; a number with the model type:
63 - 63 material model
255 - 255 material model
65535 - 65535 material model
4294967295 - 4294967295 material model
ModelMaterialNames - (optional) can be empty: []; a cell array with names of materials; not used for ModelType > 255
BatchOptIn - a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.ModelType - cell string, {‘63’, ‘255’, ‘65535’, ‘4294967295’}
.ModelMaterialNames - string with semicolon-separated material names
.showWaitbar - logical, show or not the waitbar
.id (optional), dataset index from 1 to 9, default = obj.id
Output Arguments:
- Usage:
Example 1 - create a new model
obj.mibModel.createModel();
- datasetsSetsOps(BatchOptIn)¶
DATASETSSETSOPS - Operations with sets of the model.
- Syntax:
status = obj.datasetsSetsOps() status = obj.datasetsSetsOps(BatchOptIn)
Compatible with the batch processing mode.
- Input Arguments:
BatchOptIn - (optional) structure with parameters; when NaN, returns default options via “SyncBatch” event
.Mode- cell string, operation to perform:'Select set'- select the set in the Datasets panel dropdown'Add set'- add a new set (10 new datasets) into the model'Rename set'- rename the current set'Remove set'- remove the current set.SetName- char, set name to select, rename, or remove; when empty a dialog appears
- Output Arguments:
status - logical,
truewhen the operation completed successfully
- Usage:
Example 1 - select a set by name
BatchOpt.Mode = {'Select set'}; BatchOpt.SetName = 'Set 2'; obj.mibModel.datasetsSetsOps(BatchOpt);Example 2 - add a new set
BatchOpt.Mode = {'Add set'}; BatchOpt.SetName = 'Experiment B'; obj.mibModel.datasetsSetsOps(BatchOpt);
- deepCopyDataset(fromId, toId, options)¶
DEEPCOPYDATASET - Deep-copy a MibDataset; optionally install it into another container slot.
- Syntax:
obj.deepCopyDataset(fromId, toId, options) newDataset = obj.deepCopyDataset(fromId, [], options)
@c copy() (matlab.mixin.Copyable) performs a shallow copy only - all handle sub-properties (image, labels, mask, selection, annotations, lines3D, measure, hROI) continue to point at the same objects after a plain @c copy(). This method fixes that by explicitly deep-copying every handle sub-property.
Used by container-buffer and crop operations (cross-container deep copy) as well as by
backup()andundo()for the'mibDataset'snapshot type.- Input Arguments:
fromId - index of the source dataset in
obj.ItoId - index of the destination dataset in
obj.I; when[], the deep-copied dataset is not installed intoobj.Iand is only returned vianewDataset(used by undo/backup)options - (optional) structure with additional parameters
.showWaitbar- logical, show a progress dialog (default: true).UIFigure- handle to a UIFigure for the progress dialog; when empty the dialog is created without a parent (default:[])
- Output Arguments:
newDataset - deep-copied
core.MibDataset; fully independent ofobj.I{fromId}
- Usage:
Example 1 - deep-copy dataset from container 1 to container 2
obj.mibModel.deepCopyDataset(srcId, destId, options);Example 2 - get a free-standing deep copy (no destination slot)
datasetCopy = obj.mibModel.deepCopyDataset(srcId, [], struct('showWaitbar', false));
- deleteAnnotations(BatchOptIn)¶
DELETEANNOTATIONS - Delete all annotations from the active dataset.
- Syntax:
obj.deleteAnnotations(BatchOptIn)
Backs up the current annotation state for undo, removes all annotations, and fires the UpdateAnnotations event so any listening views can refresh.
- Input Arguments:
BatchOptIn - (optional) struct for batch processing mode; when NaN, returns default options via the ‘SyncBatch’ event
.id- (optional) dataset index 1-9, default = obj.getActiveId()
- Output Arguments:
(none)
- Usage:
Example 1 - delete all annotations from the active dataset
obj.mibModel.deleteAnnotations();Example 2 - batch call on dataset 1
BatchOpt.id = 1; obj.mibModel.deleteAnnotations(BatchOpt);
- deleteSlice(orientation, sliceNumber, BatchOptIn)¶
DELETESLICE - Delete one or more slices (or time-frames) from the dataset.
- Syntax:
obj.deleteSlice(orientation) obj.deleteSlice(orientation, sliceNumber) obj.deleteSlice(orientation, sliceNumber, BatchOptIn)
Batch-compatible dispatcher. Shows an interactive dialog when called without
BatchOptIn. Delegates toMibDataset.deleteSlice.- Input Arguments:
orientation - (optional) initial dimension:
1= height (y),2= width (x),3= depth (z),5= time (t). Default:obj.orientationof the active datasetsliceNumber - (optional) index/indices of slices to delete;
[]uses the current slice positionBatchOptIn - (optional) struct for batch processing mode; when
NaN, returns default options via theSyncBatchevent..Dimension- [cell] deletion dimension (default:{'depth'}). Allowed values:{'height', 'width', 'depth', 'time'}.DeletePosition- [string] slice indices, e.g.'5'or'1,5:10';'0'deletes the last slice/frame.showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Usage:
Example 1 - delete the currently visible z-slice
obj.mibModel.deleteSlice(3);Example 2 - delete a specific time-frame
obj.mibModel.deleteSlice(5, 3);Example 3 - batch: delete z-slices 2 through 10
BatchOpt.Dimension = {'depth'}; BatchOpt.DeletePosition = '2:10'; obj.mibModel.deleteSlice([], [], BatchOpt);
- dilateImage(BatchOptIn)¶
DILATEIMAGE - Dilate (expand) the selection, mask, or labels layer.
- Syntax:
obj.dilateImage(BatchOptIn)
Expands the binary content of the chosen layer using either a 2D disk-like structuring element (applied slice-by-slice) or a 3D ball structuring element (applied across the full volume). An optional Difference mode retains only the pixels that were added by dilation (i.e. the outer ring), useful for creating boundary/outline selections.
Dilation can be clipped to the extent of a model material or to the mask layer via the restrictSelectionToMaterial / restrictSelectionToMask options.
Parallel 2D dilation is supported via parfor when the Parallel Computing Toolbox is available; use core.PoolWaitbar for thread-safe progress.
Performance: for a radius above
bwdistRadiusThreshold(5 px) with a spherical/circular element (equal XY and Z / X and Y radii) the operation is computed asbwdist(BW) <= R(see utils.morphBallOp), which is O(N) regardless of radius instead of the O(R^2)/O(R^3) brute-force cost of a raw structuring element. Large anisotropic 3D elements keep the accurate (slow) ellipsoidal imdilate unlessAnisotropicMethodrequests'Fast (bwdist)'(the Selection panel offers this choice through a single dialog; batch/API callers set the field directly). This method itself never opens a dialog.- Input Arguments:
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.TargetLayer- cell string,{'selection','mask','labels'}layer to dilate.DatasetType- cell string,{'2D, Slice','3D, Stack','4D, Dataset'}scope.DilateMode- cell string,{'2D','3D'}strel dimensionality.StrelSize- string, strel radius in pixels; one value (isotropic) or two values separated by a space (first = XY radius, second = Z radius for 3D mode or X radius for 2D mode).Difference- logical, keep only the dilated ring (dilated minus original).restrictSelectionToMaterial- string, material index (e.g.'2') or'NaN'to disable; clips dilation to pixels inside the material.restrictSelectionToMask- logical, clip dilation to the mask layer.MaterialIndex- string, material index for TargetLayer='labels'.Use2DParallelComputing- logical, use parfor for 2D slice-by-slice dilation.AnisotropicMethod- cell string,{'Accurate (slow)','Fast (bwdist)'}; only consulted for large-radius 3D dilation on anisotropic voxels - see the performance note below.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default = obj.id
- Output Arguments:
(none)
- Usage:
Example 1 - dilate selection on current slice with defaults
obj.mibModel.dilateImage();Example 2 - dilate the mask layer across the full z-stack with a 5-px radius
BatchOpt.TargetLayer = {'mask'}; BatchOpt.DatasetType = {'3D, Stack'}; BatchOpt.DilateMode = {'2D'}; BatchOpt.StrelSize = '5'; BatchOpt.Difference = false; BatchOpt.showWaitbar = true; obj.mibModel.dilateImage(BatchOpt);Example 3 - 3D ball dilation clipped to material 2, difference mode
BatchOpt.TargetLayer = {'selection'}; BatchOpt.DatasetType = {'4D, Dataset'}; BatchOpt.DilateMode = {'3D'}; BatchOpt.StrelSize = '3'; BatchOpt.Difference = true; BatchOpt.restrictSelectionToMaterial = '2'; BatchOpt.showWaitbar = false; obj.mibModel.dilateImage(BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.dilateImage(NaN);
- editInstanceObjects(BatchOptIn)¶
EDITINSTANCEOBJECTS - Split, merge, connect and delete objects of an instance model.
- Syntax:
obj.editInstanceObjects() obj.editInstanceObjects(BatchOpt) applied = obj.editInstanceObjects(BatchOpt) obj.editInstanceObjects(NaN) % return the available options
The editing operations behind
controllers.InstanceEditor. Automatic 2D to 3D stitching (utils.instances.stitch2Dto3D) leaves errors that no threshold can remove - objects fused across many slices, one object carrying two indices - and this is how they are repaired by hand.Every per-object action is confined to the bounding boxes held in
MibDataset.instanceIndex: the volume is read, backed up and written only inside them, so the cost of an edit is the size of the object rather than the size of the dataset. The index is refreshed over the same region afterwards.- Input Arguments:
BatchOptIn - (optional) structure with the fields below;
NaNtriggers theSyncBatchevent with the defaults instead of running:.Action- cell, the operation:'Merge'- the selected objects become one, taking the smallest of their indices; the others are freed. WithObjectIndicesempty the objects are taken from the Selection layer - draw one shape across them all, and the background under that shape joins the survivor too, so the stroke closes the gap it was drawn across. InMode3Da shape also reaches one slice beyond either end of itself, which is how a gap along Z is closed; where that competes with a single object the shape merely clips in-plane, the larger share of the drawing decides: seelocalObjectsToJoin. A drawing that reaches fewer than two objects is not a failed merge but the same gesture over a smaller region, so it falls through to the two below: over nothing it becomes an object, over one object it joins that object. The rule is one rule - the drawing belongs to the surviving object - whatever it happens to reach'AddObject'- the voxels of the Selection layer take the next free index, so the drawing becomes a new object.ObjectIndicesis not used'AddToObject'- the voxels of the Selection layer are given to the one object inObjectIndices, which grows by the drawing'SplitComponents'- each object is broken into its connected components; the largest keeps the index, the rest get new ones'SplitBySelection'- the voxels of the Selection layer are cleared from the object first, then it is split into connected components. One undo step for the brush workflow: draw the break, interpolate it, split. WithObjectIndicesempty the objects are taken from the drawing itself - everything it covers is split'CutAtSlice'- voxels at or beyond the shown slice take a new index'Connect'- bridge between two objects and merge them. NeedsMode3D; the merge is the same oneMergeperforms. WithObjectIndicesempty it is a drawing-drivenMerge, down to the same code -ConnectModeis not consulted, the drawing being the bridge already. The two buttons differ only when objects are named'Delete'- remove the objects'Cleanup'- apply the noise filters to the whole model'Compact'- renumber every object to a contiguous 1..N
.ObjectIndices- char, comma-separated object indices to act on, e.g.'7, 12'. Ignored byCleanup,CompactandAddObject, and exactly one index forAddToObject. Empty is an error everywhere exceptMerge,SplitBySelectionandConnect, where it means “whatever the Selection layer covers” - and forConnect, what it lies between; the drawing is cleared afterwards, having been used.Mode3D- logical, operate on the whole volume (default) or only on the shown slice.Connectivity- cell,'26'/'6'in 3D,'8'/'4'in 2D. A value belonging to the other mode is translated rather than rejected.ConnectMode- cell, howConnectbuilds the bridge:'interpolate'- shape-interpolate between the two facing cross-sections (utils.interpolateShapes). Needs a gap in Z, having to have two faces to morph between'selection'- use the current Selection layer as the bridge. Takes the same path as a drawing-drivenMergeand needs no gap, so it also joins two objects that share a Z range but never touch
.cleanupMinObjectVoxels/.cleanupMinObjectSlices/.cleanupAbsorbFragmentVoxels- thresholds forCleanup, which is the only action that reads them; seeutils.instances.cleanup. The prefix keeps them apart from the identically-purposedMinObjectVoxelsofmodels.MibModel.stitchModelInstances, which are that method’s own and are set in its own dialog.showWaitbar- logical, show a progress dialog for the two whole-volume actions. The per-object actions are sub-second by design and never show one.id- (optional) dataset index 1-9; default = active dataset
- Output Arguments:
applied - logical, true when the model was actually changed. Every rejection path (wrong model type, nothing selected, an index that is not in the model, a cut outside the object, a cancelled cleanup) reports to the user and returns false, so a caller can tell “done” from “declined” instead of assuming the edit went through and updating its own state to match.
Note
Only 65535 and 4294967295 model types on
Standarddatasets are handled. A model with 63 or 255 materials has no per-object identity to edit, andBigDatalabels are bit-packed at 63 materials so they cannot hold an instance model at all.- Usage:
Example 1 - merge objects 12 and 7; the result is object 7. Without
ObjectIndiceseverything the Selection layer covers is merged insteadBatchOpt.Action = {'Merge'}; BatchOpt.ObjectIndices = '7, 12'; obj.mibModel.editInstanceObjects(BatchOpt);Example 2 - the brush workflow: break drawn into the Selection layer. Without
ObjectIndicesthe drawing says what to cut; naming an object restricts the cut to it, for a line that clips a neighbourBatchOpt.Action = {'SplitBySelection'}; obj.mibModel.editInstanceObjects(BatchOpt); BatchOpt.ObjectIndices = '537'; obj.mibModel.editInstanceObjects(BatchOpt);
See also: utils.instances.objectIndex, utils.instances.cleanup, core.MibDataset.buildInstanceIndex, models.MibModel.stitchModelInstances
- erodeImage(BatchOptIn)¶
ERODEIMAGE - Erode the selection, mask, or labels layer.
- Syntax:
obj.erodeImage(BatchOptIn)
Shrinks the binary content of the chosen layer using either a 2D disk-like structuring element (applied slice-by-slice) or a 3D ball structuring element (applied across the full volume). An optional Difference mode retains only the pixels that were removed by erosion (i.e. the eroded ring), useful for creating boundary/outline selections.
Parallel 2D erosion is supported via parfor when the Parallel Computing Toolbox is available; use core.PoolWaitbar for thread-safe progress.
Performance: for a radius above
bwdistRadiusThreshold(5 px) with a spherical/circular element (equal XY and Z / X and Y radii) the operation is computed asbwdist(~BW) > R(see utils.morphBallOp), which is O(N) regardless of radius instead of the O(R^2)/O(R^3) brute-force cost of a raw structuring element. Large anisotropic 3D elements keep the accurate (slow) ellipsoidal imerode unlessAnisotropicMethodrequests'Fast (bwdist)'(the Selection panel offers this choice through a single dialog; batch/API callers set the field directly). This method itself never opens a dialog.- Input Arguments:
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.TargetLayer- cell string,{'selection','mask','labels'}layer to erode.DatasetType- cell string,{'2D, Slice','3D, Stack','4D, Dataset'}scope.ErodeMode- cell string,{'2D','3D'}strel dimensionality.StrelSize- string, strel radius in pixels; one value (isotropic) or two values separated by a space (first = XY radius, second = Z radius for 3D mode or X radius for 2D mode).Difference- logical, keep only the eroded ring (original minus eroded).MaterialIndex- string, material index for TargetLayer='labels'; useNaNto erode all materials (not yet implemented - pass a valid index).Use2DParallelComputing- logical, use parfor for 2D slice-by-slice erosion.AnisotropicMethod- cell string,{'Accurate (slow)','Fast (bwdist)'}; only consulted for large-radius 3D erosion on anisotropic voxels - see the performance note below.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default = obj.id
- Output Arguments:
(none)
- Usage:
Example 1 - erode selection on current slice with defaults
obj.mibModel.erodeImage();Example 2 - erode the mask layer across the full z-stack with a 5-px radius
BatchOpt.TargetLayer = {'mask'}; BatchOpt.DatasetType = {'3D, Stack'}; BatchOpt.ErodeMode = {'2D'}; BatchOpt.StrelSize = '5'; BatchOpt.Difference = false; BatchOpt.showWaitbar = true; obj.mibModel.erodeImage(BatchOpt);Example 3 - 3D ball erosion of labels material 2 across whole dataset
BatchOpt.TargetLayer = {'labels'}; BatchOpt.DatasetType = {'4D, Dataset'}; BatchOpt.ErodeMode = {'3D'}; BatchOpt.StrelSize = '3'; BatchOpt.MaterialIndex = '2'; BatchOpt.showWaitbar = false; obj.mibModel.erodeImage(BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.erodeImage(NaN);
- expandSelectionToMaskBorder(BatchOptIn)¶
EXPANDSELECTIONTOMASKBORDER - Snap each selection blob to its enclosing mask region.
- Syntax:
obj.expandSelectionToMaskBorder(BatchOptIn)
For each connected component in the Selection layer, finds the mask connected component that contains (or overlaps) it, and replaces the selection blob with the full extent of that mask region. Uses a labelmatrix lookup for O(N_sel) efficiency rather than the O(N_sel x N_mask) linear scan in MIB2.
- Input Arguments:
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event.
.DatasetType- cell string,{'3D, Stack','4D, Dataset'}scope.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default = obj.id
- Output Arguments:
(none)
- Usage:
Example 1 - expand selection to mask border on current stack
obj.mibModel.expandSelectionToMaskBorder();Example 2 - batch mode across full 4D dataset
BatchOpt.DatasetType = {'4D, Dataset'}; BatchOpt.showWaitbar = false; obj.mibModel.expandSelectionToMaskBorder(BatchOpt);Example 3 - return default BatchOpt to the Batch Processing editor
obj.mibModel.expandSelectionToMaskBorder(NaN);
- exportDataset(layerType, BatchOptIn)¶
EXPORTDATASET - Export image, mask, or labels layer to the MATLAB main workspace.
- Syntax:
obj.exportDataset(layerType, BatchOptIn)- Input Arguments:
layerType - a string specifying which layer to export:
'image'- export image data with metadata (and colormap if indexed)'mask'- export mask layer as a uint8 array'model'- export model (labels) as a struct with material info
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options via “SyncBatch” event:.LayerType- cell string,{'image'|'mask'|'model'}layer to export.ImageVariable- string, [image only] workspace variable name for image data, default'I'.ColormapVariable- string, [image only, indexed color] variable name for colormap, default'cmap'.MaskVariable- string, [mask only] workspace variable name for mask, default'M'.LabelsVariable- string, [model only] workspace variable name for labels struct, default'O'.MaterialIndex- string, [model only] index of material to export; empty = whole model.MaterialOutputIndex- string, [model only] value assigned to single material export, default'1'.showWaitbar- logical, show or not the waitbar.id- (optional) index of the dataset
- Usage:
Example 1 - export image interactively
obj.mibModel.exportDataset('image');Example 2 - export mask interactively
obj.mibModel.exportDataset('mask');Example 3 - export mask in batch mode
BatchOpt.MaskVariable = 'myMask'; BatchOpt.showWaitbar = false; obj.mibModel.exportDataset('mask', BatchOpt);
- exportDatasetToImaris(layerType, BatchOptIn)¶
EXPORTDATASETTOIMARIS - Export the image, mask, or model layer to Imaris via IceImarisConnector.
- Syntax:
obj.exportDatasetToImaris(layerType, BatchOptIn)- Input Arguments:
layerType - a string specifying which layer to export:
'image'- export image data'mask'- export mask layer as a single binary channel'model'- export model (labels layer); prompts for material index
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options via “SyncBatch” event:.LayerType- cell string,{'image'|'mask'|'model'}layer to export.MaterialIndex- string, [model only] material index to export; empty = all materials.showWaitbar- logical, show or not the waitbar.id- (optional) index of the dataset
- Usage:
Example 1 - export image interactively
obj.mibModel.exportDatasetToImaris('image');Example 2 - export mask interactively
obj.mibModel.exportDatasetToImaris('mask');Example 3 - export first material in batch mode
BatchOpt.MaterialIndex = '1'; obj.mibModel.exportDatasetToImaris('model', BatchOpt);
- exportDatasetToMib(layerType, BatchOptIn)¶
EXPORTDATASETTOMIB - Copy the mask or model layer to another MIB container (buffer).
- Syntax:
obj.exportDatasetToMib(layerType, BatchOptIn)- Input Arguments:
layerType - a string specifying which layer to copy:
'mask'- copy the mask layer'model'- copy the model (labels) layer, including material metadata
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options via “SyncBatch” event:.LayerType- cell string,{'mask'|'model'}layer to copy.Destination- cell string, destination container, e.g.{'Container 2'}.showWaitbar- logical, show or not the waitbar.id- (optional) index of the source dataset
- Usage:
Example 1 - copy mask interactively
obj.mibModel.exportDatasetToMib('mask');Example 2 - copy model interactively
obj.mibModel.exportDatasetToMib('model');Example 3 - batch mode
BatchOpt.Destination = {'Container 2'}; BatchOpt.showWaitbar = false; obj.mibModel.exportDatasetToMib('mask', BatchOpt);
- fillSelectionOrMask(targetLayer, BatchOptIn)¶
FILLSELECTIONORMASK - Fill holes in the selection or mask layer.
- Syntax:
obj.fillSelectionOrMask(targetLayer, BatchOptIn)
Applies imfill(‘holes’) slice-by-slice across the chosen scope. Optionally the filled result is clipped to the pixels belonging to a specific model material (restrictSelectionToMaterial).
Parallel 2D filling is supported via parfor when the Parallel Computing Toolbox is available; use core.PoolWaitbar for thread-safe progress.
- Input Arguments:
targetLayer - (optional) char with the targer layer, ‘mask’, or ‘selection’, when [] - ‘selection’
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event. When called from MibSelection.fillSelection the DatasetType and TargetLayer fields are already populated.
.TargetLayer- cell string,{'selection','mask'}layer to fill.DatasetType- cell string,{'2D, Slice','3D, Stack','4D, Dataset'}scope.SelectedMaterial- string, material index used when restrictSelectionToMaterial=true;'-1'mask,'0'exterior,'1','2'….restrictSelectionToMaterial- logical, clip filled result to the pixels of the selected model material.Use2DParallelComputing- logical, use parfor for slice-by-slice fill.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default = obj.id
- Output Arguments:
(none)
- Usage:
Example 1 - fill selection on current slice
obj.mibModel.fillSelectionOrMask();Example 2 - fill the mask layer across the full z-stack
BatchOpt.TargetLayer = {'mask'}; BatchOpt.DatasetType = {'3D, Stack'}; BatchOpt.restrictSelectionToMaterial = false; BatchOpt.showWaitbar = true; obj.mibModel.fillSelectionOrMask(BatchOpt);Example 3 - return default BatchOpt to the Batch Processing editor
obj.mibModel.fillSelectionOrMask(NaN);
- getActiveId()¶
GETACTIVEID - Compute the correct dataset index from Sets.selectedSet.
- Syntax:
id = obj.getActiveId()
In split-panel mode, mouse motion over a different document silently updates obj.id via gui_WinMouseMotionFcn. This makes obj.id unreliable when used as a default in BatchOpt initialisation. This method computes the id from Sets.selectedSet and Sets.selectedDataset, which are only changed through the full UI chain and are therefore always correct.
- Output Arguments:
id - [numeric] the dataset index (1..datasetsInSet*numberOfSets)
Example 1 - get the reliable dataset index:
id = obj.mibModel.getActiveId();
- getAxesLimits(id)¶
GETAXESLIMITS - get axes limits for the currently shown or id dataset.
- Syntax:
[axesX, axesY] = obj.getAxesLimits(id)- Input Arguments:
id - (optional) id of the dataset, otherwise the currently shown dataset (obj.mibModel.id)
- Output Arguments:
axesX - a vector [min, max] for the X
axesY - a vector [min, max] for the Y
- Usage:
Example 1 - get axes limits for the currently shown dataset
[axesX, axesY] = obj.mibModel.getAxesLimits();Example 2 - get axes limits for dataset 2
[axesX, axesY] = obj.mibModel.getAxesLimits(2);
- getData2D(type, slice_no, orient, col_channel, options)¶
GETDATA2D - Get a 2D slice from the current (or specified) dataset; wrapper around core.MibDataset.getData2D.
- Syntax:
dataset = obj.getData2D(type, slice_no, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.getData2D(…) instead of obj.mibModel.I{obj.mibModel.id}.getData2D(…). All argument semantics are identical to core.MibDataset.getData2D.
- Input Arguments:
type - type of the dataset layer to retrieve:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
slice_no - (optional) slice index;
[]= current sliceorient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.t,.level- seeMibDataset.getData2D
- Output Arguments:
dataset - cell array {roiId}[height, width(, colors)] - see MibDataset.getData2D
- Usage:
Example 1 - current slice, current colour
slice = obj.mibModel.getData2D('image');Example 2 - slice 5, XY orient, ch 2
slice = obj.mibModel.getData2D('image', 5, 3, 2);Example 3 - use blockModeSwitch to get the visible area only
opt.blockModeSwitch = 1; sImage = cell2mat(obj.mibModel.getData2D('image', [], [], col_ch, opt));
- getData3D(type, time, orient, col_channel, options)¶
GETDATA3D - Get a 3D dataset from the current (or specified) dataset; wrapper around core.MibDataset.getData3D.
- Syntax:
dataset = obj.getData3D(type, time, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.getData3D(…) instead of obj.mibModel.I{obj.mibModel.id}.getData3D(…). All argument semantics are identical to core.MibDataset.getData3D.
- Input Arguments:
type - type of the dataset layer to retrieve:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
time - (optional) time-point index;
[]= current time pointorient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.z- seeMibDataset.getData3D
- Output Arguments:
dataset - cell array {roiId}[height, width, depth(, colors)] - see MibDataset.getData3D
- Usage:
Example 1 - current time point, shown orientation
dataset = obj.mibModel.getData3D('image');Example 2 - time 5, XY orient, ch 2
dataset = obj.mibModel.getData3D('image', 5, 3, 2);Example 3 - full selection volume (all colour channels)
dataset = obj.mibModel.getData3D('selection', [], [], NaN);
- getData4D(type, orient, col_channel, options)¶
GETDATA4D - Get the complete 4D dataset from the current (or specified) dataset; wrapper around core.MibDataset.getData4D.
- Syntax:
dataset = obj.getData4D(type, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.getData4D(…) instead of obj.mibModel.I{obj.mibModel.id}.getData4D(…). All argument semantics are identical to core.MibDataset.getData4D.
- Input Arguments:
type - type of the dataset layer to retrieve:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
orient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.z,.t- seeMibDataset.getData4D
- Output Arguments:
dataset - cell array {roiId}[height, width, depth, colors, time] or {roiId}[height, width, depth, time] - see MibDataset.getData4D
- Usage:
Example 1 - full dataset in shown orientation
dataset = obj.mibModel.getData4D('image');Example 2 - XY orient, ch 2
dataset = obj.mibModel.getData4D('image', 3, 2);
- getImageProperty(propertyName, id)¶
GETIMAGEPROPERTY - Get a property of the currently shown or specified MibDataset.
- Syntax:
propertyValue = obj.getImageProperty(propertyName, id)
A convenience wrapper that reads a named property directly from obj.I{id}.(propertyName). Useful for code that may not know the active dataset index in advance.
- Input Arguments:
propertyName - string with the property name to read from MibDataset
id - (optional) index of the dataset; default is obj.getActiveId()
- Output Arguments:
propertyValue - value of the requested property, or [] on error
- Usage:
Example 1 - get orientation of the active dataset
orientation = obj.mibModel.getImageProperty('orientation');Example 2 - get depth of dataset 2
depth = obj.mibModel.getImageProperty('depth', 2);
- getLinkedDataset(id)¶
GETLINKEDDATASET - Return the global dataset ID of the linked partner, or [] if not linked.
- Syntax:
partnerId = obj.getLinkedDataset(id)
Searches
obj.linkedPairs(n×2 array of [idA idB] global ID pairs) for a row that contains id and returns the other column value.- Input Arguments:
id - (1,1) double, global dataset ID to look up
- Output Arguments:
partnerId - scalar double with the partner’s global ID, or [] if id is not part of any linked pair
- Usage:
Example 1 - look up the linked partner for dataset 3
partnerId = obj.mibModel.getLinkedDataset(3);
- getMagFactor(id)¶
GETMAGFACTOR - Get magnification factor for the currently shown or specified dataset.
- Syntax:
magFactor = obj.getMagFactor(id)- Input Arguments:
id - (optional) ID of the dataset, otherwise uses current dataset (obj.id)
- Output Arguments:
magFactor - magnification factor
- Usage:
Example 1 - get current magFactor and for dataset 2
magFactor = obj.mibModel.getMagFactor(); magFactor = obj.mibModel.getMagFactor(2);
- getOwnStatsShard()¶
GETOWNSTATSSHARD - Return this workstation’s contribution to the user statistics.
- Syntax:
ownTiers = obj.getOwnStatsShard()
User statistics are stored as one file per workstation (
mib_user_<COMPUTERNAME>.mat) inside a folder that may be shared between machines, andutils.loadUserStats()sums those files at startup.preferences.Users.Tierstherefore holds the total across every workstation, which is what the user sees, but it is not what this machine may write back: writing the total into this machine’s shard would re-count all the other machines on every exit, and the totals would double each session.This method reconstructs the value this machine is entitled to write:
shard at startup + (current total - total at startup)where both baselines were captured by
models.MibModel.initializePreferences()intosessionSettings.UserStats. Only scalar numeric counters take part;tierLevelis skipped because it is derived fromcollectedPointsand recomputed when the shards are summed, andlogStartDateis taken from this machine’s own shard so that its log keeps starting when MIB first ran here.When the baselines are missing - a fresh installation, or a session that started before this bookkeeping existed - the current values are returned unchanged, which is correct because there was nothing to double-count.
- Input Arguments:
none
- Output Arguments:
ownTiers - [struct] statistics contributed by this workstation, ready to be passed to
utils.saveUserStats()
- Usage:
Example 1 - store this workstation’s shard
statsFolder = fileparts(obj.preferences.System.UserStatsProfile); utils.saveUserStats(statsFolder, obj.getOwnStatsShard());
See also: utils.saveUserStats, utils.loadUserStats, models.MibModel.initializePreferences, models.MibModel.relocateUserStats
- getProgressBarParent()¶
GETPROGRESSBARPARENT - Parent figure for progress dialogs.
Returns the active image document’s floating window when that document is undocked, otherwise the main MIB window (
obj.mibGUI). The undocked case keeps a long-running operation’s progress bar on the same screen the user is actually working on, instead of jumping back to the main window.Used as the parent argument for
uiprogressdlgandcore.PoolWaitbarin place ofobj.mibGUI/obj.mibModel.mibGUI.wb = uiprogressdlg(obj.getProgressBarParent(), 'Value', 0, 'Title', 'Eroding...');- Return values:
- parentFig: handle to the figure to parent progress dialogs to. Always a
valid handle; falls back to
obj.mibGUIon any error (batch/headless mode, no open dataset, stale document handles, docked document).
- getRGBimage(options, datasetId, sImgIn)¶
GETRGBIMAGE - Generate RGB image from all layers for display.
- Syntax:
[imgRGB, imgRAW] = obj.getRGBimage(options) [imgRGB, imgRAW] = obj.getRGBimage(options, datasetId) [imgRGB, imgRAW] = obj.getRGBimage(options, datasetId, sImgIn)
Combines image data, segmentation model, mask, selection layer, annotations, and 3D lines into a single RGB image for visualization.
- Input Arguments:
options - struct with display parameters
.blockModeSwitch- (optional)0return full slice [default],1crop to visible area.resizeToMagnification- (optional)trueresize to current magnification [default],falsereturn at 100%.sliceNo- (optional) specific slice index to display.markerType- (optional) annotation display type, default from preferences ('Marker','Label','Value','Label + Value').t- (optional) [tmin, tmax] time point to display.y- (optional) [ymin, ymax] Y-coordinates of region to extract.x- (optional) [xmin, xmax] X-coordinates of region to extract.useLut- (optional)0or1to use LUT color table [default: current dataset setting]datasetId - (optional) index of the dataset; when empty uses the currently selected dataset
sImgIn - (optional) custom 3D image stack to use instead of loading from dataset
- Output Arguments:
imgRGB - RGB image combining all visible layers [height × width × 3]
imgRAW - raw image data (used for virtual stacking mode)
modelRAW - model material-index raster aligned with imgRAW (Virtual/ BigData modes); empty when no model overlay is rendered. Used by the cursor material readout in gui_WinMouseMotionFcn
- Usage:
Example 1 - get full slice RGB with all layers
options.blockModeSwitch = 0; imgRGB = obj.getRGBimage(options);Example 2 - get cropped RGB of visible area only
options.blockModeSwitch = 1; options.resizeToMagnification = true; imgRGB = obj.getRGBimage(options);Example 3 - get specific slice without resizing
options.sliceNo = 50; options.resizeToMagnification = false; imgRGB = obj.getRGBimage(options);
- importDataset(layerType, BatchOptIn)¶
IMPORTDATASET - Import the image, mask, or model layer from the MATLAB main workspace.
- Syntax:
obj.importDataset(layerType, BatchOptIn)- Input Arguments:
layerType - a string specifying which layer to import:
'image'- replace the active dataset with an image variable from workspace'mask'- import a mask array from workspace into the active dataset'model'- import a model array or struct from workspace into the active dataset
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options via “SyncBatch” event:.LayerType- cell string,{'image'|'mask'|'model'}layer to import.ImageVariable- string, [image only] workspace variable name for image data, default'I'.MetaVariable- string, [image only] workspace variable name for metadata (containers.Mapordictionary); empty = skip.MaskVariable- string, [mask only] workspace variable name for mask data, default'M'.ModelVariable- string, [model only] workspace variable name for model data or struct, default'O'.showWaitbar- logical, show or not the waitbar.id- (optional) index of the dataset
- Usage:
Example 1 - import image interactively
obj.mibModel.importDataset('image');Example 2 - import mask interactively
obj.mibModel.importDataset('mask');Example 3 - batch import of mask
BatchOpt.MaskVariable = 'myMask'; BatchOpt.showWaitbar = false; obj.mibModel.importDataset('mask', BatchOpt);
- importDatasetFromMib(layerType, BatchOptIn)¶
IMPORTDATASETFROMMIB - Import the mask or model layer from another MIB container into the active dataset.
- Syntax:
obj.importDatasetFromMib(layerType, BatchOptIn)
This is the inverse of exportDatasetToMib: it pulls a layer FROM another container INTO the currently active container.
- Input Arguments:
layerType - a string specifying which layer to import:
'mask'- copy the mask layer from another container'model'- copy the model (labels) layer + material metadata from another container
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options via “SyncBatch” event:.LayerType- cell string,{'mask'|'model'}layer to import.Source- cell string, source container, e.g.{'Container 2'}.showWaitbar- logical, show or not the waitbar.id- (optional) index of the destination dataset
- Usage:
Example 1 - import mask interactively
obj.mibModel.importDatasetFromMib('mask');Example 2 - import model interactively
obj.mibModel.importDatasetFromMib('model');Example 3 - batch mode
BatchOpt.Source = {'Container 2'}; BatchOpt.showWaitbar = false; obj.mibModel.importDatasetFromMib('mask', BatchOpt);
- importMaterial(BatchOptIn)¶
IMPORTMATERIAL - Import selected materials from a saved model file into the current model.
- Syntax:
status = obj.importMaterial(BatchOptIn)
Loads a source model file, lets the user select a subset of its materials (by index), resizes the source pixel array to the current dataset dimensions (nearest-neighbour), then appends the selected materials as new slots - names, colors, and voxels - into the active model using an overwrite merge policy (existing voxels at the import locations are replaced by the source values).
BigData support: for disk-backed pyramidal datasets (
core.MibBigDataLabels) the source may have been saved at any pyramid resolution. The closest matching pyramid level of the current dataset is selected automatically (findClosestLevelForImport), the source is resized to that level, and the voxels are written there withsetData63; coarser levels are updated eagerly and finer levels are reconstructed lazily by the level map.- Input Arguments:
BatchOptIn - (optional) a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.Filename- char, full path to the source model file; leave empty to open the file browser interactively [default''].MaterialIndices- char, MATLAB-style index expression for the source materials to import (e.g.'1','2:4','1 3 5'); leave empty to prompt interactively (or import all in batch mode) [default''].showWaitbar- logical, show or not the progress dialog [defaulttrue].id- (optional), dataset index 1-9, default = obj.getActiveId()
- Output Arguments:
status - logical, true when the import completed successfully
- Usage:
Example 1 - interactive: file browser + material selection dialog
obj.mibModel.importMaterial();Example 2 - batch: import materials 1 and 3 from a specific file
BatchOpt.Filename = 'C:\data\source.model'; BatchOpt.MaterialIndices = '1 3'; BatchOpt.showWaitbar = false; obj.mibModel.importMaterial(BatchOpt);
- initialize()¶
INITIALIZE - Initialize the MibModel class.
- Syntax:
obj.initialize()
Initializes the MibModel class by setting up default directories, datasets, and session parameters. Creates the initial dataset set with dummy datasets and initializes core components like the undo system and extension registry.
- Input Arguments:
none
- Usage:
Example 1 - initialize the model after construction
obj = models.MibModel(); obj.initialize();
- initializePreferences()¶
INITIALIZEPREFERENCES - Initialize and update MIB preferences from a file.
- Syntax:
obj.initializePreferences()
Initializes MIB preferences by loading saved preferences from the user’s preferences directory. Handles preference upgrades when version changes occur, applies override settings when available, and restores user statistics.
When the user has no
mib3.matyet, the first override file found inobj.mibPathis merged over the defaults, in this order:mib3_prefs_override_<COMPUTERNAME>.json,mib3_prefs_override_<COMPUTERNAME>.mat,mib3_prefs_override.json,mib3_prefs_override.mat. A JSON file, written bymodels.MibModel.saveOverridePreferences(), may list any subset of the settings; the rest keep their defaults. Its values are coerced back to the class and shape of the defaults -jsondecodereturns every vector as a column,{}as[]and cannot holdInf/NaN, which the file stores as the strings"Inf","-Inf","NaN"."_comment"keys are dropped, unknown settings are dropped with aMIB:preferencesOverridewarning, and a file that cannot be read is ignored with the same warning.Usersis never taken from an override file, andKeyShortcutsonly when the file has at least as many actions as this version.The files that were picked up are reported to the command window unless the model was constructed with
Verbose = false(obj.verboseStartup); warnings raised by a failed handover of the MIB2 statistics are printed either way.- Input Arguments:
none
- Usage:
Example 1 - called internally during MibModel initialization
obj.initializePreferences();
See also: utils.defaults.generatePreferences, utils.getPrefDir, controllers.Preferences.defaultBtn_Callback
- insertEmptySlice(BatchOptIn)¶
INSERTEMPTYSLICE - Insert one or more empty (background-filled) slices into the volume.
- Syntax:
obj.insertEmptySlice() obj.insertEmptySlice(BatchOptIn)
Batch-compatible dispatcher. Shows an interactive dialog when called without
BatchOptIn. Creates a zero-filled (or background-filled) image block of the required size and delegates toMibDataset.insertSlice.- Input Arguments:
BatchOptIn - (optional) struct for batch processing mode; when
NaN, returns default options via theSyncBatchevent..Dimension- [cell] insertion dimension (default:{'depth'}). Allowed values:{'depth', 'time'}.InsertPosition- [numeric cell]{value, [minLim maxLim], 'on'}insert before this 1-based slice index;1= insert as first slice;0= append to the end (default: current slice).NumberOfSlices- [numeric cell]{value, [minLim maxLim], 'on'}number of slices to insert (default:{1, [1, maxSlice], 'on'}).BackgroundColor- [numeric cell]{value, [minLim maxLim], 'on'}fill intensity, 0 = black (default:{maxInt, [0, maxInt], 'on'}).showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Usage:
Example 1 - interactive
obj.mibModel.insertEmptySlice();Example 2 - batch: insert 10 blank time-frames before frame 2
BatchOpt.Dimension = {'time'}; BatchOpt.InsertPosition = {2, [0, 100], 'on'}; BatchOpt.NumberOfSlices = {10, [1, 100], 'on'}; BatchOpt.BackgroundColor = {0, [0, 255], 'on'}; obj.mibModel.insertEmptySlice(BatchOpt);
- intensityProjection(BatchOptIn)¶
INTENSITYPROJECTION - Calculate intensity projection of the dataset along a chosen dimension.
- Syntax:
obj.intensityProjection() obj.intensityProjection(BatchOptIn)
Calculates intensity projection (Max, Min, Mean, Median, or Sum) of the current dataset along a selected dimension (Y, X, Z, C, or T). The result is written back to the active container or to any other open container.
For virtual datasets only Z-projection is available; it is computed slice-by-slice to avoid loading the full volume into memory.
- Input Arguments:
BatchOptIn - (optional) a structure for batch processing mode; when
NaNreturns a structure with default options viaSyncBatchevent:.ProjectionType- cell string, type of projection (default{'Max'}); values{'Max', 'Min', 'Mean', 'Median', 'Sum'}(virtual mode omits'Median').Dimension- cell string, projection dimension (default{'Z'}); values{'Y', 'X', 'Z', 'C', 'T'}; virtual mode:{'Z'}only.Set- cell string, name of the destination set (default: name of the currently active set), e.g.{'Set 1'}.Container- numeric cell, local buffer index within the destination set (default: active buffer);{1}value,{2}limits[1 N],{3}'on'(integer).showWaitbar- logical, show the progress bar (defaulttrue).id- (runtime) index of the source dataset; stripped beforeSyncBatch
- Usage:
Example 1 - max Z-projection interactively
obj.mibModel.intensityProjection();Example 2 - batch: mean projection along Z to buffer 2 of Set 1
BatchOpt.ProjectionType = {'Mean'}; BatchOpt.Dimension = {'Z'}; BatchOpt.Set = {'Set 1'}; BatchOpt.Container = {2}; BatchOpt.showWaitbar = false; obj.mibModel.intensityProjection(BatchOpt);Example 3 - return default BatchOpt to the Batch Processing editor
obj.mibModel.intensityProjection(NaN);
- interpolateImage(imgType, intType, BatchOptIn)¶
INTERPOLATEIMAGE - Interpolate the ‘mask’, ‘selection’, or ‘labels’ layer between slices.
- Syntax:
obj.interpolateImage(imgType, intType, BatchOptIn)
Applies either shape interpolation (suitable for filled blobs) or line interpolation (suitable for open-line / membrane annotations) to the binary representation of the chosen layer at the current time point. Intermediate slices between any two annotated slices are filled in.
- Input Arguments:
imgType - (optional) string, layer to interpolate; default
'selection':'selection'- smooth the Selection layer'mask'- smooth the Mask layer'labels'- smooth a material of the Labels (segmentation model) layer
intType - (optional) string, interpolation algorithm; default from preferences:
'shape'- contour-based interpolation, best for filled shapes/blobs'line'- endpoint-based interpolation, best for open lines/membranes
BatchOptIn - (optional) structure for batch processing mode; when
NaN, returns a structure with default options via the “SyncBatch” event:.Target- cell string,{'mask','selection','labels'}layer to interpolate.InterpolationType- cell string,{'shape','line'}algorithm.MaterialIndex- string [only for'labels'], index of the material.showWaitbar- logical, show or not the waitbar.id- (optional) dataset index 1-9, default =obj.id
- Output Arguments:
(none) - returns early on cancel, invalid input, or unsupported mode.
- Usage:
Example 1 - shape-interpolate current selection
obj.mibModel.interpolateImage('selection', 'shape');
- invertImage(datasetType, BatchOptIn)¶
INVERTIMAGE - Invert pixel intensities in the image dataset.
- Syntax:
obj.invertImage() obj.invertImage(datasetType) obj.invertImage(datasetType, BatchOptIn)
Inverts all or selected color channels of the current dataset across the chosen scope (single slice, current z-stack, or complete 4D volume).
For 3D and 4D scopes, inversion is performed by a vectorised call to
MibImage.invertColorChannel. For the 2D (single-slice) scope,getData2D/setData2Dare used so that ROI masking and arbitrary viewing orientation are handled correctly.- Input Arguments:
datasetType - (optional) char, pre-sets
BatchOpt.DatasetType{1}; pass[]or omit to use the BatchOptIn value or the default'2D, Slice'. One of:'2D, Slice','3D, Stack','4D, Dataset'. PassNaNto return default options via theSyncBatchevent.BatchOptIn - (optional) structure for batch processing mode
.DatasetType- cell string, scope of inversion (default{'2D, Slice'}); values:{'2D, Slice', '3D, Stack', '4D, Dataset'}.ColorChannels- cell string, channels to invert (default{'Shown channels'}); values:{'Shown channels', 'All channels'}.showWaitbar- logical, show the progress dialog (defaulttrue).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Output Arguments:
(none)
- Usage:
Example 1 - invert shown channels on the current slice
obj.mibModel.invertImage();Example 2 - pre-select 3D mode (controller calls this from the menu)
obj.mibModel.invertImage('3D, Stack');Example 3 - invert all channels across the full dataset (batch)
BatchOpt.ColorChannels = {'All channels'}; BatchOpt.showWaitbar = true; obj.mibModel.invertImage('4D, Dataset', BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.invertImage(NaN);
- invertMask(type, sel_switch, BatchOptIn)¶
INVERTMASK - Invert the Mask or Selection layer.
- Syntax:
obj.invertMask(type) obj.invertMask(type, sel_switch) obj.invertMask(type, sel_switch, BatchOptIn)
Inverts the binary content of the mask or selection layer for the chosen scope (single slice, current z-stack, or full 4D dataset). For standard (non-packed) datasets the inversion is
1 - data; for MibLabels63 packed datasets the relevant bit (bit 7 for mask, bit 8 for selection) is flipped withbitxor.- Input Arguments:
type - char, layer to invert:
'mask'or'selection'; pass''to default to'mask'sel_switch - (optional) char, scope of the inversion; initialises
BatchOpt.DatasetType'2D, Slice'- current slice only (default)'3D, Stack'- full z-stack at the current time point'4D, Dataset'- entire dataset (all z and t)
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the
SyncBatchevent.Target- cell string,{'mask','selection'}.DatasetType- cell string, scope of inversion.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default =obj.getActiveId()
- Output Arguments:
(none)
- Usage:
Example 1 - invert mask on the current slice
obj.mibModel.invertMask('mask');Example 2 - invert selection across the full z-stack
obj.mibModel.invertMask('selection', '3D, Stack');Example 3 - invert mask across the full 4D dataset (batch)
BatchOpt.Target = {'mask'}; BatchOpt.DatasetType = {'4D, Dataset'}; BatchOpt.showWaitbar = false; obj.mibModel.invertMask('mask', '4D, Dataset', BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.invertMask('', [], NaN);
- loadImages(parameter, BatchOptIn)¶
LOADIMAGES - Load images and arrange them into a stack.
- Syntax:
obj.loadImages(parameter) obj.loadImages(parameter, BatchOptIn)- Input Arguments:
parameter - string specifying the loading mode
'Combine datasets'- [default] combine selected datasets'Load part of dataset'- load part of the dataset'Load each N-th dataset'- load every N-th dataset'Insert into open dataset'- insert into the open dataset'Combine files as color channels'- combine files as color channels'Add as new color channel'- add as a new color channel'Add each N-th dataset as new color channel'- add each N-th dataset as a new color channelBatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via “SyncBatch” event
.Mode- cell string, desired loading mode (see parameter above for valid values).DirectoryName- cell string, directory where files are located.FilenameFilter- char, filter for filenames ('*.*'= all files,'*.tif'= TIF only).Filenames- (optional) cell within a cell array of FULL PATH filenames; batch mode only.UseBioFormats- logical, use Bio-Formats reader when true.BioFormatsIndices- char, (BioFormats only) indices of images in file containers; empty = load all.EachNthStep- char, step size for every-N-th mode.BackgroundColorIntensity- char, background fill intensity when image sizes mismatch.InsertDatasetDimension- (Insert only) cell string,{'depth'}|{'time'}.InsertDatasetPosition- (Insert only) char;'1'= beginning,'0'= end, or a numeric position.showWaitbar- logical, show progress dialog.id- (optional) dataset index (default: currently shown dataset)
- Usage:
Example 1 - load and combine datasets interactively
obj.mibModel.loadImages('Combine datasets');Example 2 - batch mode: load every 2nd TIF from a folder
BatchOpt.Mode = {'Load each N-th dataset'}; BatchOpt.DirectoryName = {'C:\data\tifs'}; BatchOpt.FilenameFilter = '*.tif'; BatchOpt.EachNthStep = '2'; BatchOpt.showWaitbar = false; obj.mibModel.loadImages('Load each N-th dataset', BatchOpt);
- loadMask(mask, BatchOptIn)¶
LOADMASK - Load a binary mask from file or import from a workspace array.
- Syntax:
obj.loadMask(mask, BatchOptIn)
This is the top-level BatchOpt-compatible wrapper for mask loading. It handles:
- FILE PATH - mask is empty; a file browser (GUI) or FilenameFilter
template (batch) is used to locate the file(s); loading is delegated to MibDataset.loadMask.
- IMPORT PATH - mask is a numeric or logical array; the array is
imported directly via MibDataset.loadMask.
- Input Arguments:
mask - (optional) raw mask array [H W D] or [H W D 1 T]
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.DirectoryName- [cell,{'Inherit from dataset filename'}] target dir.FilenameFilter- [char,'Mask_[F].mask'] filename or filter;[F]is expanded to the base name of the currently open image.showWaitbar- [logical,true] show progress dialog.id- [numeric] dataset index 1..9, default = currently active
- Output Arguments:
none
- Usage:
Example 1 - interactive file browser
obj.mibModel.loadMask();Example 2 - batch: load by name template
BatchOpt.DirectoryName = {'C:\data'}; BatchOpt.FilenameFilter = 'Mask_[F].mask'; obj.mibModel.loadMask([], BatchOpt);Example 3 - import from workspace array
rawMask = uint8(someLogicalVolume); obj.mibModel.loadMask(rawMask);
- loadModel(model, BatchOptIn)¶
LOADMODEL - Load a segmentation model from file or import from a workspace array.
- Syntax:
obj.loadModel(model, BatchOptIn)
This is the top-level BatchOpt-compatible wrapper for model loading. It handles:
FILE PATH - model is empty; a file browser (GUI) or FilenameFilter template (batch) is used to locate the file(s); the factory-pattern loaders in +io are dispatched through MibDataset.loadModel.
IMPORT PATH - model is a numeric array or a struct produced by mibImage.getData3D/4D or an export helper; metadata is unpacked from the struct before delegating to MibDataset.loadModel.
- Input Arguments:
model - (optional) raw model array (numeric) or struct with fields:
numeric- raw [H W D] or [H W D 1 T] label arraystruct- may contain:.modelMaterialNames,.modelMaterialColors,.modelType,.modelVariable,.labelText,.labelPosition,.labelValue, and a field whose name matches.modelVariable(or any field holding the array)
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.DirectoryName- [cell,{'Inherit from dataset filename'}] target dir.FilenameFilter- [char,{'Labels_[F].model'}] filename or wildcard filter;[F]is replaced with the image base name (no extension). Relative paths resolve againstDirectoryName; absolute paths bypass it. Wildcards (*) are expanded viadir()..showWaitbar- [logical,{true}] show progress dialog.id- [numeric,{obj.id}] dataset index 1..9
- Output Arguments:
none
- Usage:
Example 1 - interactive file browser
obj.mibModel.loadModel();Example 2 - batch: load by name template
BatchOpt.DirectoryName = {'C:\data'}; BatchOpt.FilenameFilter = 'Labels_[F].model'; obj.mibModel.loadModel([], BatchOpt);Example 3 - import from workspace array
rawArray = obj.mibModel.I{obj.mibModel.id}.getData3D('labels'); obj.mibModel.loadModel(rawArray);
- materialsActions(action, BatchOptIn)¶
MATERIALSACTIONS - Collection of actions related to materials of the model.
- Syntax:
status = obj.materialsActions(action, BatchOptIn)
Dispatches to the appropriate low-level method on MibDataset or MibLabels depending on the requested action: rename, add, import, insert, swap, reorder, or remove. Each action supports both interactive mode (with dialogs) and batch mode (via BatchOptIn).
- Input Arguments:
action - char, desired action. Provide only this parameter for interactive behaviour. One of:
'Rename material'- rename a single material (index 0 renames all from a comma-separated list)'Add material'- append a new material at the end of the list; delegates to obj.addMaterial'Import material'- import selected materials (names, colors, and voxels) from a saved model file into the current model; delegates to obj.importMaterial (Standard/Virtual datasets; BigData requires Phase 3)'Insert material'- insert a new material at an arbitrary position, shifting existing materials downward'Swap materials'- exchange two materials (pixel data + metadata)'Reorder materials'- rearrange all materials according to a permutation vector (small models only, maxMaterials < 256)'Export material'- [not yet ported] export a material to the MATLAB workspace'Save material to file'- [not yet ported] save a material to a file on disk'Remove material'- delete one or more materials; delegates to obj.removeMaterial
BatchOptIn - (optional) a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.Action- cell string with these options:'Rename material','Add material','Import material','Insert material','Swap materials','Reorder materials','Export material','Save material to file','Remove material'.MaterialIndex1- char, primary index(indices) of materials to perform required action; [default] index of the currently selected material in the segmentation table.MaterialIndex2- char, secondary index of materials for swapping of materials; [default] index of the selected AddTo material.MaterialName- char, new name for the material; [default''].showWaitbar- logical, show or not the waitbar; [default true].id- (optional), dataset index 1-9, default = obj.id
- Output Arguments:
status - logical, true when the action completed successfully
- Usage:
Example 1 - rename material 3
BatchOptIn.Action = {'Rename material'}; BatchOptIn.MaterialIndex1 = '3'; BatchOptIn.MaterialName = 'material3'; obj.mibModel.materialsActions([], BatchOptIn);Example 2 - remove materials 2,3,4,10
BatchOptIn.Action = {'Remove material'}; BatchOptIn.MaterialIndex1 = '2:4 10'; obj.mibModel.materialsActions([], BatchOptIn);
- moveLayers(SourceLayer, DestinationLayer, DatasetType, ActionType, BatchOptIn)¶
MOVELAYERS - Move datasets between the layers (selection, mask, labels).
- Syntax:
obj.moveLayers(SourceLayer, DestinationLayer, DatasetType, ActionType) obj.moveLayers(SourceLayer, Destinabuildtool testAlltionLayer, DatasetType, ActionType, BatchOptIn)
Move data between the selection, mask, and labels layers. Supports operations like moving selection to mask, or selection to a specified material of the labels layer.
- Input Arguments:
SourceLayer - [char] name of a layer to get data:
'selection','mask', or'labels'; can be empty[]DestinationLayer - [char] name of a layer to set data:
'selection','mask', or'labels'; can be empty[]DatasetType - [char] type of dataset to move:
'2D, Slice'- 2D mode, move only the shown slice[y,x]'3D, Stack'- 3D mode, move 3D dataset[y,x,z]'4D, Dataset'- 4D mode, move 4D dataset[y,x,z,t]
ActionType - [char] type of the desired action:
'add'- add source to destination'remove'- remove source from destination'replace'- replace destination with source
BatchOptIn (optional) - [struct] structure for batch processing mode; when
NaN, returns default options viaSyncBatchevent.id(optional) - [numeric] dataset index from 1 to 9 (default: currently shown dataset).blockModeSwitch- [logical] use or not the block mode.roiId- [char] ROI mode control;-1to disable.fillBg- [numeric] whenNaNcrops as rectangle; when a number fills out-of-ROI areas.y(optional) - [numeric][ymin, ymax]of the part of the dataset to take.x(optional) - [numeric][xmin, xmax]of the part of the dataset to take.z(optional) - [numeric][zmin, zmax]of the part of the dataset to take.t(optional) - [numeric][tmin, tmax]of the part of the dataset to take.SelectedMaterial- [char] index of the selected material.selectedAddToMaterial- [char] index of the selected add-to material.restrictSelectionToMaterial- [logical] limit selection only to the selected material.restrictSelectionToMask- [logical] perform actions only in masked areas.showWaitbar- [logical] show or hide the progress bar
Output Arguments:
Example 1 - add selection to mask:
obj.mibModel.moveLayers('selection', 'mask', '3D, Stack', 'add');Example 2 - replace selection with mask:
obj.mibModel.moveLayers('mask', 'selection', '3D, Stack', 'replace');
- static readerToIndex(reader)¶
READERTOINDEX - map a reader family name to its selectedFileFilter slot. ‘Default’ -> 1, ‘BioFormats’ -> 2, ‘OpenSlide’ -> 3 (default 1).
- relocateUserStats(statsFolder)¶
RELOCATEUSERSTATS - Keep the user statistics of this workstation in another folder.
- Syntax:
obj.relocateUserStats(statsFolder)
Points this workstation at
statsFolderand carries its own statistics over, so that moving to a shared folder (OneDrive, a network home) never costs the user their level. What happens, in order:this machine’s shard is written into
statsFolder- the points it earned belong to it and follow it;every shard in
statsFolderis summed, so the statistics already left there by other workstations are picked up immediately;the session baselines in
sessionSettings.UserStatsare reset to the new folder, so that the shard written on exit is computed against the right starting point.
Shards left behind in the previous folder are not deleted or moved. They may belong to other workstations, which are not this machine’s to relocate; a machine that is later pointed back at the old folder simply picks its own shard up again.
- Input Arguments:
statsFolder - [char] folder that should hold the statistics from now on; created when it does not exist
- Usage:
Example 1 - adopt the folder chosen by the user
chosenFolder = utils.dlgs.chooseUserStatsLocation(obj.view.gui, currentFolder); if ~isempty(chosenFolder); obj.mibModel.relocateUserStats(chosenFolder); end
See also: utils.dlgs.chooseUserStatsLocation, utils.loadUserStats, utils.saveUserStats, models.MibModel.getOwnStatsShard
- removeMaterial(BatchOptIn)¶
REMOVEMATERIAL - Remove one or more materials from the current model - wrapper around core.MibDataset.removeMaterial.
- Syntax:
obj.removeMaterial(BatchOptIn)
For models with 63 or 255 materials: prompts the user for material indices to remove, remaps the remaining materials to contiguous indices (1..N), and updates the materialNames/materialColors lists.
For models with 65535 or 4294967295 materials in interactive (non-batch) mode: squeezes all label indices to a contiguous range starting at 1 by renumbering every unique value, then calls addMaterial to re-register the next available index. With 2D objects (
labels.objects3Dfalse) only the shown XY slice is renumbered, since the numbering of such a model restarts on every slice; the slice is backed up first, so one Ctrl+Z restores it. In batch mode, the specified material pixel values are zeroed out without renumbering.In all cases the operation aborts when no model exists. After a successful removal, UpdateGuiWidgets and ShowImage events are fired so the segmentation table and image view refresh.
- Input Arguments:
BatchOptIn - a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.MaterialIndices- char, space- or comma-separated list of material indices to remove, e.g.'2'or'1 3'or'2,4,6:8'; [default''], pre-populated with the currently selected material index when one is selected in the segmentation table. For large model types (65535/4294967295) in batch mode the corresponding pixel values are zeroed; the squeeze-and-renumber operation is available in interactive mode only..showWaitbar- logical, show or not the waitbar [default true].id- (optional), dataset index from 1 to 9, default = obj.id
Output Arguments:
- Usage:
Example 1 - interactive remove with index dialog
obj.mibModel.removeMaterial();Example 2 - scripted / batch call
BatchOpt.MaterialIndices = '2 4'; BatchOpt.showWaitbar = false; obj.mibModel.removeMaterial(BatchOpt);
- renameMaterial(BatchOptIn)¶
RENAMEMATERIAL - Rename one or all materials of the current model.
- Syntax:
obj.renameMaterial(BatchOptIn)
For small models (63 or 255 materials): prompts the user for a new name for the selected material. Use MaterialIndex ‘0’ with a comma-separated MaterialName to rename all materials at once.
For large models (65535 or 4294967295 materials): the table holds only two material slots whose displayed names store the actual material index, so MaterialIndex addresses the slot (1 or 2) and MaterialName must be a number between 1 and the model capacity.
- Input Arguments:
BatchOptIn - (optional) a structure for batch processing mode; when NaN, returns a structure with default options via “SyncBatch” event
.MaterialIndex- char, 1-based row index of the material to rename in the segmentation table (for 65535+ models: the material slot, 1 or 2 - not the material index shown in the slot); use'0'to rename all materials at once (MaterialName must then be a comma-separated list); [default] row of the currently selected material in the segmentation table.MaterialName- char, new name for the material, or comma-separated list when MaterialIndex is'0'; [default''].showWaitbar- logical, show or not the waitbar; [default true].id- (optional), dataset index 1-9, default = obj.id
Output Arguments:
- Usage:
Example 1 - interactive rename with dialog
obj.mibModel.renameMaterial();Example 2 - scripted / batch call
BatchOpt.MaterialIndex = '3'; BatchOpt.MaterialName = 'Nucleus'; obj.mibModel.renameMaterial(BatchOpt);Example 3 - rename all three materials
BatchOpt.MaterialIndex = '0'; BatchOpt.MaterialName = 'A,B,C'; obj.mibModel.renameMaterial(BatchOpt);
- replaceMaskedArea(target, BatchOptIn)¶
REPLACEMASKEDAREA - Replace image intensities in the Masked or Selected area.
- Syntax:
obj.replaceMaskedArea() obj.replaceMaskedArea(target) obj.replaceMaskedArea(target, BatchOptIn) obj.replaceMaskedArea(NaN)
In GUI mode (no
BatchOptIn) shows a dialog to collect parameters. In batch mode accepts aBatchOptInstructure. PassNaNto return default options via theSyncBatchevent.- Input Arguments:
target - (optional) char, pre-sets
BatchOpt.Target{1}; pass[]or omit to use the BatchOptIn value or the default'mask'. One of:'mask','selection'. PassNaNto return default options via theSyncBatchevent.BatchOptIn - (optional) structure for batch processing mode
.Target- cell string, layer containing the mask:{'mask'}(default) or{'selection'}.ColorChannel- cell string, channel(s) to replace:{'All'}(default) or{'Ch N'}for a specific channel.ColorIntensity- 3-cell numeric{value, [0 maxInt], 'on'}; intensity written into every masked pixel (default{0, [0 Inf], 'on'}).showWaitbar- logical, show the progress dialog (defaulttrue).id- (optional) dataset index 1-9, default =obj.getActiveId().t- (optional)[t1 t2]time range;0= all time points.z- (optional)[z1 z2]z-slice range;0= all slices
- Output Arguments:
(none)
- Usage:
Example 1 - interactive dialog for mask layer
obj.mibModel.replaceMaskedArea('mask');Example 2 - interactive dialog for selection layer
obj.mibModel.replaceMaskedArea('selection');Example 3 - batch mode: set selection area on channel 1 to 128
BatchOpt.Target = {'selection'}; BatchOpt.ColorChannel = {'Ch 1'}; BatchOpt.ColorIntensity = {128, [0 255], 'on'}; obj.mibModel.replaceMaskedArea('selection', BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.replaceMaskedArea(NaN);
- resliceDataset(sliceNumbers, orientation, BatchOptIn)¶
RESLICEDATASET - Keep only specified slices; remove all others (stride-reslicing).
- Syntax:
obj.resliceDataset() obj.resliceDataset(sliceNumbers) obj.resliceDataset(sliceNumbers, orientation) obj.resliceDataset(sliceNumbers, orientation, BatchOptIn)
Batch-compatible dispatcher. Shows an interactive dialog when called without
BatchOptIn. Accepts MATLAB range expressions such as'1:10:end'in theSliceNumbersfield. Delegates toMibDataset.resliceDataset.- Input Arguments:
sliceNumbers - (optional) index vector of slices to keep, or
[]for interactive inputorientation - (optional) dimension to reslice:
1= height (y),2= width (x),3= depth (z). Default:obj.orientationof the active datasetBatchOptIn - (optional) struct for batch processing mode; when
NaN, returns default options via theSyncBatchevent..Dimension- [cell] reslice dimension (default:{'depth'}). Allowed values:{'height', 'width', 'depth'}.SliceNumbers- [string] MATLAB index expression;'end'is substituted with the actual maximum (default:'1:2:end').showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Usage:
Example 1 - interactive
obj.mibModel.resliceDataset();Example 2 - keep every 10th z-slice via batch
BatchOpt.Dimension = {'depth'}; BatchOpt.SliceNumbers = '1:10:end'; obj.mibModel.resliceDataset([], [], BatchOpt);
- saveBigDataModel(id, mode)¶
function saveBigDataModel(obj, id, mode) Persist a BigData model. Two modes:
- ‘full’materialize every pyramid level from the level map AND write the
level-map side-file, so the on-disk model is fully consistent at all resolutions (correct for export and any external reader). Can be slow on a large slide.
- ‘sidecar’write ONLY the level-map side-file (fast). Pixel edits are already
on disk (each edit is written live at its working level + coarser); the only volatile state is the in-memory level map. Persisting it is a cheap crash-safety checkpoint: after a crash a reopen can then reconstruct the deferred finer levels correctly instead of showing stale data. No materialization is performed.
During interactive segmentation a BigData model is only written at the level each edit was drawn (+ coarser); finer levels are reconstructed on demand (see
core.MibBigDataLabels.getData63/materializeForRead). ‘full’ performs that deferred work for every level at once.Parameters: id: [@em optional] index of the dataset; when omitted uses
obj.getActiveId(). mode: [@em optional]'full'(default) or'sidecar'.Return values:
@note no-op for non-BigData datasets or when no model exists.
- saveImage(layerType, filename, BatchOptIn)¶
SAVEIMAGE - Save image, mask, or labels layer; top-level BatchOpt-compatible wrapper.
- Syntax:
fnOut = obj.saveImage(layerType) fnOut = obj.saveImage(layerType, filename) fnOut = obj.saveImage(layerType, filename, BatchOptIn)
This is the highest-level save entry point. It replaces the three separate MIB2 functions (saveImageAsDialog / saveMask / saveModel) with a unified interface that declares a BatchOpt structure, handles the SyncBatch event, resolves output directory and filename policies, and delegates to
core.MibDataset.saveImagefor actual file writing.- Input Arguments:
layerType -
'image'|'mask'|'labels'|'everything'(MibLabels63 only)filename - (optional) full output path; when empty the path is resolved through the directory/filename policies below
BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the “SyncBatch” event
.LayerType- cell string,{'image'|'mask'|'labels'}layer to save.Format- cell string, output format (default depends on layer type).FilenamePolicy- cell string,{'Use existing name'}|{'Use new provided name'}.Filename- char, stem used when FilenamePolicy ='Use new…'; supports[F]template to embed the source stem:'Labels_[F]_suffix'→'Labels_myStack_suffix.model'.OutputDirectoryPolicy- cell string,{'Same as image'}|{'Subfolder'}|{'Full path'}|{'Same as loaded'}.DestinationDirectory- char, meaning depends on OutputDirectoryPolicy.FilenameGenerator- cell string,{'Use sequential filename'}|{'Use original filename'}.Saving3DPolicy- cell string,{'3D stack'}|{'2D sequence'}.MaterialIndex- char,''= all materials,'NaN'= current.showWaitbar- logical, show progress dialog.id- numeric, dataset index (default:obj.id)
- Output Arguments:
fnOut - char or cell of char; saved filename(s);
[]on failure
- Usage:
Example 1 - simple mode - save current image (GUI-based, asks dialogs as needed)
obj.mibModel.saveImage('image');Example 2 - simple mode with explicit filename (silent, no dialogs)
obj.mibModel.saveImage('image', '/output/stack.tif');Example 3 - scripted/batch mode - save image to a specific folder and format
BatchOpt.LayerType = {'image'}; BatchOpt.Format = {'TIF format LZW compression (``*.tif``)'}; BatchOpt.OutputDirectoryPolicy = {'Full path'}; BatchOpt.DestinationDirectory = '/output/tif_export'; BatchOpt.FilenamePolicy = {'Use existing name'}; BatchOpt.FilenameGenerator = {'Use sequential filename'}; BatchOpt.Saving3DPolicy = {'3D stack'}; BatchOpt.showWaitbar = false; BatchOpt.mibBatchTooltip.LayerType = ''; obj.mibModel.saveImage('image', [], BatchOpt);Example 4 - batch mode with [F] template - prefix saved name with dataset stem
BatchOpt.LayerType = {'labels'}; BatchOpt.Format = {'Matlab format (``*.model``)'}; BatchOpt.FilenamePolicy = {'Use new provided name'}; BatchOpt.Filename = 'Labels_[F]'; BatchOpt.OutputDirectoryPolicy = {'Subfolder'}; BatchOpt.DestinationDirectory = 'Models'; BatchOpt.Saving3DPolicy = {'3D stack'}; BatchOpt.showWaitbar = false; BatchOpt.mibBatchTooltip.LayerType = ''; obj.mibModel.saveImage('labels', [], BatchOpt);Example 5 - SyncBatch mode - let batch controller discover this function
obj.mibModel.saveImage('image', [], NaN);Example 6 - save mask in Amira format to same directory as source image
BatchOpt.LayerType = {'mask'}; BatchOpt.Format = {'Amira mesh binary (``*.am``)'}; BatchOpt.OutputDirectoryPolicy = {'Same as image'}; BatchOpt.FilenamePolicy = {'Use existing name'}; BatchOpt.Saving3DPolicy = {'3D stack'}; BatchOpt.showWaitbar = true; BatchOpt.mibBatchTooltip.LayerType = ''; obj.mibModel.saveImage('mask', [], BatchOpt);
See also
core.MibDataset.saveImage, core.MibImage.save, core.MibLabels.save, io.SaverFactory, utils.updateBatchOptCombineFields_Shared
- saveLabels(filename, BatchOptIn)¶
SAVELABELS - Save the segmentation model (labels layer) for the current dataset.
- Syntax:
fnOut = obj.saveLabels(filename, BatchOptIn)
Thin convenience wrapper around obj.saveImage(‘labels’, …). All BatchOpt machinery (SyncBatch, mibBatchSectionName, FilenamePolicy, directory resolution, [F] template) is implemented in saveImage and is fully available via this wrapper.
- Input Arguments:
obj - MibModel instance filename - (optional) (char) full output path. When empty ([]) a uiputfile dialog is shown. When omitted, the existing labels filename is reused with its extension forced to
.model(the Save button always writes the internal Matlab format; a prior “Save as…” to another format only defines the base filename). BatchOptIn - (optional) (struct | NaN) batch processing options. When NaN, fires SyncBatch event and returns without saving. See models.MibModel.saveImage for the full field list. - .Format - output format string - .FilenamePolicy - ‘Use existing name’ | ‘Use new provided name’ - .Filename - output filename stem (supports [F] template) - .OutputDirectoryPolicy - ‘Same as image’ | ‘Subfolder’ | ‘Full path’ | ‘Same as loaded’ - .DestinationDirectory - target folder - .Saving3DPolicy - ‘3D stack’ | ‘2D sequence’ - .MaterialIndex - ‘’ = all, ‘NaN’ = current, integer = specific material - .showWaitbar - logical - .id - (optional) dataset index 1-9, default = obj.id- Output Arguments:
fnOut - (char or cell of char) saved filename(s); [] on failure or cancel
- Usage:
Example 1 - save using existing filename
obj.mibModel.saveLabels();Example 2 - show save-as dialog
obj.mibModel.saveLabels([]);Example 3 - full batch mode
BatchOpt.Format = {'Matlab format (``*.model``)'}; BatchOpt.FilenamePolicy = {'Use existing name'}; BatchOpt.OutputDirectoryPolicy = {'Same as image'}; BatchOpt.Saving3DPolicy = {'3D stack'}; BatchOpt.showWaitbar = false; BatchOpt.mibBatchTooltip.LayerType = ''; obj.mibModel.saveLabels([], BatchOpt);
- saveMask(filename, BatchOptIn)¶
SAVEMASK - Save the binary mask layer for the current dataset.
- Syntax:
fnOut = obj.saveMask(filename, BatchOptIn)
Thin convenience wrapper around obj.saveImage(‘mask’, …). All BatchOpt machinery (SyncBatch, mibBatchSectionName, FilenamePolicy, directory resolution, [F] template) is implemented in saveImage and is fully available via this wrapper.
- Input Arguments:
obj - MibModel instance
filename (optional) - (char) full output path. When empty (
[]) a uiputfile dialog is shown. When omitted, the existing mask filename is used.BatchOptIn (optional) - (struct | NaN) batch processing options. When NaN, fires SyncBatch event and returns without saving. See models.MibModel.saveImage for the full field list.
.Format- output format string.FilenamePolicy-'Use existing name'|'Use new provided name'.Filename- output filename stem (supports[F]template).OutputDirectoryPolicy-'Same as image'|'Subfolder'|'Full path'|'Same as loaded'.DestinationDirectory- target folder.Saving3DPolicy-'3D stack'|'2D sequence'.showWaitbar- logical.id- (optional) dataset index 1-9, default =obj.id
- Output Arguments:
fnOut - (char or cell of char) saved filename(s);
[]on failure or cancel- Usage:
Example 1 - save using existing filename
obj.mibModel.saveMask();Example 2 - show save-as dialog
obj.mibModel.saveMask([]);Example 3 - full batch mode
BatchOpt.Format = {'Matlab format (``*.mask``)'}; BatchOpt.FilenamePolicy = {'Use existing name'}; BatchOpt.OutputDirectoryPolicy = {'Same as image'}; BatchOpt.Saving3DPolicy = {'3D stack'}; BatchOpt.showWaitbar = false; BatchOpt.mibBatchTooltip.LayerType = ''; obj.mibModel.saveMask([], BatchOpt);
- saveOverridePreferences(filename)¶
SAVEOVERRIDEPREFERENCES - Save the current preferences as a JSON override file for new users.
- Syntax:
numberOfSettings = obj.saveOverridePreferences(filename)
Writes the settings of the current session that differ from the MIB defaults (
utils.defaults.generatePreferences()) into a JSON file. Saved in the MIB program folder asmib3_prefs_override.jsonormib3_prefs_override_<COMPUTERNAME>.json, the file is picked up bymodels.MibModel.initializePreferences()on the first start of every user who does not yet havemib3.mat, so new users of a workstation start from the settings configured here instead of from the MIB defaults.Only the differences are written, which makes the file a partial override: a setting missing from it keeps the MIB default, including defaults changed by later MIB releases. A leaf is compared with
isequaln; vectors (colors, key shortcuts) and cell arrays are written whole when any element differs, and a struct whose default has no fields (DoNotShowDialogs) is written whole as well.Left out regardless of their value, because they are the state or history of the person who generates the file rather than settings of the workstation:
Users- statistics and tier definitionsSystem.Dirs.LastPath,System.Dirs.RecentDirs,System.Update.SinceLastCheckSystem.UserStatsProfile,System.UserStatsPromptShown- every user keeps their own statistics and is asked once where to store themTips.Files,Tips.CurrentTipIndexImageArithmetic.Actions,.InputVars,.OutputVarsVolRen.Animation.animationPathDeep.OriginalTrainingImagesDir,Deep.OriginalPredictionImagesDir,Deep.ResultingImagesDirDeep.SendReports.SMTP_password- the file is readable by every user
Fields of the current preferences that the defaults do not have (left over from an older MIB) are not written either.
File layout:
{ "_comment": ["what the file is and how it is used", "..."], "mibVersion": 2026.09, "preferences": { "System": { "_comment": {"MouseWheel": "'scroll' - the wheel changes slices; 'zoom' - ..."}, "MouseWheel": "zoom" } } }Every struct gets a
"_comment"object, keyed by the names of its own fields, describing the settings written next to it and their allowed values; a struct without any described field gets none.jsondecodereads the key back asx_comment, andinitializePreferencesdrops it. The descriptions live in the local functionpreferenceCommentsat the end of this file: when a preference with a restricted set of values is added togeneratePreferences, describe it there as well. A missing description is harmless, the setting is written without.JSON has no
Inf/NaN:jsonencodewould writenull, which reads back as[]. A non-finite element of a numeric scalar or vector is therefore written as the string"Inf","-Inf"or"NaN", whichinitializePreferencesconverts back. Non-finite values inside a 2-D matrix are not handled; no preference has them. Numeric and logical vectors are collapsed onto one line for readability.Colors - numeric settings whose name ends with
ColororColors(Colors.ModelMaterialColors,Colors.SelectionColor,VolRen.Viewer.backgroundColor, …) - are rounded to 3 decimals. The comparison with the default is made before rounding. A step of an 8-bit color channel is 1/255 = 0.0039, so the rounding is invisible, while a random material color would otherwise be written with 17 significant digits.Colors.ModelMaterialColorsis written with at most 255 rows. Opening the Preferences dialog copies the colors of the current dataset into preferences, and a 63-bit model carries 65535 of them, randomly generated; the dialog shows and edits only the first 255, and a model with more materials than colors gets the missing ones generated anyway.- Input Arguments:
filename - [char] full path of the JSON file to write
- Output Arguments:
numberOfSettings - [double] number of settings written to the file, 0 when the current preferences match the defaults; the file is written in that case too
- Usage:
Example 1 - save an override file for all workstations using this MIB installation
obj.mibModel.saveOverridePreferences(fullfile(obj.mibModel.mibPath, 'mib3_prefs_override.json'));
See also: models.MibModel.initializePreferences, utils.defaults.generatePreferences
- setAxesLimits(axesX, axesY, id)¶
SETAXESLIMITS - set axes limits for the currently shown or id dataset.
- Syntax:
obj.setAxesLimits(axesX, axesY, id)- Input Arguments:
id - (optional) id of the dataset, otherwise the currently shown dataset (obj.id)
- Output Arguments:
axesX - a vector [min, max] for X
axesY - a vector [min, max] for Y
- Usage:
Example 1 - set axes limits for the currently shown dataset
obj.mibModel.setAxesLimits([1 512], [1 512]);Example 2 - set axes limits for dataset 2
obj.mibModel.setAxesLimits([1 512], [1 512], 2);
- setData2D(dataset, type, slice_no, orient, col_channel, options)¶
SETDATA2D - Set a 2D slice in the current (or specified) dataset; wrapper around core.MibDataset.setData2D.
- Syntax:
result = obj.setData2D(dataset, type, slice_no, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.setData2D(…) instead of obj.mibModel.I{obj.mibModel.id}.setData2D(…). All argument semantics are identical to core.MibDataset.setData2D.
- Input Arguments:
dataset - 2D image data - matrix or cell array; see
MibDataset.setData2Dtype - type of the dataset layer to update:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
slice_no - (optional) slice index;
[]= current sliceorient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.t- seeMibDataset.setData2D
- Output Arguments:
result - logical; true on success, false on failure
- Usage:
Example 1 - update selection on current slice
result = obj.mibModel.setData2D(slice, 'selection');Example 2 - slice 5, XY orient, ch 2
result = obj.mibModel.setData2D(slice, 'image', 5, 3, 2);
- setData3D(dataset, type, time, orient, col_channel, options)¶
SETDATA3D - Set a 3D dataset in the current (or specified) dataset; wrapper around core.MibDataset.setData3D.
- Syntax:
result = obj.setData3D(dataset, type, time, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.setData3D(…) instead of obj.mibModel.I{obj.mibModel.id}.setData3D(…). All argument semantics are identical to core.MibDataset.setData3D.
- Input Arguments:
dataset - 3D image data - matrix or cell array; see
MibDataset.setData3Dtype - type of the dataset layer to update:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
time - (optional) time-point index;
[]= current time pointorient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.z,.PixelIdxList- seeMibDataset.setData3D
- Output Arguments:
result - logical; true on success, false on failure
- Usage:
Example 1 - update full selection volume
result = obj.mibModel.setData3D(volume, 'selection');Example 2 - time 5, XY orient
result = obj.mibModel.setData3D(volume, 'image', 5, 3);Example 3 - fast pixel-list update
opt.PixelIdxList = pixelIndices; result = obj.mibModel.setData3D(values, 'selection', [], [], NaN, opt);
- setData4D(dataset, type, orient, col_channel, options)¶
SETDATA4D - Set the complete 4D dataset in the current (or specified) dataset; wrapper around core.MibDataset.setData4D.
- Syntax:
result = obj.setData4D(dataset, type, orient, col_channel, options)
This is a thin convenience wrapper so controllers can call obj.mibModel.setData4D(…) instead of obj.mibModel.I{obj.mibModel.id}.setData4D(…). All argument semantics are identical to core.MibDataset.setData4D.
- Input Arguments:
dataset - 4D image data - matrix or cell array; see
MibDataset.setData4Dtype - type of the dataset layer to update:
'image'- [default] the image layer'labels'- labels layer with segmentation'mask'- mask layer'selection'- selection layer'everything'- packed model/mask/selection (MibLabels63 only)
orient - (optional) orientation;
[]= current orientationcol_channel - (optional) colour channel(s);
[]= current channels;NaN= alloptions - (optional) struct with extra parameters:
.id- (optional) dataset index 1-9; default =obj.id.blockModeSwitch,.roiId,.fillBg,.x,.y,.z,.t,.replaceDatasetSwitch,.keepModel- seeMibDataset.setData4D
- Output Arguments:
result - logical; true on success, false on failure
- Usage:
Example 1 - replace full dataset
result = obj.mibModel.setData4D(dataset, 'image');Example 2 - XY orient, ch 2
result = obj.mibModel.setData4D(dataset, 'image', 3, 2);
- setDefaultColorPalette(paletteName, colorsNo, randomSeed)¶
SETDEFAULTCOLORPALETTE - set default color palette for materials of the model.
- Syntax:
obj.setDefaultColorPalette(paletteName, colorsNo, randomSeed)- Input Arguments:
paletteName - string with the name of the palette to use, see utils.defaults.generateDefaultPalette for the full list of options; two special values are also accepted:
‘current2default’ - copy current model colors to preferences as default
‘default2current’ - restore model colors from preferences default
colorsNo - (optional) numeric, number of required color channels
randomSeed - (optional) seed for the ‘Random Colors’ palette; when omitted or empty, a dialog asking for the seed is shown. Use ‘shuffle’ to seed the generator from the system clock and skip the dialog
Output Arguments:
- Usage:
Example 1 - select the default color scheme with 6 colors
obj.mibModel.setDefaultColorPalette('Default, 6 colors');Example 2 - set “Qualitative (Monte Carlo->Half Baked)” palette with 6 colors
obj.mibModel.setDefaultColorPalette('Qualitative (Monte Carlo->Half Baked), 3-12 colors', 6);Example 3 - generate random colors without asking for the random seed
obj.mibModel.setDefaultColorPalette('Random Colors', [], 'shuffle');
- setMagFactor(magFactor, id)¶
SETMAGFACTOR - set magnification for the currently shown or id dataset.
- Syntax:
obj.setMagFactor(magFactor, id)- Input Arguments:
magFactor - magnification factor
id - (optional) id of the dataset, otherwise the currently shown dataset (obj.id)
Output Arguments:
- Usage:
Example 1 - set current magFactor to 2
obj.mibModel.setMagFactor(2);Example 2 - set magFactor to 2 for dataset 4
obj.mibModel.setMagFactor(2, 4);
- smoothImage(type, BatchOptIn)¶
SMOOTHIMAGE - Smooth ‘Mask’, ‘Selection’, or ‘Labels’ layer with a Gaussian kernel.
- Syntax:
obj.smoothImage(type) obj.smoothImage(type, BatchOptIn)
Applies a Gaussian blur to the binary content of a selection, mask, or labels layer. The blurred result is stored back (MATLAB’s
imfilterclips to the uint8 range, so edge pixels below the threshold become 0, effectively rounding the corners of the selection). Supports 2D (slice-by-slice) and 3D (separable Gaussian) modes, and can operate on a single material or a range of materials of the labels layer.- Input Arguments:
type - char, layer to smooth:
'selection','mask', or'labels'; pass''to default to'selection'BatchOptIn - (optional) structure for batch processing mode; when NaN, returns default options via the
SyncBatchevent.Target- cell string,{'selection','mask','labels'}.SmoothingMode- cell string,{'2D','3D'}.KernelSizeX- numeric{val, [min max], 'on'}, X kernel size in pixels.KernelSizeY- numeric{val, [min max], 'on'}, Y kernel size in pixels;0= auto (square, same size as X).KernelSizeZ- numeric{val, [min max], 'on'}, Z kernel size in pixels (3D only).Sigma- numeric{val, [min max], 'off'}, Gaussian sigma.MaterialIndex- string, index or range of labels materials, e.g.'1'or'1,3'or'2:4'.showWaitbar- logical, show or not the progress dialog.id- (optional) dataset index 1-9, default =obj.getActiveId()
- Output Arguments:
(none)
- Usage:
Example 1 - smooth selection on the current dataset with interactive dialog
obj.mibModel.smoothImage('selection');Example 2 - 3D Gaussian smoothing of the mask layer, sigma=2, 7-pixel kernel
BatchOpt.Target = {'mask'}; BatchOpt.SmoothingMode = {'3D'}; BatchOpt.KernelSizeX = {7, [1 100], 'on'}; BatchOpt.KernelSizeZ = {7, [1 100], 'on'}; BatchOpt.Sigma = {2, [0.01 100], 'off'}; BatchOpt.showWaitbar = true; obj.mibModel.smoothImage('mask', BatchOpt);Example 3 - smooth material 2 of the labels layer
BatchOpt.Target = {'labels'}; BatchOpt.MaterialIndex = '2'; obj.mibModel.smoothImage('labels', BatchOpt);Example 4 - return default BatchOpt to the Batch Processing editor
obj.mibModel.smoothImage('', NaN);
- stitchModelInstances(BatchOptIn)¶
STITCHMODELINSTANCES - Stitch per-slice 2D instance labels into a 3D instance model.
- Syntax:
obj.stitchModelInstances() obj.stitchModelInstances(BatchOptIn)
Treats the active labels layer as a stack of independently generated 2D instance segmentations (per-slice indices, not consistent across slices) and links overlapping objects between neighbouring slices into single 3D instances with one consistent index through the whole stack. Wrapper around
core.MibDataset.stitchModelInstances(), which in turn callsutils.instances.stitch2Dto3D().When called interactively (no
BatchOptInor a struct without.Method) a settings dialog is shown to pick the linking strategy and thresholds. The current model is backed up first, so the operation can be undone (Ctrl+Z).- Input Arguments:
BatchOptIn (optional) - structure for batch processing; pass
NaNto return default options via theSyncBatchevent.Method- cell string dropdown selecting the linking strategy:'graph'(default) - link every pair of overlapping objects on neighbouring slices, then group the links into 3D objects by connected components. Naturally handles objects that split into several pieces or merge together between slices.'hungarian'- strict one-to-one matching per slice pair (empanada / MitoNet style), plus a containment merge for the leftovers.
.SplitDisconnected2D- logical checkbox. Whentrue(default) each connected blob of a per-slice index is treated as its own 2D object. 2D instance predictors regularly give one index to several separate blobs; keeping them as one object welds their 3D chains together, and the welds chain across slices until most of the stack is a single giant instance. Uncheck only when the per-slice indices are trusted and a genuinely disconnected 2D mask must stay one object..IoUThreshold- Intersection-over-Union link threshold, range 0-1. For two objects on adjacent slices,IoU = overlapping pixels / pixels in either object; they are joined into one 3D object when IoU exceeds this value. Higher = only near-identical cross-sections are joined (more, smaller 3D objects); lower = looser joining (fewer, larger objects)..IoAThreshold- logical checkbox: enable Intersection-over-Area merging of split objects. Whentrue(default), two objects are also joined whenoverlapping pixels / pixels in the *smaller* objectis high (one is mostly contained in the other), reconnecting a 3D object that briefly breaks into small fragments on one slice. Whenfalse, objects are linked by IoU only. (Internally maps to an IoA threshold of0.5when enabled,Infwhen disabled.).MinOverlapPixels- absolute minimum number of overlapping pixels before two objects may be linked; stops a 1-2 px touch between unrelated objects from fusing them..AbsOverlapPixels- link two objects whose overlap reaches this many pixels whatever their IoU and IoA (0= disabled). IoU and IoA are both ratios against object area, so a large cross-section meeting a much smaller one scores low on each even when the shared area is substantial. This is a sufficient condition added to the ratio tests, the opposite role fromMinOverlapPixels, which is a guard applied to all of them. The right value depends on object size in the dataset..ZLookback- how many slices apart to compare.1= only directly adjacent slices;2+also compares a slice with the one 2 (or more) planes away, so an object that vanishes for a slice or two is reconnected..MinObjectVoxels- after stitching, delete any 3D object smaller than this many voxels (0= keep all); useful for removing tiny single-slice noise fragments..MinObjectSlices- after stitching, delete any 3D object that appears on this many Z-slices or fewer (0= keep all,1= drop single-slice objects,2= also drop those seen on two slices). Catches the noiseMinObjectVoxelscannot: a false detection may be large in-plane yet never propagate through the stack..AbsorbFragmentVoxels- after stitching, give any 3D object of this size or smaller to the object surrounding it in-plane [default5, matchingMinOverlapPixels- the size below which an object can never be linked at all;0= off]. 2D predictors leave stray pixels inside or on the rim of a neighbouring mask; being smaller thanMinOverlapPixelsthey can never be linked and survive as specks, usually a hole in an otherwise solid object. Deleting them withMinObjectVoxelsleaves the hole, and relaxingMinOverlapPixelsinstead is unsafe - a speck touching two different objects on consecutive slices would then weld them together. A fragment with no labelled neighbour is left forMinObjectVoxels..UseAnisotropy- logical. Whentrue, the IoU link threshold is lowered by the dataset voxel aspect ratiopixSize.z / pixSize.xso a real but displaced continuation still links across thick Z sections. IoA (containment) is unaffected. Pair withMaxCentroidShiftto stop the relaxed threshold from fusing distant objects [defaultfalse]..MaxCentroidShift- reject a link when the two object centroids are more than this many pixels apart (scaled by the slice gap whenZLookback> 1);0= disabled..CentroidLinkRadius- advanced centroid nearest-neighbour gap bridging: link an object that has no overlapping neighbour to the mutually-nearest such orphan on the next compared slice within this many pixels (scaled by the slice gap), when of comparable size. Reconnects a displaced or briefly-missing continuation on anisotropic/gappy data;0= disabled..showWaitbar- logical, show or not the waitbar [defaulttrue].id- (optional) dataset index 1-9; default = active dataset
- Output Arguments:
(none)
Example - stitch the active model with default (graph) settings
obj.mibModel.stitchModelInstances();
- transformDataset(BatchOptIn)¶
TRANSFORMDATASET - Dispatcher for dataset geometry transform operations.
- Syntax:
status = obj.transformDataset(BatchOptIn)
Orchestrates all dataset shape and orientation transforms for the active
MibDataset. Validates preconditions (virtual mode, backup), then delegates to the appropriateMibDatasetsub-method. Fully batch-compatible.- Input Arguments:
BatchOptIn - (optional) structure for batch processing mode; when
NaN, returns default options via theSyncBatchevent..Transform- [cell] transform to apply (default:{'Flip horizontally'}). Allowed values:{'Flip horizontally','Flip vertically','Flip Z','Flip T''Rotate 90 degrees','Rotate -90 degrees''Transpose YX -> YZ','Transpose YX -> XZ','Transpose YX -> XY','Transpose YX -> ZX''Transpose Z<->T','Transpose Z<->C''Update with new width/height','Update with new dX/dY'}.Position- [cell] image position for'Update with new width/height'(default:{'Center'}). Allowed values:{'Center','Left-upper corner','Center-top','Right-upper corner','Left-bottom corner','Center-bottom','Right-bottom corner'}.NewImageWidth- [numeric cell] new width in pixels for'Update with new width/height';{1}value (default:0),{2}limits[1, Inf],{3}'on'(integer).NewImageHeight- [numeric cell] new height in pixels for'Update with new width/height';{1}value (default:0),{2}limits[1, Inf],{3}'on'(integer).FrameColorIntensity- [numeric cell] fill pixel intensity for'Update with new width/height';{1}value (default:0),{2}limits[0, Inf],{3}'off'.FrameWidth- [numeric cell] frame half-width in pixels for'Update with new dX/dY';{1}value (default:0),{2}limits[-Inf, Inf],{3}'on'(integer).FrameHeight- [numeric cell] frame half-height in pixels for'Update with new dX/dY';{1}value (default:0),{2}limits[-Inf, Inf],{3}'on'(integer).IntensityPadValue- [numeric cell] pad intensity for'Update with new dX/dY';{1}value (default:0),{2}limits[0, Inf],{3}'off'.Method- [cell] pad method for'Update with new dX/dY'(default:{'use the pad value'}). Allowed values:{'use the pad value','replicate','circular','symmetric'}.Direction- [cell] pad direction for'Update with new dX/dY'(default:{'both'}). Allowed values:{'both','pre','post'}.NumberOfColorChannels- [numeric cell] output color channels for'Transpose Z<->C';{1}value (default:NaN= auto),{2}limits[0, Inf],{3}'on'(integer).showWaitbar- [logical] show the progress dialog (default:true).id- (optional) dataset index 1-9, default =obj.getActiveId()
- Output Arguments:
status -
1on success,0on failure or user cancel
- Usage:
Example 1 - flip the current dataset horizontally
obj.mibModel.transformDataset();Example 2 - rotate 90 degrees via batch call
BatchOpt.Transform = {'Rotate 90 degrees'}; BatchOpt.showWaitbar = false; obj.mibModel.transformDataset(BatchOpt);Example 3 - return default BatchOpt to the Batch Processing editor
obj.mibModel.transformDataset(NaN);
- undo(newIndex)¶
UNDO - Undo/redo the recent changes (Ctrl+Z shortcut).
- Syntax:
obj.undo(newIndex)
Restores a previously stored dataset state from the Backup history. Works with all layer types: image, selection, mask, model, everything, modelLayers, annotations, lines3d, measurements, and mibDataset.
Entries holding a pixel snapshot of a segmentation layer carry the model type they were captured at (
storeOptions.modelType). When the live labels layer has since changed type, it is converted back before the snapshot is applied and the current layers are kept for redo as a'modelLayers'entry - seecore.MibDataset.copyModelLayers().- Input Arguments:
newIndex - (optional) index of the dataset to restore. When omitted (or NaN), restores the last stored dataset (Ctrl+Z behavior). When provided, navigates the undo history to the specified index (toolbar arrow button behavior).
Output Arguments:
- Usage:
Example 1 - undo last action (Ctrl+Z shortcut handler in mibController)
if obj.mibModel.Backup.enableSwitch == 0; return; end if obj.mibModel.Backup.prevUndoIndex == 0; return; end obj.mibModel.undo(); obj.showImage();Example 2 - navigate to a specific index in the undo history (toolbar arrow button)
obj.mibModel.undo(3); obj.showImage();Example 3 - typical backup + undo workflow from a controller
obj.mibModel.backup('selection', 0); obj.mibModel.I{obj.mibModel.id}.setData2D(newSelection, 'selection', sliceNo, [], NaN); obj.mibModel.undo();Example 4 - undo with 3D data - backup and undo work symmetrically
obj.mibModel.backup('mask', 1); obj.mibModel.undo();Example 5 - undo for image type - also restores metadata (dimensions, pixSize, viewPort)
obj.mibModel.backup('image', 0); obj.mibModel.undo();