CropObjects

class controllers.CropObjects

Bases: handle

CROPOBJECTS - Child controller for the Crop Image Patches dialog.

Launched from the Annotations context menu. Crops image patches centred on annotation positions and saves them to disk or the MATLAB workspace.

Syntax:
obj.startController('controllers.CropObjects', obj, false, annotationLabels);
Constructor Summary
CropObjects(mibModel, parentController, batchModeSwitch, annotationLabels)

CROPOBJECTS - Constructor for the CropObjects controller.

Syntax:
obj = CropObjects(mibModel, parentController)
obj = CropObjects(mibModel, parentController, batchModeSwitch, annotationLabels)
Input Arguments:
  • mibModel - handle to MibModel

  • parentController - handle to the parent Annotations controller

  • batchModeSwitch - (optional) logical; when true, runs in headless mode without opening the GUI

  • annotationLabels - (optional) struct with annotation crop coordinates

    • .positions - [Nx4] matrix with [z, x, y, t] annotation coordinates

    • .names - {Nx1} cell array of label strings

Output Arguments:
  • obj - new CropObjects controller instance

Property Summary
annotationLabels

base variable name used when exporting to Matlab workspace

listener

handle to core.ChildView (views.CropObjectsGUI)

mibModel
outputDir

cell array with listener handles

outputVar

output directory for saved patches

parentController

handle to MibModel

sessionSettingsKey

.positions [Nx4 z,x,y,t] and .names {Nx1 cell}

Type:

struct

view

handle to the parent controller (owns BatchOpt)

Method Summary
static ViewListner_Callback2(~, evnt)

VIEWLISTNER_CALLBACK2 - Guard: clean up listeners and return silently if the view was closed.

Syntax:
CropObjects.ViewListner_Callback2(obj, src, evnt)
Input Arguments:
  • obj - handle to the CropObjects controller instance

  • src - event source handle (unused)

  • evnt - event data; evnt.EventName identifies the event

Output Arguments:

(none)

addCallbacks()

ADDCALLBACKS - Wire all widget callbacks; called once from the constructor.

Syntax:
obj.addCallbacks()
Output Arguments:

(none)

closeWindow()

CLOSEWINDOW - Close the dialog and release all listeners.

Syntax:
obj.closeWindow()
Output Arguments:

(none)

cropBtn_Callback()

CROPBTN_CALLBACK - Callback for the Crop button; resolves output directory then calls generatePatches.

Syntax:
obj.cropBtn_Callback()
Output Arguments:

(none)

cropMaskCheck_Callback()

CROPMASKCHECK_CALLBACK - Callback for the “Crop Mask” checkbox.

Syntax:
obj.cropMaskCheck_Callback()
Output Arguments:

(none)

cropModelCheck_Callback()

CROPMODELCHECK_CALLBACK - Callback for the “Crop Model” checkbox.

Syntax:
obj.cropModelCheck_Callback()
Output Arguments:

(none)

dirEdit_Callback()

DIREDIT_CALLBACK - Validate a directory path typed manually into dirEdit.

Syntax:
obj.dirEdit_Callback()
Output Arguments:

(none)

generate3DPatches_Callback()

GENERATE3DPATCHES_CALLBACK - Callback for the “crop 3D objects” checkbox.

Syntax:
obj.generate3DPatches_Callback()
Output Arguments:

(none)

generatePatches()

GENERATEPATCHES - Crop image patches centred on each annotation and save them.

Syntax:
obj.generatePatches()

Reads coordinates from obj.annotationLabels.positions [Nx4: z,x,y,t] and names from obj.annotationLabels.names {Nx1}. Output format and inclusion of model/mask are controlled by obj.parentController.BatchOpt fields.

Output Arguments:

(none)

jitter_Callback()

JITTER_CALLBACK - Callback for the jitter enable checkbox.

Syntax:
obj.jitter_Callback()
Output Arguments:

(none)

saveAuxLayer(data, format, fnBase, pixSize, xMinPhys, yMinPhys, zMinPhys, colors, names, ~, id, layerType)

SAVEAUXLAYER - Save a model or mask subvolume in the requested format.

Syntax:
obj.saveAuxLayer(data, format, fnBase, pixSize, xMinPhys, yMinPhys, zMinPhys, colors, names, saveOpts, id, layerType)
Input Arguments:
  • data - [H x W x D] uint8 array with model/mask voxel data

  • format - [char] one of the CropObjectsIncludeModel/CropObjectsIncludeMask option strings

  • fnBase - [char] base filename without extension; directory already included

  • pixSize - struct with physical voxel size fields .x, .y, .z, .units

  • xMinPhys - [double] physical X origin of the crop region

  • yMinPhys - [double] physical Y origin of the crop region

  • zMinPhys - [double] physical Z origin of the crop region

  • colors - [Nx3] colour matrix for Amira label export

  • names - {Nx1} cell array of material names

  • saveOpts - shared save options struct (unused; reserved for future use)

  • id - [numeric] active dataset index

  • layerType - [char] 'model' or 'mask'

Output Arguments:

(none)

selectDirBtn_Callback()

SELECTDIRBTN_CALLBACK - Browse for the output directory using a folder picker dialog.

Syntax:
obj.selectDirBtn_Callback()
Output Arguments:

(none)

targetPanel_Callback()

TARGETPANEL_CALLBACK - Callback for the target radio button group (File / MATLAB).

Syntax:
obj.targetPanel_Callback()
Output Arguments:

(none)

updateBatchOptFromGUI(hObject)

UPDATEBATCHOPTFROMGUI - Sync a single widget value back into parentController.BatchOpt.

Syntax:
obj.updateBatchOptFromGUI(hObject)
Input Arguments:
  • hObject - handle to the widget that changed; hObject.Tag identifies the BatchOpt field to update

Output Arguments:

(none)

updateWidgets()

UPDATEWIDGETS - Refresh all widgets from parentController.BatchOpt.

Syntax:
obj.updateWidgets()
Output Arguments:

(none)