MibSelection

class controllers.MibSelection

MIBSELECTION - controller for methods of the Selection and View settings panel in MIB.

Constructor Summary
MibSelection(mainCtrl, view, guiHandles, model)

MIBSELECTION - Initialize Selection panel controller.

Syntax:
obj = MibSelection(mainCtrl, view, guiHandles, model)
Input Arguments:
  • mainCtrl - [controllers.MibController] handle to main MIB controller

  • view - [views.MibView] handle to main MIB view

  • guiHandles - [struct] GUI component handles for the Selection panel

  • model - [models.MibModel] handle to MIB model

Output Arguments:
  • obj - [MibSelection] initialized Selection panel controller instance

Property Summary
UIFigure

handle to underlying UIFigure

gui

handle to the GUI of the ROI panel (views.components.Roi)

handles

struct of ROI panel handles (panel, listbox, buttons, …)

listeners

cell array of listeners

mibController

controllers.MibController

mibModel

models.MibModel

view

MibView (full app view)

Method Summary
clearSelection()

CLEARSELECTION - Clear the Selection layer for the current dataset.

Syntax:
obj.clearSelection()
Reads modifier keys held at call time to decide the clear scope:
  • no modifier ‘2D, Slice’ (current slice only)

  • Alt or Shift ‘3D, Stack’ (full z-stack at current t)

  • Alt + Shift ‘4D, Dataset’ (entire dataset)

When only one time point is present, ‘4D, Dataset’ is demoted to ‘3D, Stack’ automatically.

The method simply delegates to obj.mibModel.clearSelection with the appropriate scope string; all backup, waitbar, and event handling is done there.

Input Arguments:

(none)

Output Arguments:

(none)

Usage:

Example 1:

obj.clearSelection();   // called from the Clear button callback or keyboard shortcut
dilateSelection()

DILATESELECTION - Expand (dilate) the Selection layer for the current dataset.

Syntax:
obj.dilateSelection()

Reads modifier keys to determine the dataset scope, then reads the Apply-in-3D, Difference and Strel-size widgets from the Selection panel. When Apply-in-3D is checked the user is asked to confirm before proceeding, and the scope is promoted to at least ‘3D, Stack’. All heavy lifting is delegated to obj.mibModel.dilateImage.

Modifier-key scope rules (same as erodeSelection and clearSelection):
  • no modifier ‘2D, Slice’ (current slice only)

  • Alt or Shift ‘3D, Stack’ (full z-stack at current t)

  • Alt + Shift ‘4D, Dataset’ (entire dataset)

When only one time point is present, ‘4D, Dataset’ is demoted to ‘3D, Stack’ automatically.

Input Arguments:

(none)

Output Arguments:

(none)

Usage:

Example 1:

obj.dilateSelection();  // called from the Dilate button callback

Example 2 - Simulated call with 3D strel confirmed:

% Simulated call with 3D strel confirmed:
% (modifier keys are read automatically; no arguments needed)
obj.mibController.cImageDoc{1}.dilateSelection();
erodeSelection()

ERODESELECTION - Shrink (erode) the Selection layer for the current dataset.

Syntax:
obj.erodeSelection()

Reads modifier keys to determine the dataset scope, then reads the Apply-in-3D, Difference and Strel-size widgets from the Selection panel. When Apply-in-3D is checked the user is asked to confirm before proceeding, and the scope is promoted to at least ‘3D, Stack’. All heavy lifting is delegated to obj.mibModel.erodeImage.

Modifier-key scope rules (same as clearSelection):
  • no modifier ‘2D, Slice’ (current slice only)

  • Alt or Shift ‘3D, Stack’ (full z-stack at current t)

  • Alt + Shift ‘4D, Dataset’ (entire dataset)

When only one time point is present, ‘4D, Dataset’ is demoted to ‘3D, Stack’ automatically.

Input Arguments:

(none)

Output Arguments:

(none)

Usage:

Example 1:

obj.erodeSelection();  // called from the Erode button callback

Example 2 - Simulated call with 3D strel confirmed:

% Simulated call with 3D strel confirmed:
% (modifier keys are read automatically; no arguments needed)
obj.mibController.cImageDoc{1}.erodeSelection();
fillSelection()

FILLSELECTION - Fill holes in the Selection layer for the current dataset.

Syntax:
obj.fillSelection()

Reads modifier keys to determine the dataset scope, then reads the restrictSelectionToMaterial state from the dataset and delegates to obj.mibModel.fillSelectionOrMask.

