Alignment

class controllers.Alignment

Bases: handle

ALIGNMENT - Controller class for slice-by-slice alignment of 3D image stacks.

Replaces mibAlignmentController from MIB2. Drives the alignment dialog, builds the BatchOpt parameter set, and dispatches to per-algorithm method files (drift correction, single/three-point landmarks, multi-point landmarks, feature-based, AMST). The “Two stacks” mode from MIB2 is intentionally not ported.

Usage:
obj.mibController.startController('controllers.Alignment');
controllers.Alignment(mibModel, [], BatchOpt);   % headless batch run
controllers.Alignment(mibModel, [], NaN);        % return BatchOpt schema
Constructor Summary
Alignment(mibModel, varargin)

ALIGNMENT - Construct the alignment controller.

Syntax:
obj = controllers.Alignment(mibModel)
obj = controllers.Alignment(mibModel, [])
obj = controllers.Alignment(mibModel, [], BatchOptInput)
Input Arguments:
  • mibModel - handle to models.MibModel.

  • varargin{1} (optional) - reserved (compat slot).

  • varargin{2} (optional) - BatchOpt struct for headless run, or NaN to request the default BatchOpt via SyncBatch.

Property Summary
BatchOpt

structure compatible with batch processing

automaticOptions

struct with feature-detector / AMST tuning parameters

bigDataPyramid

cached pyramid struct of the active BigData image (levelImageSizes/levelScaleFactors/…)

files

files structure from getImageMetadata (HDD mode)

isBigData

logical, true when the active dataset is a BigData (disk-backed pyramidal) store

listener

cell array of listener handles

meta

meta dictionary from getImageMetadata (HDD mode)

mibModel

handle to MibModel

pathstr

current dataset path

pixSize

pixSize struct from getImageMetadata (HDD mode)

shiftsX

vector of X shifts or affine tform matrix

shiftsY

vector of Y shifts or rigid-body matrix

varname

workspace variable name for shift export

view

handle to the view (AlignmentGUI .mlapp)

Method Summary
AlignMedianSmoothTemplate_Alignment(parameters)

ALIGNMEDIANSMOOTHTEMPLATE_ALIGNMENT - Align a stack to its own median-smoothed template (AMST).

Syntax:
obj.AlignMedianSmoothTemplate_Alignment(parameters)

Intensity-based registration aligning each slice to a median-smoothed version of the same stack. Smoothing is applied along Z with medfilt3() using a [1, 1, MedianSize] neighbourhood - the template at slice k is the median of the surrounding slices, which compensates for local deformations that pure feature matching cannot fix. The dataset is expected to have been pre-aligned with drift correction first; this stage refines the result.

Per-slice registration uses imregtform() in monomodal mode with optimizer parameters drawn from obj.automaticOptions.amst. Supported TransformationType values come from imregtform(): translation, rigid, similarity, affine. projective is rejected with an error dialog (imregtform does not support it).

Running-average smoothing of stretch + shear is available in two modes: interactive (GUI) and batch. In interactive mode the raw scaling and shear curves are plotted (figure 125) and the user chooses whether to apply smoothing and tunes the half-width / exclude-peaks settings in a loop until satisfied; the smoothed values are written back into tformMatrix{*}.T before the apply phase. In batch mode smoothing runs automatically from the BatchOpt.SubtractRunningAverage* fields when BatchOpt.SubtractRunningAverage is set.

AMST is cropped-mode only (matches MIB2 behaviour).

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, useBatchMode, method.

AutomaticFeatureBasedHDDV2_Alignment(parameters)

AUTOMATICFEATUREBASEDHDDV2_ALIGNMENT - Streaming v2 feature-based alignment.

Syntax:
obj.AutomaticFeatureBasedHDDV2_Alignment(parameters)

Streaming variant of AutomaticFeatureBasedV2_Alignment() for stacks that do not fit in memory. Reads slices one at a time from obj.BatchOpt.HDD_InputDir via matlab.io.datastore.ImageDatastore configured with io.loadImagesWrapper() as its ReadFcn.

