Internals

Documentation for all non-exported functions can be found below:

Common

OMETIFF.loadFunction
load(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 loading
  • inmemory::Bool: controls whether arrays are fully loaded into memory (default) or left on disk and specific parts only loaded when accessed.
Tip

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)
source
OMETIFF.dump_omexmlFunction
dump_omexml(filepath) -> String

Returns the OME-XML embedded inside the OME-TIFF as a prettified string.

source

Types

OMETIFF.DiskOMETaggedImageType

A 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.

  • ifds

    A map of dimensions (sans XY) to the corresponding TiffFile and IFD

  • 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

source
TiffImages.IFDType
struct 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")
Note

Tags are not required to be unique! See TiffImages.Iterable for how to work with duplicate tags.

TiffImages.TiffFileType
mutable 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!Function
ifdindex!(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 dimensions
  • ifd_files::OrderedDict{Int, Tuple{String, String}}: A mapping from IFD number to the filepath and UUID of the file it's located in
  • obs_filepaths::Dict{String, Int}: A list of observed filepaths mapped to the offset of their IFDs
  • image::EzXML.Node: The OMEXML rooted at the current position
  • dims::NamedTuple: Sizes of each dimension with the names as keys
  • tifffile::TiffFile: A pointer to the root file
  • posidx::Int: The index of the current position

The first two parameters should be then pumped through OMETIFF.get_ifds

source
OMETIFF.get_ifdsFunction
get_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 object
  • OrderedDict{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
source
OMETIFF.build_axesFunction
build_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 the order that they are specified in the OMEXML.
  • Vector{AxisArray.Axis}: List of AxisArray.Axis objects with units (if possible) in the same order as above
Warning

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.

source

Construction

OMETIFF.inmemoryarrayFunction
inmemoryarray(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.

source

Miscellaneous

Base.iterateFunction
iterate(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.

source
OMETIFF.get_elapsed_timesFunction
get_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.

source
OMETIFF.get_unitful_axisFunction
get_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.

source
OMETIFF.load_commentsFunction
load_comments(file) -> String

Extracts the MicroManager embedded description, if present. Else returns an empty string.

source
OMETIFF.load_master_xmlFunction
load_master_xml(file::TiffFile) -> EzXML.doc

Loads the master OME-XML file from file or from a linked file.

source
OMETIFF.to_symbolFunction
to_symbol(input) -> String

Cleans up input string and converts it into a symbol, needed so that channel names work with AxisArrays.

source