Modifier-key scope rules (same as erodeSelection, dilateSelection, clearSelection):
  • no modifier ‘2D, Slice’ (current slice only)

  • Alt or Shift ‘3D, Stack’ (full z-stack at current t)

  • Alt + Shift ‘4D, Dataset’ (entire dataset)

When only one time point is present, ‘4D, Dataset’ is demoted to ‘3D, Stack’ automatically.

Input Arguments:

(none)

Output Arguments:

(none)

Usage:

Example 1:

obj.fillSelection();  // called from the Fill button callback or keyboard shortcut
getStrelSizeString()

GETSTRELSIZESTRING - build the StrelSize string from the strel1/strel2 panel widgets.

Syntax:
strelSize = obj.getStrelSizeString()

strel2 (obj.view.handles.panels.selection.handles.strel2) is an optional numeric field (AllowEmpty); when left blank the result is a single-value isotropic size, when filled in it is appended as the second (anisotropic) radius for utils.parseStrelSize.

Output Arguments:
  • strelSize - [char] '5' or '5 2', ready for utils.parseStrelSize

gui_Callbacks(hWidget, hData)

GUI_CALLBACKS - callbacks for widgets of some the Segmentation panel obj.handles.panels.segmentation.

Syntax:
obj.gui_Callbacks(hWidget, hData)
Input Arguments:
  • hWidget - [Button|CheckBox|DropDown|EditField|Slider] pressed widget with .Tag property identifying the action:

    • 'add' - add selection to material/mask

    • 'subtract' - subtract selection from material/mask

    • 'replace' - replace material/mask using current selection

    • 'clear' - clear selection

    • 'fill' - fill selection

    • 'colChannel' - select color channel

    • 'applySegmentationIn3D' - apply segmentation tools in 3D

    • 'autoFillSelection' - auto-fill selection

    • 'preset1' - apply preset 1 to selected segmentation tool

    • 'preset2' - apply preset 2 to selected segmentation tool

    • 'preset3' - apply preset 3 to selected segmentation tool

    • 'erode' - erode selection

    • 'dilate' - dilate selection

    • 'strel1' - set XY strel radius for erosion/dilation

    • 'strel2' - set Z (3D) or X (2D anisotropic) strel radius for erosion/dilation

    • 'differenceSelection' - enable difference mode for dilate/erode

    • 'lutColors' - visualize image using LUT colors

    • 'showModel' - show model layer

    • 'showMask' - show mask layer

    • 'showAnnotations' - show annotations

    • 'hideImage' - hide image

    • 'display' - start image view settings dialog

    • 'onFly' - automatically adjust contrast and brightness

    • 'modelTransparency' - adjust model transparency

    • 'maskTransparency' - adjust mask transparency

    • 'selectionTransparency' - adjust selection transparency

    • 'help' - show help

  • hData - [ValueChangedData|ValueChangingData|ButtonPushedData] event data from widget callback

listener_updatePanelPosition(src, evtData)

LISTENER_UPDATEPANELPOSITION - Adapt Selection panel grid layout when docked to different AppContainer region.

Syntax:
obj.listener_updatePanelPosition(src, evtData)

The Selection panel uses a mainGridLayout with sub-grids that are transposed when the panel moves:

  • Bottom - horizontal 5-column layout: ColumnWidth = {320, 3, 320, 3, '1x'}; RowHeight = {'1x'} ColumnSpacing = 10, RowSpacing = 4; Padding = [10 8 10 6]

  • Left/Right - vertical 5-row layout: RowHeight = {130, 3, 130, 3, 1}; ColumnWidth = {'1x'} RowSpacing = 10, ColumnSpacing = 4; Padding = [8 10 6 10]

Each child grid’s Layout.Column (bottom) becomes Layout.Row (vertical) and vice-versa.

Input Arguments:
  • obj - [MibSelection] this controller instance

  • src - [uipanel] the panel whose property changed (obj.view.handles.panels.selectionPanel)

  • evtData - [PropertyChangedData] event data; .PropertyName checked for 'Region'

listners_Callbacks(src, evtData)

LISTENERS_CALLBACKS - Generic callback on getting listeners events

Syntax:
obj.listners_Callbacks(src, evtData)
Input Arguments:
  • obj - handle to the Graphcut controller

  • evnt - event data; evnt.EventName is inspected for dispatch

lutTable_CellEditCallback(hWidget, hData, keyModifier)

LUTTABLE_CELLEDITCALLBACK - callbacks for cell edit in the LUT table (obj.handles.lutTable) of the Selection and Image View panel.