V2 specifics (vs the v1 HDD variant):

  • Uses estgeotform2d returning affinetform2d natively; tforms are composed via the modern .A (premultiply) property.

  • Stores pairwise transforms separately from cumulative ones and decomposes each pairwise matrix into translation / rotation / scale so the running-average smoothing can act on each parameter independently.

  • Downsamples by 1 / imgDownsamplingFactorForAnalysis.

  • Builds the extended canvas via corner projection: transform the four image corners through every cumulative tform and union their bounding box.

  • Rounds translations to integer pixels when TransformationType == 'translation'.

Two-phase fit:
  1. Parallel detect + extract (parfor when UseParallelComputing is set). Only descriptors + valid-point locations are kept in memory.

  2. Sequential match + compose - adjacent descriptor pairs are matched, estgeotform2d fits a robust 2-D transform, the pairwise tform is stored and decomposed.

Apply phase re-reads each image, warps it with imwarp() against the chosen OutputView (cropped = max input dims; extended = the union canvas computed by corner projection), and saves the result to <InputDir>/HDD_OutputSubfolderName via core.MibImage.save(). The apply loop runs under parfor when parallel computing is enabled.

No in-memory dataset is touched - no backup, no NewDataset notify.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, useBatchMode, method, UseParallelComputing.

AutomaticFeatureBasedHDD_Alignment(parameters)

AUTOMATICFEATUREBASEDHDD_ALIGNMENT - Streaming v1 feature-based alignment.

Syntax:
obj.AutomaticFeatureBasedHDD_Alignment(parameters)

Streaming variant of AutomaticFeatureBased_Alignment() for stacks that do not fit in memory. Reads slices one at a time from obj.BatchOpt.HDD_InputDir via matlab.io.datastore.ImageDatastore configured with io.loadImagesWrapper() as its ReadFcn.

Two-phase fit:
  1. Parallel detect + extract - every file is opened in turn (parfor when BatchOpt.UseParallelComputing is set), features are detected with utils.align.detectFeatures() and descriptors are extracted with extractFeatures(). Only the descriptors + valid-point locations are kept in memory - never the images.

  2. Sequential match + compose - adjacent descriptor pairs are matched, estgeotform2d() fits a robust 2-D transform, the cumulative tform chain is built via legacy .T composition.

Apply phase re-reads each image, warps it with imwarp() against the chosen refImgSize (cropped = slice 1’s dims; extended = each slice’s per-image affineOutputView()), and saves it to <InputDir>/HDD_OutputSubfolderName via core.MibImage.save(). Cropped + extended apply loops both run under parfor when parallel computing is enabled.

No in-memory dataset is touched - no backup, no NewDataset notify.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, useBatchMode, method, UseParallelComputing.

AutomaticFeatureBasedV2BigData_Alignment(parameters)

AUTOMATICFEATUREBASEDV2BIGDATA_ALIGNMENT - Automatic feature-based v2 (affine) for BigData.

Syntax:
obj.AutomaticFeatureBasedV2BigData_Alignment(parameters)

Feature-based affine alignment for disk-backed pyramidal (BigData) stores. Two-pass streaming:

  • Pass 1 runs the shared per-slice fit (utils.align.fitPerSliceV2()) on slices read at the analysis pyramid level parameters.pyramidLevel. When a coarse level is chosen the level already downsamples, so the v2 analysis factor is forced to 1 (no double downsampling). Cumulative parameters are composed and optionally smoothed (interactive in GUI, BatchOpt-driven in batch) - the smoothing acts on the small level-L parameter vectors.

  • Cumulative transforms are conjugated to level 0 (T0 = S*TL*inv(S), S = diag([s s 1]) - the linear block is unchanged, the translation column is multiplied by the level scale s). The extended canvas is computed by corner projection at level-0 dims. The level-0 transforms are handed to applyAlignmentBigData() with mode = 'affine', which streams a NEW aligned OME-Zarr v3 image (+ Labels_<stem>.zarr3) and swaps the active buffer. The source store is never modified.

Save / replay - when SaveShiftsToFile is set the level-0 alignment struct (cumulative + pairwise tforms + decomposed parameters) is written to a .coefXY file; when loadShiftsCheck pre-loads such a struct into obj.shiftsX the detection/fit/smoothing pass is skipped and the loaded level-0 cumulative transforms are replayed directly (align another dataset). The saved transforms are level-0, so replay is pyramid-level-independent.

