Internals
Documentation for all non-exported functions can be found below:
Common
OMETIFF.load
— Functionload(io; dropunused, verbose, inmemory) -> ImageMetadata.ImageMeta
Load an OMETIFF file using the stream io
.
Arguments
dropunused::Bool
: controls whether dimensions of length 1 are dropped automatically (default) or not.verbose::Bool
: if true then prints a progress bar during loadinginmemory::Bool
: controls whether arrays are fully loaded into memory (default) or left on disk and specific parts only loaded when accessed.
The inmemory=false
flag currently returns a read-only view of the data on the disk for data integrity reasons. In order to modify the contents, you must copy the data into an in-memory container–at least until #52 is fixed–like so:
copy(arr)
OMETIFF.dump_omexml
— Functiondump_omexml(filepath) -> String
Returns the OME-XML embedded inside the OME-TIFF as a prettified string.
Types
OMETIFF.DiskOMETaggedImage
— TypeA lazy representation of a OMETIFF file. This custom type is needed since TIFF files are laid out noncontiguously and nonregularly. It uses an internal index to determine the mapping from indices to the locations of data slices on disk. These slices are generally XY slices and are usually loaded in all at once so it is quickly loaded into an internal cache to speed up the process. Externally, this type should behave very similarly to an in-memory array, albeit with a higher cost of accessing an element.
dims
The full set of dimensions of the TIFF file, including XY
cache
An internal cache to fill when reading from disk
cache_index
The dimension indices corresponding to the slice currently in the cache
TiffImages.IFD
— Typestruct IFD{O<:Unsigned}
An image file directory is a sorted collection of the tags representing this plane in the TIFF file. They behave like dictionaries except that tags aren't required to be unique, so given an IFD called ifd
, we can add new tags as follows:
julia> ifd[TiffImages.IMAGEDESCRIPTION] = "Some details";
julia> ifd[TiffImages.IMAGEWIDTH] = 512;
julia> ifd
IFD, with tags:
Tag(IMAGEWIDTH, 512)
Tag(IMAGEDESCRIPTION, "Some details")
Tags are not required to be unique! See TiffImages.Iterable
for how to work with duplicate tags.
TiffImages.TiffFile
— Typemutable struct TiffFile{O<:Unsigned, S<:FileIO.Stream}
-> TiffFile
Wrap io
with helper parameters to keep track of file attributes.
uuid
A unique identifier for this file
filepath
The relative path to this file
io
The file stream
first_offset
Location of the first IFD in the file stream
need_bswap
Whether this file has a different endianness than the host computer
Logic
These are the key logic functions that work through the OME and TIFF data and determine the mapping between these two. Future changes to the OME specification should be handle in these functions.
OMETIFF.ifdindex!
— Functionifdindex!(ifd_index, ifd_files, obs_filepaths, image, dims, tifffile, posidx)
OMEXML is very flexible with its representation of the IFDs in the TIFF image. This function attempts to handle many of the exceptions and update the passed collections with the proper mapping of which TiffData elements correspond to which IFDs (and which files these IFDs are located in) inside the TIFF image.
Arguments
ifd_index::OrderedDict{Int, NTuple{4, Int}}
: A mapping from IFD number to dimensionsifd_files::OrderedDict{Int, Tuple{String, String}}
: A mapping from IFD number to the filepath and UUID of the file it's located inobs_filepaths::Dict{String, Int}
: A list of observed filepaths mapped to the offset of their IFDsimage::EzXML.Node
: The OMEXML rooted at the current positiondims::NamedTuple
: Sizes of each dimension with the names as keystifffile::TiffFile
: A pointer to the root fileposidx::Int
: The index of the current position
The first two parameters should be then pumped through OMETIFF.get_ifds
OMETIFF.get_ifds
— Functionget_ifds(orig_file, ifd_index, ifd_files) -> Dict, Dict
Run through all the IFDs extracted from the OMEXML and open all the referenced files to construct a mapping of ZCTP (not guaranteed order) index to IFD object. This is necessary because there can be multiple files referenced in a single OMEXML and we need to iterate over the files to identify the actual offsets for the data since this information isn't found in the OMEXML.
Output
Dict{Tuple{String, String}, TiffFile}
: a mapping of filepath, UUID to the actual TiffFile objectOrderedDict{NTuple{4, Int}, IFD}
: a mapping of ZCTP (or other order) index to the IFD objects in order that the IFDs are referenced in the OMEXML
OMETIFF.build_axes
— Functionbuild_axes(image) -> Tuple, Vector
Extracts the dimensions and axis information from the OMEXML data.
Output
NamedTuple{order, NTuple{6, Int}}
: the labeled 6 dimensions in theorder
that they are specified in the OMEXML.Vector{AxisArray.Axis}
: List ofAxisArray.Axis
objects with units (if possible) in the sameorder
as above
There's no guarantee that the dimension sizes extracted here are correct if the acquisition was cancelled during a multiposition session. See #38. Downstream functions should be flexible and handle these cases.
Construction
OMETIFF.inmemoryarray
— Functioninmemoryarray(ifds, dims, rawtype, mappedtype) -> Array
Builds an in-memory high-dimensional image using the mapping provided by ifds
from indices to OMETIFF.IFD
objects. The IFD objects store handles to the file objects and the offsets for the data. dims
stores the size of each named dimension. The rawtype
parameter describes the storage layout of each element on disk and mappedtype
is the corresponding fixed or floating point type.
Miscellaneous
Base.iterate
— Functioniterate(iter [, state]) -> Union{Nothing, Tuple{Any, Any}}
Advance the iterator to obtain the next element. If no elements remain, nothing
should be returned. Otherwise, a 2-tuple of the next element and the new iteration state should be returned.
OMETIFF.get_elapsed_times
— Functionget_elapsed_times(containers, master_dims, masteraxis)
-> AxisArray
Extracts the actual acquisition times from the OME-XML data. Takes containers
, a vector of the XML nodes corresponding to the root of each image.
OMETIFF.get_unitful_axis
— Functionget_unitful_axis(image, dimsize, stepsize, units) -> Range
Attempts to return a unitful range with a length of dimsize
. Parameters stepsize
and units
should be the XML tags in image
.
OMETIFF.load_comments
— Functionload_comments(file) -> String
Extracts the MicroManager embedded description, if present. Else returns an empty string.
OMETIFF.load_master_xml
— Functionload_master_xml(file::TiffFile) -> EzXML.doc
Loads the master OME-XML file from file
or from a linked file.
OMETIFF.to_symbol
— Functionto_symbol(input) -> String
Cleans up input
string and converts it into a symbol, needed so that channel names work with AxisArrays.