stitchInstancesSettingsDlg¶
- utils.dlgs.stitchInstancesSettingsDlg(parentFigure, note, defaults, dlgOptions)¶
STITCHINSTANCESSETTINGSDLG - Ask for the 2D-to-3D instance stitching settings.
- Syntax:
[stitchOptions, values] = utils.dlgs.stitchInstancesSettingsDlg(parentFigure, note, defaults, dlgOptions)
The single definition of the settings dialog for
utils.instances.stitch2Dto3D(), shared by its two entry points:models.MibModel.stitchModelInstances()(stitches the active labels layer) andcontrollers.MibDeep.mergeInstancesTo3D()(stitches predicted*.modelfiles from disk). Keeping one copy means a new stitching parameter is added in one place instead of two hand-synchronised prompt lists - the two dialogs previously had to be renumbered in lockstep, with nothing to catch a mismatchedanswer{n}index.On acceptance the chosen settings are echoed to the console as one line, built by walking the returned options struct, so a trial can be reproduced from the log without a second list to keep in step.
The dialog itself is stateless - a caller that wants the widgets to reopen on the last-used values stores the returned
valuesstruct and hands it back asdefaultsnext time. A seeded numeric outside a widget’s range is clamped rather than rejected, so a stale entry cannot break the dialog, and adefaultsfield the dialog does not know is ignored, because the seeding walks the dialog’s own field list rather than what it was given.Both callers persist under one shared key,
MibModel.sessionSettings.stitchInstances2Dto3D, so a threshold trialled at one entry point is offered at the other. They write into it field by field instead of replacing it, because the anisotropy answer is the one value that cannot be shared - seeanisotropyModebelow. It lives underUseAnisotropy(the checkbox) andAnisotropy(the ratio), and each caller touches only its own.The callers differ only in how the Z anisotropy is obtained, which
dlgOptions.anisotropyModeselects:'checkbox'- a yes/no toggle; the caller derives the ratio from its dataset’spixSize.z / pixSize.x.anisotropyZis not set institchOptions; readvalues.Anisotropy(logical) and set it.'ratio'- a numeric spinner, for input that carries no pixel size (raw prediction images).anisotropyZis set institchOptionswhenever the entered ratio exceeds 1.
- Input Arguments:
parentFigure - handle of the parent figure for the modal dialog
note - char, the bold header text shown above the settings
defaults - (optional) structure seeding the widgets; every field is optional and falls back to the value below. Field names match those of
values:.Method-'graph'(default) or'hungarian'.SplitDisconnected2D- logical [defaulttrue].IoUThreshold- numeric 0-1 [default0.25].IoAThreshold- logical, enables containment merging [defaulttrue].MinOverlapPixels- numeric [default5].AbsOverlapPixels- numeric,0= off [default0].ZLookback- numeric [default1].MinObjectVoxels- numeric,0= keep all [default0].MinObjectSlices- numeric,0= keep all [default0].AbsorbFragmentVoxels- numeric,0= off [default5].Anisotropy- logical in'checkbox'mode [defaultfalse], numeric ratio in'ratio'mode [default1].MaxCentroidShift- numeric,0= off [default0].CentroidLinkRadius- numeric,0= off [default0]
dlgOptions - (optional) structure:
.anisotropyMode-'checkbox'(default) or'ratio'.dlgTitle- dialog window title [default'Stitch 2D instances to 3D'].mibPath- MIB installation path. Supplies the dialog icon and the Help button, which opens the Stitch 2D instances to 3D documentation page - the local copy underdocs/htmlwhen the documentation was built, the page on mib.helsinki.fi otherwise. Without it the dialog still works, but shows no Help button
- Output Arguments:
stitchOptions - structure ready for
utils.instances.stitch2Dto3D();[]when the user cancelledvalues - structure of the raw widget values under the
defaultsfield names, so a caller can write them back into its ownBatchOpt;[]when the user cancelled
Example - the MibDeep call site, which supplies its own anisotropy ratio:
dlgOptions.anisotropyMode = 'ratio'; dlgOptions.dlgTitle = 'Merge 2D instances to 3D'; dlgOptions.mibPath = obj.mibModel.mibPath; [stitchOptions, values] = utils.dlgs.stitchInstancesSettingsDlg( ... obj.view.gui, note, struct(), dlgOptions); if isempty(stitchOptions); return; end % cancelled