Input Arguments:
  • parameters - struct built by continueBtn_Callback(); BigData fields isBigData (true), pyramidLevel, outputPath, plus TransformationType (translation/rigid/similarity/affine), TransformationMode, colorCh, backgroundColor, useBatchMode.

See also: utils.align.fitPerSliceV2, controllers.Alignment.applyAlignmentBigData, controllers.Alignment.AutomaticFeatureBasedV2_Alignment

AutomaticFeatureBasedV2_Alignment(parameters)

AUTOMATICFEATUREBASEDV2_ALIGNMENT - V2 feature-based alignment with parameter decomposition.

Syntax:
obj.AutomaticFeatureBasedV2_Alignment(parameters)

Modern feature-based alignment (R2022b+). Compared to v1 this version:

  • Uses estgeotform2d returning rigidtform2d / simtform2d / affinetform2d natively; transforms are composed cumulatively via the new .A (premultiply) property.

  • Stores pairwise transforms separately from cumulative ones and decomposes each pairwise matrix into translation / rotation / scale components so the running-average smoothing can act on each parameter independently rather than on the raw matrix entries.

  • Downsamples by 1 / imgDownsamplingFactorForAnalysis instead of imgWidthForAnalysis.

  • Computes the extended canvas via corner projection (transform the four image corners through every cumulative tform and union their bounding box) rather than from per-slice imref2d limits; gives a tighter canvas.

  • Rounds translations to integer pixels when TransformationType == 'translation' so the resulting stack stays free of resampling blur.

Supported TransformationType: 'translation', 'rigid', 'similarity', 'affine' (matches MIB2 v2’s allowed list).

In GUI mode a diagnostic plot of the cumulative parameters is shown after step 1 and the user can choose Apply current values (no smoothing) or Fix drifts (interactive running-average smoothing loop with per-component control over translation, rotation and scale). In batch mode, smoothing runs straight from the BatchOpt.SubtractRunningAverage* fields when the flag is set.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, useBatchMode, method.

AutomaticFeatureBased_Alignment(parameters)

AUTOMATICFEATUREBASED_ALIGNMENT - Align a stack with automatically detected feature matches.

Syntax:
obj.AutomaticFeatureBased_Alignment(parameters)

Walks the stack slice by slice, detects features with the user-selected detector (utils.align.detectFeatures()), extracts descriptors, matches them, and fits a robust 2-D transform with estgeotform2d (MSAC inlier selection). Transforms are composed cumulatively so each slice is aligned to slice 1’s coordinate frame.

Two apply modes (chosen via parameters.TransformationMode):

  • 'cropped' - original canvas preserved; each slice warped with imwarp(..., 'OutputView', imref2d([H, W])) and written back via setData2D().

  • 'extended' - canvas grows to fit the union of all warped slices; the image canvas is replaced atomically and service-layer containers are pre-resized before setData4D().

Running-average smoothing of the per-slice scale + shear parameters is available in two modes: interactive (GUI) and batch. In interactive mode the raw scaling and shear curves are plotted (figure 125) and the user chooses whether to apply smoothing and tunes the half-width / exclude-peaks settings in a loop until satisfied; the smoothed values are written back into tformMatrix{*}.T before the apply phase. In batch mode smoothing runs automatically from the BatchOpt.SubtractRunningAverage* fields when BatchOpt.SubtractRunningAverage is set.

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; cancel state is polled at each phase boundary and immediately before each write. The automaticOptions settings dialog from MIB2 is currently skipped - the algorithm runs with whatever defaults already exist in obj.automaticOptions.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, useBatchMode, method.

DriftCorrectionBigData_Alignment(parameters)

DRIFTCORRECTIONBIGDATA_ALIGNMENT - Drift correction / template matching for BigData datasets.

Syntax:
obj.DriftCorrectionBigData_Alignment(parameters)

Two-pass streaming alignment for disk-backed pyramidal (BigData) stores:

  • Pass 1 reads the stack at the analysis pyramid level parameters.pyramidLevel and computes per-slice X/Y shifts via utils.align.calcShifts(). The math operates on the small level-L arrays, so the existing helpers are reused unchanged.

  • Shifts are scaled to level 0 (shift0 = round(shiftL * scale)) - integer shifts give resample-free placement - and handed to applyAlignmentBigData() with mode = 'translation', which streams a NEW aligned OME-Zarr v3 image (+ Labels_<stem>.zarr3) and swaps the active buffer to it. The source store is never modified.

