BaseSaver¶
- class io.savers.BaseSaver¶
Bases:
handleBASESAVER - Abstract base class for all MIB3 image format savers.
This class defines the standard interface that every concrete saver must implement, and provides protected utility methods shared across all formats. The design mirrors io.loaders.BaseImageLoader so that the loading and saving layers are symmetric.
DATA CONVENTION All data passed to save() uses the MIB3 native dimension order: data = [Height, Width, Depth, Colors, Time] (5-D) Each saver is responsible for any permutation required by the underlying file-format library (e.g. imwrite expects [H W C D]).
METADATA CONVENTION metadata is a plain struct populated by MibImage.save() or MibLabels.save() from the object’s own properties. MibDataset additionally injects .pixSize before delegating. Required fields: .filename - (char) source image filename .colorType - (char) ‘grayscale’ | ‘multichannel’ | ‘indexed’ .lutColors - (double [C x 3]) per-channel LUT, values 0..1 .dataClass - (char) ‘uint8’ | ‘uint16’ | ‘uint32’ | … .maxInt - (double) maximum representable intensity .sliceName - (cell of char) per-slice source filenames .sliceSize - (double [N×2]) per-slice original [height, width]; empty when uniform Optional fields injected by MibDataset: .pixSize - struct {.x .y .z .t .units .tunits} .boundingBox - [xmin xmax ymin ymax zmin zmax] .imageDescription - (char) full ImageDescription tag .xResolution - scalar pixels/unit horizontal .yResolution - scalar pixels/unit vertical Label-specific fields injected by MibLabels.save(): .materialNames - cell array of material name strings .materialColors - [M x 3] per-material RGB (0..1) .labelsVariable - (char) variable name used inside .model/.mat Mask-specific fields injected by MibDataset.save(): .maskFilename - (char) mask output filename .maskColor - [1 x 3] mask overlay colour (0..1)
USAGE (from user scripts) The preferred entry points are the high-level methods: core.MibImage.save(filename, options) core.MibDataset.save(layerType, filename, options) models.MibModel.save(layerType, filename, BatchOptIn)
Direct use of a saver is possible for advanced workflows: saver = io.SaverFactory.create(‘TIF format uncompressed (
*.tif)’); fnOut = saver.save(data, metadata, ‘/tmp/out.tif’, options);SEE ALSO io.SaverFactory, io.loaders.BaseImageLoader
- Property Summary
- Options¶
Options struct passed during construction (may be empty)
- ParentFigure¶
Path to MIB installation directory; used by dialogs. Set from options.mibPath at construction time; empty in standalone use.
- WaitbarHandle¶
Handle to the main MIB application window. Required as parent for uiprogressdlg progress bars. Set from options.ParentFigure at construction time; empty in standalone use.
- mibPath¶
- Method Summary
- saveStream(provider, metadata, filename, options)¶
SAVESTREAM - Write a dataset one Z-slice at a time from a SliceProvider.
- Syntax:
fnOut = obj.saveStream(provider, metadata, filename, options)
This is the memory-bounded entry point used by
core.MibImage.save/core.MibLabels.saveto export pyramidal (Virtual / BigData) datasets without ever gathering the full volume: the saver pulls each slice fromprovider(anio.savers.SliceProvider) on demand.Default implementation (this method) is a fallback: it gathers the provider into a full
[H W D C T]array and delegates toobj.save. That keeps every not-yet-migrated saver working - memory is still bounded by the selected pyramid level (the caller chooses a coarse level), but a level is held whole. Savers overridesaveStreamto write truly slice-by-slice (e.g.io.savers.TiffSaver).- Input Arguments:
provider -
io.savers.SliceProviderexposingOutputSize,DataClass,NumSlices,NumFrames,NumChannelsandgetSlice(z, t)metadata - struct (see class-level description)
filename - [char] full output path including extension
options - struct of runtime options (see
save)
- Output Arguments:
fnOut - [char | cell of char] saved path(s);
[]on failure
Example - stream a resident volume to any registered format:
data = uint8(rand(128,128,20,1,1) * 255); % [H W D C T] provider = io.savers.InMemorySliceProvider(data); saver = io.SaverFactory.create('NRRD Data Format (*.nrrd)'); meta.colorType = 'grayscale'; meta.dataClass = 'uint8'; meta.pixSize = struct('x',1,'y',1,'z',1,'t',1,'units','um','tunits','s'); fnOut = saver.saveStream(provider, meta, 'C:\out\vol.nrrd', struct('silent',true));