ContrastNormalization¶
- class controllers.ContrastNormalization¶
Bases:
handleCONTRASTNORMALIZATION - Controller for slice-by-slice contrast normalization of 3D/4D datasets.
Normalizes image contrast across Z-slices or time frames using one of four strategies: full-frame Z-stack, time-series, masked-area, or background shift. Fully compatible with the MIB3 batch-processing pipeline (BatchOpt).
- Usage:
obj.mibController.startController('controllers.ContrastNormalization'); controllers.ContrastNormalization(mibModel, [], BatchOpt); % headless batch run controllers.ContrastNormalization(mibModel, [], NaN); % return BatchOpt schema obj.startController('controllers.ContrastNormalization'); % start from MibController obj.startController('controllers.ContrastNormalization'); % start from MibController
- Constructor Summary
- ContrastNormalization(mibModel, varargin)¶
CONTRASTNORMALIZATION - Construct the contrast-normalization controller.
- Syntax:
obj = controllers.ContrastNormalization(mibModel) obj = controllers.ContrastNormalization(mibModel, []) obj = controllers.ContrastNormalization(mibModel, [], BatchOptInput) obj = controllers.ContrastNormalization(mibModel, [], NaN)- Input Arguments:
mibModel - handle to
models.MibModel.varargin{1} (optional) - reserved compatibility slot.
varargin{2} (optional) -
BatchOptstruct for headless run, orNaNto return the defaultBatchOptschema viaSyncBatch.
- Property Summary
- BatchOpt¶
structure compatible with batch processing
- listener¶
cell array of listener handles
- mibModel¶
handle to MibModel
- view¶
handle to the ContrastNormalizationGUI .mlapp (empty in batch mode)
- Method Summary
- static ViewListner_Callback2(~, evnt)¶
VIEWLISTNER_CALLBACK2 - Static guarded listener callback.
- Syntax:
obj.ViewListner_Callback2(src, evnt)
Routes
UpdateGuiWidgetsandNewDatasetmodel events toupdateWidgets(). Deletes stale listeners when the controller or its view has been destroyed.- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.evnt - event data from the model.
- addCallbacks()¶
ADDCALLBACKS - Wire every widget to the central
gui_Callbacks()dispatcher.- Syntax:
obj.addCallbacks()
Sets
CloseRequestFcnon the figure, then assigns thegui_Callbacksanonymous handle to every tagged widget listed in the view contract. Widgets not yet present in the.mlappare silently skipped.
- closeWindow()¶
CLOSEWINDOW - Close the dialog, save settings, and release listeners.
- Syntax:
obj.closeWindow()
- collectSliceStats(z1, z2, t, colorCh, useMask, options)¶
COLLECTSLICESTATS - Compute per-slice mean and std for one color channel.
- Syntax:
[mean_val, std_val] = obj.collectSliceStats(z1, z2, t, colorCh, useMask, options)
Iterates over slices
z1:z2at time pointtand computes mean and standard deviation of pixel intensities. WhenuseMaskistrue, statistics are restricted to the pixels flagged byobj.BatchOpt.MaskLayer('selection'or'mask'). Slices where the mask is empty returnNaN; the caller is responsible for gap-filling.- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.z1 - first slice index (1-based).
z2 - last slice index (1-based).
t - time-point index.
colorCh - scalar color-channel index.
useMask - logical;
trueto restrict stats to the mask layer.options - struct passed to
getData2D; must contain.id.
- Output Arguments:
mean_val -
[maxZ x 1]double vector;NaNfor empty-mask slices.std_val -
[maxZ x 1]double vector;NaNfor empty-mask slices.
- continueBtn_Callback(useBatchMode)¶
CONTINUEBTN_CALLBACK - Validate, back up, and dispatch to the target-specific normalization method.
- Syntax:
obj.continueBtn_Callback() obj.continueBtn_Callback(useBatchMode)
Checks preconditions (virtual mode, indexed color type, mask presence), creates a backup for single-frame operations, then dispatches to the appropriate low-level normalization method based on
obj.BatchOpt.Target. On completion the image is re-displayed and the batch controller is notified.- Input Arguments:
useBatchMode (optional) - logical;
truewhen invoked via the batch processor (no GUI). Defaultfalse.
- gui_Callbacks(source, event)¶
#ok<INUSD> GUI_CALLBACKS - Dispatcher for every ContrastNormalization widget callback.
- Syntax:
obj.gui_Callbacks(source, event)
Routes by
source.Tagto the appropriate action method.TargetandModecases also update context-sensitive widget enable states. All other widgets fall through toupdateBatchOptFromGUI().- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.source - widget handle that fired the event.
event - event data (unused).
- normalizeBackground(colorChannel, options)¶
NORMALIZEBACKGROUND - Shift each slice based on masked background intensity.
- Syntax:
obj.normalizeBackground(colorChannel, options)
For each color channel, computes the per-slice mean intensity restricted to pixels in the mask layer (representing background regions), fills gaps where the mask is empty, and then shifts each slice so that its background mean matches a common target value. Standard deviation is not used; only a shift is applied.
- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.colorChannel -
[1 x N]vector of color-channel indices to process.options - struct with fields:
.id- dataset index..t-[tVal tVal]time-point pair..waitbar- handle to theuiprogressdlg; may be[]..waitbarOffset- base progress value before this target starts..totalSteps- total steps for the waitbar denominator..parentFig- parent figure for error dialogs.
- normalizeMaskedArea(colorChannel, options)¶
NORMALIZEMASKEDAREA - Normalize contrast using per-slice masked-area statistics.
- Syntax:
obj.normalizeMaskedArea(colorChannel, options)
For each color channel, computes the per-slice mean and standard deviation restricted to pixels in the mask layer, fills any gaps where the mask is empty, then shifts and scales each slice to match a common target mean and std.
- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.colorChannel -
[1 x N]vector of color-channel indices to process.options - struct with fields:
.id- dataset index..t-[tVal tVal]time-point pair..waitbar- handle to theuiprogressdlg; may be[]..waitbarOffset- base progress value before this target starts..totalSteps- total steps for the waitbar denominator..parentFig- parent figure for error dialogs.
- normalizeTimeSeries(colorChannel, options)¶
NORMALIZETIMESERIES - Normalize contrast across time frames.
- Syntax:
obj.normalizeTimeSeries(colorChannel, options)
For each color channel, computes mean and standard deviation per time frame (either from the currently shown 2D slice or from the full 3D stack), then shifts and scales each frame so that its statistics match the dataset-wide (or manually specified) target values.
- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.colorChannel -
[1 x N]vector of color-channel indices to process.options - struct with fields:
.id- dataset index..t1- first time-frame index..t2- last time-frame index..currentZ- Z-slice index for'Based on current 2D slice'mode..waitbar- handle to theuiprogressdlg; may be[]..waitbarOffset- base progress value before this target starts..totalSteps- total steps for the waitbar denominator.
- normalizeZStack(colorChannel, options)¶
NORMALIZEZSTACK - Normalize contrast across Z-slices of a single time point.
- Syntax:
options = obj.normalizeZStack(colorChannel, options)
For each color channel, computes the per-slice mean and standard deviation over the full image frame and adjusts each slice so that its mean matches the dataset-wide (or manually specified) mean and its spread matches the dataset-wide std.
- Input Arguments:
obj -
controllers.ContrastNormalizationinstance.colorChannel -
[1 x N]vector of color-channel indices to process.options - struct with fields:
.id- dataset index..t-[tVal tVal]time-point pair for the single frame..waitbar- handle to theuiprogressdlg; may be[]..waitbarOffset- base progress value before this target starts..totalSteps- total number of (channel × slice) steps for the waitbar.
- returnBatchOpt(BatchOptOut)¶
RETURNBATCHOPT - Forward
BatchOpttomibBatchControllerviaSyncBatch.- Syntax:
obj.returnBatchOpt() obj.returnBatchOpt(BatchOptOut)- Input Arguments:
BatchOptOut (optional) - override struct; defaults to
obj.BatchOpt.
- updateBatchOptFromGUI(hObject)¶
UPDATEBATCHOPTFROMGUI - Sync
obj.BatchOptfrom a single widget.- Syntax:
obj.updateBatchOptFromGUI(hObject)- Input Arguments:
hObject - AppDesigner widget whose
Tagmatches aBatchOptfield.
- updateContextualWidgets()¶
UPDATECONTEXTUALWIDGETS - Enable or disable context-sensitive widgets.
- Syntax:
obj.updateContextualWidgets()
Enables
Mean/Stdonly in Manual mode;ReferenceSliceNoonly in BasedOnSlice mode;MaskLayeronly for Masked area / Background targets;TimeSeriesNormalizationonly for Time series.
- updateWidgets()¶
UPDATEWIDGETS - Refresh all GUI widgets from the current dataset state.
- Syntax:
obj.updateWidgets()
Rebuilds the
ColChanneldropdown to match the active dataset, then applies the currentBatchOptto all widgets and updates context-sensitive enable states.