Syntax:
obj.lutTable_CellEditCallback(hWidget, hData, keyModifier)
Input Arguments:
  • hWidget - [uitable] handle to the LUT table widget

  • hData - [CellEditData] edit event data with properties:

    • .Indices - [1×2 numeric] [row, col] indices of edited cell

    • .PreviousData - old value before edit

    • .NewData - new value after edit

    • .Source - [uitable] handle to the table

    • .EventName - 'CellEdit' event name

  • keyModifier - [char|empty] pressed modifier key: [], 'control', or 'shift' (default: read from Figure.CurrentModifier)

lutTable_CellSelection(hWidget, hData)

LUTTABLE_CELLSELECTION - callbacks for cell selection in the LUT table (obj.handles.lutTable) of the Selection and Image View panel.

Syntax:
obj.lutTable_CellSelection(hWidget, hData)
Input Arguments:
  • hWidget - [uitable] handle to the LUT table widget

  • hData - [CellSelectionChangeData] cell selection event data with properties:

    • .Indices - [M×2 numeric] indices of selected cells [row, col]

    • .DisplayIndices - [M×2 numeric] display indices of selected cells

    • .Source - [uitable] handle to the table (lutTable)

    • .EventName - 'CellSelection' event name

lutTable_ContextMenu(menuEntry, selectedData)

LUTTABLE_CONTEXTMENU - callbacks for the context menu of the LUT table widget.

Syntax:
obj.lutTable_ContextMenu(menuEntry, selectedData)
Input Arguments:
  • menuEntry - [matlab.ui.container.Menu] pressed context menu entry

  • selectedData - [MenuSelectedData] menu event data; use .ContextObject to find source widget

Available menu options (from menuEntry.Tag):

  • 'lutTableContextInsert' - insert an empty color channel

  • 'lutTableContextCopy' - copy selected color channel to a new one

  • 'lutTableContextInvert' - invert selected color channel

  • 'lutTableContextRotate' - rotate selected color channel

  • 'lutTableContextShift' - shift selected color channel

  • 'lutTableContextSwap' - swap two color channels

  • 'lutTableContextDelete' - delete selected color channel

  • 'lutTableContextSetLUT' - select new color for selected color channel (LUT mode)

lutTable_update_fromModel()

LUTTABLE_UPDATE_FROMMODEL - Update obj.view.handles.panels.selection.handles.lutTable table and.

Syntax:
obj.lutTable_update_fromModel()

obj.view.handles.panels.selection.handles.colChannel color dropdown from obj.mibModel

Input Arguments:

Output Arguments:

selectionActions(action)

SELECTIONACTIONS - Wrapper for Add/Subtract/Replace buttons to move selection to material/mask.

Syntax:
obj.selectionActions(action)

Determines destination layer (mask or model) from selected “Add to” material index, reads dataset scope from modifier keys, then delegates to obj.mibModel.moveLayers.

Input Arguments:
  • action - [char] the button that was pressed:

    • 'add' - add selection to active material/mask

    • 'subtract' - subtract selection from active material/mask

    • 'replace' - replace active material/mask with selection

Example 1 - called from Add button:

obj.selectionActions('add');

Example 2 - called from Subtract button:

obj.selectionActions('subtract');

Example 3 - called from Replace button:

obj.selectionActions('replace');
selectionPanelCheckboxes(BatchOptIn)

SELECTIONPANELCHECKBOXES - Read or modify checkbox states and color-channel dropdown in Selection panel.

Syntax:
obj.selectionPanelCheckboxes(BatchOptIn)

Batch-compatible method for the Selection and View Settings panel. Checkbox fields accept three string values: 'Unchanged' (leave as-is, default), 'Checked' (enable feature), or 'Unchecked' (disable feature). ColorChannel: empty string = do not modify; '0' = All channels; '1', '2', etc. = individual channels.

Input Arguments:
  • BatchOptIn - [struct] batch options structure with fields:

    • .Apply3D - [cell] checkbox state ('Unchanged', 'Checked' or 'Unchecked') - Apply-in-3D checkbox

    • .AutoFillSelection - [cell] checkbox state - Auto-fill checkbox

    • .Difference - [cell] checkbox state - Difference mode checkbox (erode/dilate)

    • .LutColors - [cell] checkbox state - LUT colors checkbox

    • .ShowModel - [cell] checkbox state - Show model overlay checkbox

    • .ShowMask - [cell] checkbox state - Show mask overlay checkbox

    • .ShowAnnotations - [cell] checkbox state - Show annotations/measurements checkbox

    • .HideImage - [cell] checkbox state - Hide image checkbox

    • .OnFly - [cell] checkbox state - On-fly contrast stretch checkbox

    • .ColorChannel - [char] channel selection: '' (do not modify), '0' (All channels), '1'/'2'/… (specific channels)