Input Arguments:
  • parameters - struct built by continueBtn_Callback(); BigData fields: isBigData (true), pyramidLevel (1-based analysis level), outputPath (target .zarr3 store), plus method, colorCh, backgroundColor, refFrame, IntensityGradient, Subarea, minX/maxX/minY/maxY, TransformationMode, useBatchMode.

See also: controllers.Alignment.applyAlignmentBigData, controllers.Alignment.DriftCorrection_Alignment, utils.align.calcShifts

DriftCorrection_Alignment(parameters)

DRIFTCORRECTION_ALIGNMENT - In-memory drift correction / template matching.

Syntax:
obj.DriftCorrection_Alignment(parameters)

Computes per-slice X/Y shifts via utils.align.calcShifts() and applies them to the image stack with utils.align.crossShiftStack(). Mask, selection, and labels layers are realigned with the same shifts so the whole dataset stays consistent.

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; the cancel state is polled at the top of every loop and immediately before any irreversible write back to the model.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback() with the fields method, colorCh, backgroundColor, refFrame, IntensityGradient, Subarea, minX/maxX/minY/maxY, UseParallelComputing, useBatchMode.

LandmarkMultiPointColor_Alignment(parameters)

LANDMARKMULTIPOINTCOLOR_ALIGNMENT - Align one colour channel to another using per-slice landmarks.

Syntax:
obj.LandmarkMultiPointColor_Alignment(parameters)

Performs a within-slice 2D alignment of a single colour channel (parameters.colorCh) onto a reference channel using corresponding annotation pairs placed on the same slice. Annotation values mark the role of each point:

  • value == 1 - landmarks on the reference (fixed) channel.

  • value == 2 - landmarks on the channel to be transformed.

Corresponding landmarks must share the same annotation text label. Each slice is processed independently - no cumulative transform is propagated forward - and the warped channel is written back into its original slot.

The minimum number of landmark pairs per slice depends on the transformation type:

TransformationType

minLandmarks

nonreflectivesimilarity

2

similarity / affine

3

projective / pwl

4

polynomial / lwm

6

Only parameters.TransformationMode = 'cropped' is supported (matches MIB2 behaviour). Extended-canvas mode is rejected with an error dialog.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, colorCh, backgroundColor, transformationDegree, useBatchMode.

LandmarkMultiPoint_Alignment(parameters)

LANDMARKMULTIPOINT_ALIGNMENT - Align a stack using 3+ corresponding landmarks per slice pair.

Syntax:
obj.LandmarkMultiPoint_Alignment(parameters)

Fits a per-slice geometric transform (parameters.TransformationType) to the landmarks placed on consecutive slices and warps every slice in the stack with the cumulative transform. The number of required landmarks per slice pair is set by the transformation type:

TransformationType

minLandmarks

nonreflectivesimilarity

2

similarity / affine

3

projective / pwl

4

polynomial / lwm

6

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; the cancel state is polled at each phase boundary (landmark search, image warp, canvas assembly, service-layer warp) and immediately before each write.

Modes:
  • parameters.TransformationMode = 'cropped' keeps the original canvas - each slice is warped with imwarp(..., 'OutputView', imref2d([H, W])) and written back to its slot via setData2D().

  • parameters.TransformationMode = 'extended' grows the canvas to fit the union of all warped slices; service layers are pre-resized to the new canvas before setData4D().

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads TransformationType, TransformationMode, transformationDegree, colorCh, backgroundColor, useBatchMode.

LandmarksBigData_Alignment(parameters)

LANDMARKSBIGDATA_ALIGNMENT - Landmark-based alignment (single/three/multi) for BigData.

Syntax:
obj.LandmarksBigData_Alignment(parameters)

Landmark alignment for disk-backed pyramidal (BigData) stores; branches on parameters.method:

  • 'Single landmark point' - one annotation per slice → per-slice cumulative translation (applyAlignmentBigData mode='translation').

  • 'Three landmark points' - the first slice pair carrying 3+ matching-labelled annotations → a single affine transform broadcast to the tail (head unchanged).

  • 'Landmarks, multi points' - 3+ matching-labelled annotations per slice pair → per-slice cumulative affine (fitgeotrans).

