Alignment¶
- class controllers.Alignment¶
Bases:
handleALIGNMENT - Controller class for slice-by-slice alignment of 3D image stacks.
Replaces
mibAlignmentControllerfrom MIB2. Drives the alignment dialog, builds theBatchOptparameter 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) -
BatchOptstruct for headless run, orNaNto request the defaultBatchOptviaSyncBatch.
- 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 fromobj.automaticOptions.amst. Supported TransformationType values come fromimregtform():translation,rigid,similarity,affine.projectiveis rejected with an error dialog (imregtformdoes 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{*}.Tbefore the apply phase. In batch mode smoothing runs automatically from theBatchOpt.SubtractRunningAverage*fields whenBatchOpt.SubtractRunningAverageis set.AMST is cropped-mode only (matches MIB2 behaviour).
- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). ReadsTransformationType,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 fromobj.BatchOpt.HDD_InputDirviamatlab.io.datastore.ImageDatastoreconfigured withio.loadImagesWrapper()as itsReadFcn.V2 specifics (vs the v1 HDD variant):
Uses
estgeotform2dreturningaffinetform2dnatively; 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:
Parallel detect + extract (parfor when
UseParallelComputingis set). Only descriptors + valid-point locations are kept in memory.Sequential match + compose - adjacent descriptor pairs are matched,
estgeotform2dfits a robust 2-D transform, the pairwise tform is stored and decomposed.
Apply phase re-reads each image, warps it with
imwarp()against the chosenOutputView(cropped = max input dims; extended = the union canvas computed by corner projection), and saves the result to<InputDir>/HDD_OutputSubfolderNameviacore.MibImage.save(). The apply loop runs underparforwhen parallel computing is enabled.No in-memory dataset is touched - no backup, no
NewDatasetnotify.- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). ReadsTransformationType,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 fromobj.BatchOpt.HDD_InputDirviamatlab.io.datastore.ImageDatastoreconfigured withio.loadImagesWrapper()as itsReadFcn.- Two-phase fit:
Parallel detect + extract - every file is opened in turn (parfor when
BatchOpt.UseParallelComputingis set), features are detected withutils.align.detectFeatures()and descriptors are extracted withextractFeatures(). Only the descriptors + valid-point locations are kept in memory - never the images.Sequential match + compose - adjacent descriptor pairs are matched,
estgeotform2d()fits a robust 2-D transform, the cumulative tform chain is built via legacy.Tcomposition.
Apply phase re-reads each image, warps it with
imwarp()against the chosenrefImgSize(cropped = slice 1’s dims; extended = each slice’s per-imageaffineOutputView()), and saves it to<InputDir>/HDD_OutputSubfolderNameviacore.MibImage.save(). Cropped + extended apply loops both run underparforwhen parallel computing is enabled.No in-memory dataset is touched - no backup, no
NewDatasetnotify.- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). ReadsTransformationType,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 levelparameters.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 scales). The extended canvas is computed by corner projection at level-0 dims. The level-0 transforms are handed toapplyAlignmentBigData()withmode = '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
SaveShiftsToFileis set the level-0 alignment struct (cumulative + pairwise tforms + decomposed parameters) is written to a.coefXYfile; whenloadShiftsCheckpre-loads such a struct intoobj.shiftsXthe 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 fieldsisBigData(true),pyramidLevel,outputPath, plusTransformationType(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
estgeotform2dreturningrigidtform2d/simtform2d/affinetform2dnatively; 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 / imgDownsamplingFactorForAnalysisinstead ofimgWidthForAnalysis.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
imref2dlimits; 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(). ReadsTransformationType,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 withestgeotform2d(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 withimwarp(..., 'OutputView', imref2d([H, W]))and written back viasetData2D().'extended'- canvas grows to fit the union of all warped slices; the image canvas is replaced atomically and service-layer containers are pre-resized beforesetData4D().
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{*}.Tbefore the apply phase. In batch mode smoothing runs automatically from theBatchOpt.SubtractRunningAverage*fields whenBatchOpt.SubtractRunningAverageis set.Cancellation: a
core.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris set; cancel state is polled at each phase boundary and immediately before each write. TheautomaticOptionssettings dialog from MIB2 is currently skipped - the algorithm runs with whatever defaults already exist inobj.automaticOptions.- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). ReadsTransformationType,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.pyramidLeveland computes per-slice X/Y shifts viautils.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 toapplyAlignmentBigData()withmode = '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.zarr3store), plusmethod,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 withutils.align.crossShiftStack(). Mask, selection, and labels layers are realigned with the same shifts so the whole dataset stays consistent.Cancellation: a
core.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris 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 fieldsmethod,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(). ReadsTransformationType,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.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris 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 withimwarp(..., 'OutputView', imref2d([H, W]))and written back to its slot viasetData2D().parameters.TransformationMode = 'extended'grows the canvas to fit the union of all warped slices; service layers are pre-resized to the new canvas beforesetData4D().
- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). ReadsTransformationType,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 (applyAlignmentBigDatamode='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 fieldsisBigData(true),outputPath, plusmethod,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.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris set; the cancel state is polled at the top of every iteration and before any irreversible write back to the model.- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). OnlybackgroundColor,useBatchModeare used here.
- 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
selectionlayer, treats those centroids as corresponding landmarks, fits anaffinetransform withfitgeotrans(), and warps every slice fromlayer+1toDepthwithimwarp(). The warped tail is then concatenated to the unchanged head1:layerviautils.align.crossShiftStacks()so the canvas grows to fit both pieces.Cancellation: a
core.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris 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(). OnlybackgroundColor,colorCh,useBatchModeare read here.
- static ViewListner_Callback2(~, evnt)¶
VIEWLISTNER_CALLBACK2 - Static guarded listener callback.
- Syntax:
obj.ViewListner_Callback2(src, evnt)
Routes the model events
UpdateGuiWidgetsandNewDatasettoupdateWidgets(). 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
CloseRequestFcnon the figure first; assigns a single anonymous-handle callback to every widget Tag listed in the view contract. Widgets that the user’s.mlappdoes 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_Modeis enabled only for drift / template / feature-based; AMST disablesSubareaand forcescroppedmode; the feature-based variants restrictTransformationTypeto 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 fromobj.BatchOpt.HDD_InputDir(filtered byHDD_InputFilenameExtension) viamatlab.io.datastore.ImageDatastoreconfigured withio.loadImagesWrapper()as itsReadFcn; computes FFT cross-correlation pairwise; integrates pairwise shifts viacumsum(CorrelateWith = 'Previous slice'/'Relative to') or keeps slice 1 as the reference throughout (CorrelateWith = 'First slice'); optionally smooths viautils.align.subtractRunningAverage()(interactive loop whenuseBatchModeis false, straight batch otherwise); then re-reads each image, places it onto a padded canvas, and saves it to<InputDir>/HDD_OutputSubfolderNamein the chosen format viacore.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
NewDatasetnotify is suppressed.Cancellation: a
core.PoolWaitbaris constructed withCancelable = truewheneverBatchOpt.showWaitbaris set; cancel state is polled between every image.- Input Arguments:
parameters - struct produced by
continueBtn_Callback(). Readsmethod,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 (nomibModel.backupis taken in BigData paths).- Pipeline:
Build per-slice level-0 transforms + the level-0 output canvas (
extendedgrowth orcroppedoriginal dims).One shared level plan (
Zarr3Saver.computeLevelPlan) so the image store (built bysaveStream) and the labels store (built bycreateStore) share identical level sizes / scale factors / chunks.Stream the image store via
Zarr3Saver.saveStream+io.savers.AlignedImageSliceProvider.Warp packed-63 labels/mask/selection (nearest-neighbour) into a new
MibBigDataLabelsstore;materializeAll+closeStore(persists the level map).Patch metadata (bounding box + per-level translation/scale).
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 ofaffinetform2d(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
parametersstruct fromobj.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]
truewhen the controller was invoked via the batch processor (no GUI). Defaultfalse.
- 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 thatX1(j)matchesX2(idx(j));NaNfor 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/maxYwidgets and the matchingBatchOptfields.
- gui_Callbacks(source, event)¶
#ok<INUSD> GUI_CALLBACKS - Dispatcher for every Alignment widget callback.
- Syntax:
obj.gui_Callbacks(source, event)
Routes by
source.Tagto the appropriate action method. Widgets that only need to keepBatchOptin sync fall through theotherwisebranch.- Input Arguments:
obj -
controllers.Alignmentinstance.source - widget handle that fired the event.
event - event data (unused).
- loadShiftsCheck_Callback()¶
LOADSHIFTSCHECK_CALLBACK - Load pre-computed shifts from a
.coefXYfile.- Syntax:
obj.loadShiftsCheck_Callback()
When the
loadShiftsCheckcheckbox is enabled the user is prompted for a.coefXYfile. The file may containshiftsX/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 (seepreviewConfirmLoadedShifts()), 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
FeatureDetectorTypewidget, matches the descriptors, robust-fits a 2-D geometric transform (RANSAC viaestgeotform2d), 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 / WidthAutomatic 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
BatchOpttomibBatchControllerviaSyncBatch.- 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 viautils.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 selectedAlgorithm:AMST: median-smoothed template- image downsampling + pyramid levels +imregconfigoptimizer 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 selectedFeatureDetectorType, and theestgeotform2d(RANSAC) settings - delegated to the sharedutils.align.detectorSettingsDlg()(also used by the Stitching tool).
Updates
obj.automaticOptionsin place; the algorithm methods read from there.- Output Arguments:
status -
1when the user clicked OK and settings were applied;0when the dialog was cancelled.
- updateBatchOptFromGUI(hObject)¶
UPDATEBATCHOPTFROMGUI - Sync
obj.BatchOptfrom a single widget.- Syntax:
obj.updateBatchOptFromGUI(hObject)
- updateWidgets()¶
UPDATEWIDGETS - Refresh dialog widgets from the current dataset.
- Syntax:
obj.updateWidgets()