Formats#

The mosaic.formats module provides file I/O for the geometry, density, and session formats used throughout Mosaic. Most user code only needs the high-level entry points open_file(), open_session(), and write_session(); the lower-level container types are listed for completeness.

Reading#

open_file() dispatches to the right parser based on the file extension and returns a GeometryDataContainer of one or more entities.

open_file(filename, *args, **kwargs)

Open and parse a file based on its extension.

Writing#

OrientationsWriter(points, quaternions, entities)

write_density(data, filename[, ...])

Write 3D density data to file (typically in CCP4/MRC format).

Session Files#

Mosaic sessions are written in an indexed binary format that bundles the pickled application state with optional auxiliary sections (thumbnails, metadata, …). The helpers below read and write those archives.

is_session_file(filepath)

Return True if filepath has a recognised session extension.

open_session(filepath)

Read session state, handling both legacy and indexed formats.

write_session(filepath, state[, sections])

Write a session file in the indexed format.

read_session_index(filepath)

Read the session file index.

read_session_meta(filepath)

Read session metadata without loading geometry data.

read_session_section(filepath, section)

Read raw bytes for a named section without decoding.

Streaming#

Helpers for chunked, level-of-detail access to OME-Zarr volumes.

open_omezarr(url)

Open a remote OME-Zarr store and return a VTK streaming source.

ZarrImageSource(pyramid[, initial_level])

VTK pipeline source that serves image data from a ZarrPyramid.

Data Containers#

In-memory representations returned by the parsers. GeometryDataContainer groups one or more geometry entities, while VertexPropertyContainer carries per-vertex scalar fields alongside them.

GeometryDataContainer

Container for multiple geometry entities with automatic validation.

VertexPropertyContainer

Container for managing custom vertex properties with automatic synchronization.

Exceptions#

NotASegmentationError

Raised when a volume cannot be interpreted as a segmentation.