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) and controllers.MibDeep.mergeInstancesTo3D() (stitches predicted *.model files 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 mismatched answer{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 values struct and hands it back as defaults next time. A seeded numeric outside a widget’s range is clamped rather than rejected, so a stale entry cannot break the dialog, and a defaults field 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 - see anisotropyMode below. It lives under UseAnisotropy (the checkbox) and Anisotropy (the ratio), and each caller touches only its own.

The callers differ only in how the Z anisotropy is obtained, which dlgOptions.anisotropyMode selects:

  • 'checkbox' - a yes/no toggle; the caller derives the ratio from its dataset’s pixSize.z / pixSize.x. anisotropyZ is not set in stitchOptions; read values.Anisotropy (logical) and set it.

  • 'ratio' - a numeric spinner, for input that carries no pixel size (raw prediction images). anisotropyZ is set in stitchOptions whenever 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 [default true]

    • .IoUThreshold - numeric 0-1 [default 0.25]

    • .IoAThreshold - logical, enables containment merging [default true]

    • .MinOverlapPixels - numeric [default 5]

    • .AbsOverlapPixels - numeric, 0 = off [default 0]

    • .ZLookback - numeric [default 1]

    • .MinObjectVoxels - numeric, 0 = keep all [default 0]

    • .MinObjectSlices - numeric, 0 = keep all [default 0]

    • .AbsorbFragmentVoxels - numeric, 0 = off [default 5]

    • .Anisotropy - logical in 'checkbox' mode [default false], numeric ratio in 'ratio' mode [default 1]

    • .MaxCentroidShift - numeric, 0 = off [default 0]

    • .CentroidLinkRadius - numeric, 0 = off [default 0]

  • 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 under docs/html when 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 cancelled

  • values - structure of the raw widget values under the defaults field names, so a caller can write them back into its own BatchOpt; [] 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