Example 1 - Enable Apply-in-3D mode:

BatchOptIn.Apply3D = {'Checked'};
obj.mibController.cSelection.selectionPanelCheckboxes(BatchOptIn);

Example 2 - Show model overlay and switch to color channel 1:

BatchOptIn.ShowModel    = {'Checked'};
BatchOptIn.ColorChannel = '1';
obj.mibController.cSelection.selectionPanelCheckboxes(BatchOptIn);

Example 3 - Hide image and show mask only (mask QC):

BatchOptIn.HideImage  = {'Checked'};
BatchOptIn.ShowMask   = {'Checked'};
BatchOptIn.ShowModel  = {'Unchecked'};
obj.mibController.cSelection.selectionPanelCheckboxes(BatchOptIn);

Example 4 - Enable LUT colors and on-fly contrast stretch:

BatchOptIn.LutColors = {'Checked'};
BatchOptIn.OnFly     = {'Checked'};
obj.mibController.cSelection.selectionPanelCheckboxes(BatchOptIn);

Example 5 - Reset all display flags (clean-slate view):

BatchOptIn.ShowModel       = {'Unchecked'};
BatchOptIn.ShowMask        = {'Unchecked'};
BatchOptIn.ShowAnnotations = {'Unchecked'};
BatchOptIn.HideImage       = {'Unchecked'};
BatchOptIn.LutColors       = {'Unchecked'};
BatchOptIn.OnFly           = {'Unchecked'};
obj.mibController.cSelection.selectionPanelCheckboxes(BatchOptIn);

Example 6 - Populate the Batch Processing parameter table with default options:

% Populate the Batch Processing parameter table with default options
obj.mibController.cSelection.selectionPanelCheckboxes(NaN);
showModel_ContextMenu(menuEntry, selectedData)

SHOWMODEL_CONTEXTMENU - callbacks for the context menu of the “Show model” checkbox.

Syntax:
obj.showModel_ContextMenu(menuEntry, selectedData)
Input Arguments:
  • menuEntry - [matlab.ui.container.Menu] pressed context menu entry

  • selectedData - [MenuSelectedData] menu event data; use .ContextObject to find source widget

Available menu options (from menuEntry.Tag):

  • 'showModelContextPerObject' - draw an imported label overlay with one colour per object instead of a single material

Notes

Only core.MibBigDataLabelsIndex has anything to toggle. Its core.MibBigDataLabelsIndex.renderPerObject is applied per block read, after the chunk cache, so switching it costs one redraw of the displayed slice - no re-read of the store and no network request. Every other model type either has no object ids to separate (the 63-material packed scheme) or already shows them, which is why showModel_ContextMenuOpening() disables the entry for them.

showModel_ContextMenuOpening(hContextMenu, openingData)

SHOWMODEL_CONTEXTMENUOPENING - refresh the “Show model” context menu from the active dataset.

Syntax:
obj.showModel_ContextMenuOpening(hContextMenu, openingData)
Input Arguments:
  • hContextMenu - [matlab.ui.container.ContextMenu] the menu being opened

  • openingData - [ContextMenuOpeningData] menu event data; unused

Notes

Reading the state as the menu opens rather than keeping it in step with listeners is what makes it impossible to show stale: a buffer switch, a mode change or a model being closed need no notification to reach it.

Render instances per object applies only to core.MibBigDataLabelsIndex, the read-only overlay served from a label pyramid the image does not share. The other BigData label classes pack six bits of material into a byte, so their object ids did not survive the load and there is nothing left to separate.

updateSegmentationPreset(presetId)

UPDATESEGMENTATIONPRESET - Update preset from the current settings of the selected segmentation.

Syntax:
obj.updateSegmentationPreset(presetId)

tool; callback on Shift+click of preset1/2/3 buttons or Shift+1/2/3 keyboard shortcuts.

Input Arguments:
  • presetId - [numeric] preset index, 1 to 3

Output Arguments:

Usage:

Example 1:

obj.updateSegmentationPreset(1);  // store current settings to preset 1
updateSettingsFromPreset(presetId)

UPDATESETTINGSFROMPRESET - Update settings of the selected segmentation tool from a stored preset;.

Syntax:
obj.updateSettingsFromPreset(presetId)

callback on click of preset1/2/3 buttons or 1/2/3 keyboard shortcuts.

Input Arguments:
  • presetId - [numeric] preset index, 1 to 3

Output Arguments:

Usage:

Example 1:

obj.updateSettingsFromPreset(1);  // restore preset 1 settings