Annotation positions are already in full-resolution (level-0) coordinates, so no pyramid-level scaling is needed - the transforms go straight into applyAlignmentBigData(), which streams a NEW aligned OME-Zarr v3 store (+ Labels_<stem>.zarr3) and swaps the active buffer. The source is never modified.

Note

Phase 3 uses the Annotation layer as the landmark source (the practical choice for gigapixel slides). Selection-layer landmark extraction (bounded by selectionBBoxFull) is a later addition.

Input Arguments:
  • parameters - struct built by continueBtn_Callback(); BigData fields isBigData (true), outputPath, plus method, TransformationType, TransformationMode, transformationDegree, colorCh, backgroundColor, useBatchMode.

See also: controllers.Alignment.applyAlignmentBigData, controllers.Alignment.SingleLandmark_Alignment, controllers.Alignment.LandmarkMultiPoint_Alignment

SingleLandmark_Alignment(parameters)

SINGLELANDMARK_ALIGNMENT - Align a stack using a single corresponding landmark per slice.

Syntax:
obj.SingleLandmark_Alignment(parameters)

Computes per-slice X/Y shifts so that one landmark on each slice maps onto the matching landmark of the previous slice, then applies the cumulative shifts via utils.align.crossShiftStack(). Landmarks may be marked either with the Selection layer (centroid of the connected region per slice) or with the Annotation tool (a single annotation per slice).

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; the cancel state is polled at the top of every iteration and before any irreversible write back to the model.

Input Arguments:
ThreeLandmarks_Alignment(parameters)

THREELANDMARKS_ALIGNMENT - Align a stack from a single pair of slices carrying 3+ landmarks.

Syntax:
obj.ThreeLandmarks_Alignment(parameters)

Walks the stack until it finds the first pair of consecutive slices that both carry at least three connected components in the selection layer, treats those centroids as corresponding landmarks, fits an affine transform with fitgeotrans(), and warps every slice from layer+1 to Depth with imwarp(). The warped tail is then concatenated to the unchanged head 1:layer via utils.align.crossShiftStacks() so the canvas grows to fit both pieces.

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; the cancel state is polled at each phase boundary (landmark search, image warp, service-layer warps) and immediately before each irreversible write.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Only backgroundColor, colorCh, useBatchMode are read here.

static ViewListner_Callback2(~, evnt)

VIEWLISTNER_CALLBACK2 - Static guarded listener callback.

Syntax:
obj.ViewListner_Callback2(src, evnt)

Routes the model events UpdateGuiWidgets and NewDataset to updateWidgets(). Deletes stale listeners if the controller or its view has been destroyed.

addCallbacks()

ADDCALLBACKS - Wire every widget to the central gui_Callbacks() dispatcher.

Syntax:
obj.addCallbacks()

Sets CloseRequestFcn on the figure first; assigns a single anonymous-handle callback to every widget Tag listed in the view contract. Widgets that the user’s .mlapp does not yet expose are silently skipped.

algorithm_Callback()

ALGORITHM_CALLBACK - Toggle widget enable/disable based on the selected algorithm.

Syntax:
obj.algorithm_Callback()

Reads obj.view.handles.Algorithm.Value, then enables only the widgets relevant to that algorithm. HDD_Mode is enabled only for drift / template / feature-based; AMST disables Subarea and forces cropped mode; the feature-based variants restrict TransformationType to a method-specific subset.

alignDriftCorrectionHDD_Alignment(parameters)

ALIGNDRIFTCORRECTIONHDD_ALIGNMENT - Streaming drift correction over a directory of images.

Syntax:
obj.alignDriftCorrectionHDD_Alignment(parameters)

