OmeTiffSaver¶
- class io.savers.OmeTiffSaver¶
Bases:
io.savers.BaseSaverOMETIFFSAVER - Saver for OME-TIFF (Open Microscopy Environment TIFF) output.
Handles two format variants: ‘OME-TIFF 5D (.ome.tiff)’ - full 5-D OME-TIFF (single file) ‘OME-TIFF 2D sequence (.ome.tiff)’ - one OME-TIFF per Z×T slice
OME-TIFF stores the full 5-D data set [H, W, C, D, T] together with standardised OME-XML metadata describing pixel sizes, channel names, LUT colours, and acquisition information.
The saver calls io.BioFormats.mibImage2ometiff(), which is already present in MIB3 at mib/+io/+BioFormats/mibImage2ometiff.m.
DATA DIMENSIONS Input data : [H, W, D, C, T] (MIB3 native order) mibImage2ometiff() expects [H, W, C, D, T] - the saver permutes dimensions 3 and 4 before the call.
SAVING OPTIONS PASSED TO mibImage2ometiff savingOptions.pixSize - struct {.x .y .z .units .t .tunits} savingOptions.lutColors - [C x 3] channel LUT colours (0..1) savingOptions.ImageDescription - (char) dataset description savingOptions.DimensionOrder - always ‘XYCZT’ savingOptions.Saving3d - ‘5D’ | ‘2D’ savingOptions.overwrite - logical savingOptions.DatasetType - ‘image’ | ‘mask’ | ‘labels’ savingOptions.showWaitbar - logical
NOTES * OME-TIFF is the preferred format for multichannel, multi-Z, multi-time datasets because it stores all metadata in standardised OME-XML. * The output file extension is always ‘.ome.tiff’; if the user provides a different extension it is replaced automatically.
USAGE EXAMPLES
%% 1. Save 5-D multichannel stack as OME-TIFF saver = io.SaverFactory.create('OME-TIFF 5D (*.ome.tiff)'); opts.Format = 'OME-TIFF 5D (*.ome.tiff)'; opts.showWaitbar = false; opts.silent = true; opts.overwrite = true; opts.layerType = 'image'; meta.filename = 'source_stack.tif'; meta.colorType = 'multichannel'; meta.lutColors = [1 0 0; 0 1 0; 0 0 1]; % R, G, B channels meta.dataClass = 'uint16'; meta.maxInt = 65535; meta.pixSize = struct('x',0.065,'y',0.065,'z',0.2, ... 'units','um','t',1,'tunits','s'); meta.imageDescription = 'My confocal dataset'; data = uint16(rand(512,512,50,3,4)*65535); % [H W D C T] fnOut = saver.save(data, meta, '/output/myStack.ome.tiff', opts); fprintf('Saved: %s\n', fnOut);%% 2. Save as OME-TIFF 2D sequence saver = io.SaverFactory.create('OME-TIFF 2D sequence (*.ome.tiff)'); opts.Format = 'OME-TIFF 2D sequence (*.ome.tiff)'; opts.showWaitbar = true; opts.silent = true; opts.overwrite = true; opts.layerType = 'image'; meta.filename = 'source_stack.tif'; meta.colorType = 'multichannel'; meta.lutColors = [1 0 0; 0 1 0; 0 0 1]; meta.dataClass = 'uint16'; meta.maxInt = 65535; meta.pixSize = struct('x',0.065,'y',0.065,'z',0.2, ... 'units','um','t',1,'tunits','s'); data = uint16(rand(512,512,50,3,1)*65535); % [H W D C T] fnOut = saver.save(data, meta, '/output/myStack.ome.tiff', opts);%% 3. Via MibModel batch BatchOpt.LayerType = {'image'}; BatchOpt.Format = {'OME-TIFF 5D (*.ome.tiff)'}; BatchOpt.OutputDirectoryPolicy = {'Full path'}; BatchOpt.DestinationDirectory = '/output/dir'; BatchOpt.FilenamePolicy = {'Use existing name'}; BatchOpt.showWaitbar = false; BatchOpt.mibBatchTooltip.LayerType = ''; model.save('image', [], BatchOpt);SEE ALSO io.SaverFactory, io.savers.BaseSaver, io.savers.TiffSaver, io.BioFormats.mibImage2ometiff, core.MibImage.save, core.MibDataset.save, models.MibModel.save
- Constructor Summary
- OmeTiffSaver(options)¶
OMETIFFSAVER - Constructor for OmeTiffSaver class.
- Syntax:
saver = io.savers.OmeTiffSaver(options)- Input Arguments:
options - (optional) struct, saver-level options (usually empty; per-save options are passed to
save()instead)
- Output Arguments:
obj - instance of the OmeTiffSaver class
- Method Summary
- getSupportedFormats(~)¶
GETSUPPORTEDFORMATS - Return format strings handled by OmeTiffSaver.
- Syntax:
formats = obj.getSupportedFormats()- Input Arguments:
(none)
- Output Arguments:
formats - cell array of format strings for OME-TIFF output
- save(data, metadata, filename, options)¶
SAVE - Write data as an OME-TIFF file or 2-D OME-TIFF sequence.
- Syntax:
fnOut = obj.save(data, metadata, filename, options)- Input Arguments:
data - [H, W, D, C, T] numeric array
metadata - struct with fields:
colorType-'grayscale'|'multichannel'|'indexed'lutColors- [C × 3] per-channel LUT colours (0-1 range)dataClass-'uint8'|'uint16'| …maxInt- maximum intensity valuepixSize- struct {.x,.y,.z,.units,.t,.tunits}imageDescription- (optional) [char] dataset description stringsliceName- (optional) per-slice source filenames (used in 2D mode)
filename - [char] full output path; extension is always normalized to
.ome.tiffoptions - struct with fields:
Format- format string ('OME-TIFF 5D (*.ome.tiff)'or'OME-TIFF 2D sequence (*.ome.tiff)')layerType-'image'|'mask'|'labels'; default:'image'showWaitbar- logical; default:truesilent- logical, suppress dialogs; default:falseoverwrite- logical; default:trueFilenameGenerator-'Use original filename'|'Use sequential filename'(2D mode only)
- Output Arguments:
fnOut - [char] path of saved
.ome.tifffile,[]on failure
Example - see class-level documentation above.
- saveStream(provider, metadata, filename, options)¶
SAVESTREAM - Stream an OME-TIFF from a SliceProvider (memory-bounded).
- Syntax:
fnOut = obj.saveStream(provider, metadata, filename, options)
Memory-bounded twin of
save: instead of receiving a full[H W D C T]array it pulls each Z-slice fromprovider.getSlice(z, t)(anio.savers.SliceProvider) so a large pyramid level is never gathered whole - peak memory stays at one XY slice.5D mode - writes a single OME-TIFF, streaming one plane at a time through the Bio-Formats Java writer (
loci.formats.ImageWriter/OMETiffWriter.saveBytes). OME-XML metadata is built from the provider’s dimensions (MetadataTools.populateMetadata), so no full array is needed.2D sequence mode - writes one
.ome.tiffper Z×T slice viaimwrite.
NOTE: streaming bounds memory along Z. A single very large XY plane (e.g. a gigapixel WSI at full resolution, Z=1) is still held whole; tiled BigTIFF output for that case is separate future work.
Input/Output: see
io.savers.BaseSaver.saveStream.