Streaming variant of DriftCorrection_Alignment() for stacks that do not fit in memory. Reads slices one at a time from obj.BatchOpt.HDD_InputDir (filtered by HDD_InputFilenameExtension) via matlab.io.datastore.ImageDatastore configured with io.loadImagesWrapper() as its ReadFcn; computes FFT cross-correlation pairwise; integrates pairwise shifts via cumsum (CorrelateWith = 'Previous slice' / 'Relative to') or keeps slice 1 as the reference throughout (CorrelateWith = 'First slice'); optionally smooths via utils.align.subtractRunningAverage() (interactive loop when useBatchMode is false, straight batch otherwise); then re-reads each image, places it onto a padded canvas, and saves it to <InputDir>/HDD_OutputSubfolderName in the chosen format via core.MibImage.save().

No in-memory dataset is modified - only files in the output directory. This means no backup is taken (there’s nothing to back up) and the trailing NewDataset notify is suppressed.

Cancellation: a core.PoolWaitbar is constructed with Cancelable = true whenever BatchOpt.showWaitbar is set; cancel state is polled between every image.

Input Arguments:
  • parameters - struct produced by continueBtn_Callback(). Reads method, colorCh, backgroundColor, useBatchMode, refFrame, Subarea, minX/maxX/minY/maxY, IntensityGradient.

applyAlignmentBigData(parameters, tformInfo)

APPLYALIGNMENTBIGDATA - Shared apply pipeline for BigData alignment.

Syntax:
obj.applyAlignmentBigData(parameters, tformInfo)

Given per-slice level-0 transforms, streams a NEW aligned OME-Zarr v3 image store (and, when a BigData model exists, a sibling Labels_<stem>.zarr3), then reopens and swaps the active buffer to it. The source store is left intact and acts as the backup (no mibModel.backup is taken in BigData paths).

Pipeline:
  1. Build per-slice level-0 transforms + the level-0 output canvas (extended growth or cropped original dims).

  2. One shared level plan (Zarr3Saver.computeLevelPlan) so the image store (built by saveStream) and the labels store (built by createStore) share identical level sizes / scale factors / chunks.

  3. Stream the image store via Zarr3Saver.saveStream + io.savers.AlignedImageSliceProvider.

  4. Warp packed-63 labels/mask/selection (nearest-neighbour) into a new MibBigDataLabels store; materializeAll + closeStore (persists the level map).

  5. Patch metadata (bounding box + per-level translation/scale).

  6. Reopen + swap the active buffer (per CropDataset).

Input Arguments:
  • parameters - struct from continueBtn_Callback() (outputPath, TransformationMode, backgroundColor, …).

  • tformInfo - struct describing the level-0 transforms:

    • .mode - 'translation' or 'affine'.

    • .shiftX0 / .shiftY0 - [Nx1] integer level-0 shifts (translation mode).

    • .tforms - {depth x 1} cell of affinetform2d (affine mode).

    • .backgroundValue - numeric scalar image background fill.

See also: io.savers.AlignedImageSliceProvider, io.savers.Zarr3Saver, core.MibBigDataLabels, controllers.Alignment.DriftCorrectionBigData_Alignment

closeWindow()

CLOSEWINDOW - Close the dialog and detach listeners.

Syntax:
obj.closeWindow()
continueBtn_Callback(useBatchMode)

CONTINUEBTN_CALLBACK - Top-level dispatcher for the alignment Apply button.

Syntax:
obj.continueBtn_Callback()
obj.continueBtn_Callback(useBatchMode)

Validates the current dataset, builds the shared parameters struct from obj.BatchOpt, and dispatches to the algorithm-specific method file (DriftCorrection_Alignment, SingleLandmark_Alignment, …). Algorithms not yet ported in the current phase fall through to a friendly error dialog.

Input Arguments:
  • useBatchMode (optional) - [logical] true when the controller was invoked via the batch processor (no GUI). Default false.

static findMatchingPairs(X1, X2)

FINDMATCHINGPAIRS - Nearest-neighbour matching between two point sets.

Syntax:
idx = controllers.Alignment.findMatchingPairs(X1, X2)
Input Arguments:
  • X1 - [N x 2] array of (x, y) coordinates.

  • X2 - [M x 2] array of (x, y) coordinates.

Output Arguments:
  • idx - [M x 1] vector of indices such that X1(j) matches X2(idx(j)); NaN for unmatched rows.

getSearchWindow_Callback()

GETSEARCHWINDOW_CALLBACK - Populate the manual subarea fields from the current selection bounding box.

Syntax:
obj.getSearchWindow_Callback()

Reads the selection layer of the current slice; if the layer contains any non-zero pixels, copies the bounding box of the first connected region into minX/minY/maxX/maxY widgets and the matching BatchOpt fields.

gui_Callbacks(source, event)

#ok<INUSD> GUI_CALLBACKS - Dispatcher for every Alignment widget callback.

Syntax:
obj.gui_Callbacks(source, event)

Routes by source.Tag to the appropriate action method. Widgets that only need to keep BatchOpt in sync fall through the otherwise branch.

Input Arguments:
  • obj - controllers.Alignment instance.

  • source - widget handle that fired the event.

  • event - event data (unused).

loadShiftsCheck_Callback()

LOADSHIFTSCHECK_CALLBACK - Load pre-computed shifts from a .coefXY file.

Syntax:
obj.loadShiftsCheck_Callback()

When the loadShiftsCheck checkbox is enabled the user is prompted for a .coefXY file. The file may contain shiftsX / shiftsY (drift correction), tformMatrix / rbMatrix (legacy feature-based), or a feature-based v2 parameter struct. The loaded coefficients are stored on the controller and previewed + confirmed when the Apply button is pressed (see previewConfirmLoadedShifts()), where the selected algorithm is known so a mismatch can be flagged. Disabling the checkbox clears the loaded coefficients and the path.

previewFeaturesBtn_Callback()

PREVIEWFEATURESBTN_CALLBACK - Visualise feature matches between two consecutive slices.

Syntax:
obj.previewFeaturesBtn_Callback()

Detects features on the current slice and the next slice using the feature detector selected in the FeatureDetectorType widget, matches the descriptors, robust-fits a 2-D geometric transform (RANSAC via estgeotform2d), and renders the matches in a dedicated figure (two subplots - with outliers and inliers only). No alignment is applied; this is a tuning aid for the feature-based alignment algorithms.

The downsampling ratio matches what the alignment algorithm itself would use:

  • Automatic feature-based → imgWidthForAnalysis / Width

  • Automatic feature-based v2 → 1 / imgDownsamplingFactorForAnalysis

No-op for AMST: median-smoothed template (the Preview button is relabeled Settings in that mode).

returnBatchOpt(BatchOptOut)

RETURNBATCHOPT - Forward BatchOpt to mibBatchController via SyncBatch.

Syntax:
obj.returnBatchOpt()
obj.returnBatchOpt(BatchOptOut)
subwindowEdit_Callback(hObject)

SUBWINDOWEDIT_CALLBACK - Validate the manual subarea (minX/minY/maxX/maxY) widgets.

Syntax:
obj.subwindowEdit_Callback()
obj.subwindowEdit_Callback(hObject)
Input Arguments:
  • hObject (optional) - handle to the widget that fired the callback.

Coerces out-of-range values back into [1, width] / [1, height] and reports the correction via utils.dlgs.showErrorDialog().

updateAutomaticOptions()

UPDATEAUTOMATICOPTIONS - Interactive settings dialog for the feature-based / AMST options.

Syntax:
status = obj.updateAutomaticOptions()

Pops an utils.dlgs.inputUniversalDlg() settings dialog tailored to the currently selected Algorithm:

  • AMST: median-smoothed template - image downsampling + pyramid levels + imregconfig optimizer parameters (maximum iterations, gradient-magnitude tolerance, min / max step length, relaxation factor).

  • Automatic feature-based / Automatic feature-based v2 - image downsampling, rotation-invariance flag, the per-detector parameters for the currently selected FeatureDetectorType, and the estgeotform2d (RANSAC) settings - delegated to the shared utils.align.detectorSettingsDlg() (also used by the Stitching tool).

Updates obj.automaticOptions in place; the algorithm methods read from there.

Output Arguments:
  • status - 1 when the user clicked OK and settings were applied; 0 when the dialog was cancelled.

updateBatchOptFromGUI(hObject)

UPDATEBATCHOPTFROMGUI - Sync obj.BatchOpt from a single widget.

Syntax:
obj.updateBatchOptFromGUI(hObject)
updateWidgets()

UPDATEWIDGETS - Refresh dialog widgets from the current dataset.

Syntax:
obj.updateWidgets()