cosem
This module contains Pydantic models for "COSEM-flavored" multiscale images. These images are stored in the N5 format, and use a layout / metadata that's compatible with the Neuroglancer visualization tool.
Note that the hierarchy convention modeled here will likely be superceded by conventions defined in the OME-NGFF specification.
STTransform #
Bases: BaseModel
Representation of an N-dimensional scaling -> translation transform for labelled axes with units.
This metadata was created within COSEM/Cellmap at a time when existing spatial metadata conventions for images stored in chunked file formats could not express a name, translation, or unit per axis.
The creation of STTransform
metadata preceded version 0.4 of OME-NGFF,
which can express the same information. STTransform
metadata should not be used if
the OME-NGFF metadata is available.
Attributes:
Name | Type | Description |
---|---|---|
axes |
Sequence[str]
|
Names for the axes of the data. |
units |
Sequence[str]
|
Units for the axes of the data. |
translate |
Sequence[float]
|
The location of the origin of the data, in units given specified by the |
scale |
Sequence[float]
|
The difference between adjacent coordinates of the data, in units specified by
the |
order |
Optional[Literal['C', 'F']]
|
Defines the array indexing convention assumed by the The default is "C". If |
ArrayMetadata #
Bases: BaseModel
Metadata for an array in a multiscale group.
Attributes:
Name | Type | Description |
---|---|---|
transform |
STTransform
|
A description of axis names, units, scaling, and translation for this array. |
pixelResolution |
PixelResolution
|
A description of the scaling and unit for this array. This metadata redundantly
expresses a strict subset of the information expressed by |
from_transform
classmethod
#
Generate an instance of ArrayMetadata from an STTtransform`
Source code in src/cellmap_schemas/multiscale/cosem.py
check_dimensionality #
Check that pixelResolution
and transform
are consistent.
Source code in src/cellmap_schemas/multiscale/cosem.py
ScaleMetadata #
Bases: BaseModel
Metadata for an entry in MultiscaleMetadata.datasets
, which is group metadata that
contains a list of references to arrays. Structurally, ScaleMetadata
is the same
as ArrayMetadata
,
but with an additional field, path
.
Attributes:
Name | Type | Description |
---|---|---|
transform |
STTransform
|
A description of axis names, units, scaling, and translation for the array referenced by this metadata. |
path |
str
|
The path to the array referenced by this metadata, relative to the group that contains this metadata. |
MultiscaleMetadata #
Bases: BaseModel
Multiscale metadata used by COSEM/Cellmap for datasets published on OpenOrganelle. Inspired by this discussion.
This metadata should be present in the attributes of an N5 group under the key
multiscales
.
Attributes:
Name | Type | Description |
---|---|---|
name |
Optional[str]
|
A name for this multiscale group. Rarely used. |
datasets |
Sequence[ScaleMetadata]
|
A sequence of |
from_transforms
classmethod
#
Create an instance of MultiscaleMetadata
from a dict of STTransform
and an optional name.
Source code in src/cellmap_schemas/multiscale/cosem.py
GroupMetadata #
Bases: GroupMetadata
Multiscale metadata used by COSEM/Cellmap for multiscale datasets saved in N5 groups.
Note that this class inherits attributes from
neuroglancer_n5.GroupMetadata
.
Those attributes are necessary to ensure that the N5 group can be displayed properly
by the Neuroglancer visualization tool.
Additional attributes are added by this class in to express properties of the
multiscale group that cannot be expressed by neuroglancer_n5.GroupMetadata
. However,
this results in some redundancy, as the total metadata describes several properties
of the data multiple times (e.g., the resolution of the images is conveyed
redundantly, as are the axis names).
Attributes:
Name | Type | Description |
---|---|---|
multiscales |
List[MultiscaleMetadata]
|
This metadata identifies the group as a multiscale group, i.e. a collection of images at different levels of detail. |
from_transforms
classmethod
#
Create MultiscaleMetadata
from a dict of STTransform
and an optional name.
Source code in src/cellmap_schemas/multiscale/cosem.py
Array #
Bases: ArraySpec
The metadata for a single scale level of a multiscale group.
Attributes:
Name | Type | Description |
---|---|---|
attributes |
ArrayMetadata
|
|
check_consistent_transform #
Check that the spatial metadata in the attributes of this array are consistent with the properties of the array.
Source code in src/cellmap_schemas/multiscale/cosem.py
Group #
Bases: Group
A model of a multiscale N5 group used by COSEM/Cellmap for data presented on OpenOrganelle.
Attributes:
Name | Type | Description |
---|---|---|
attributes |
GroupMetadata
|
Metadata that conveys that this is a multiscale group, and the coordinate information of the arrays it contains. |
members |
dict[str, MultiscaleArray]
|
The members of this group must be instances of
|
check_arrays_consistent #
Check that the arrays referenced by GroupMetadata
are consist with the
arrays in members
.
Source code in src/cellmap_schemas/multiscale/cosem.py
from_arrays
classmethod
#
Create a Group
from a dict of Array
instances
Source code in src/cellmap_schemas/multiscale/cosem.py
change_coordinates #
Return a Group with new coordinates, i.e., new scale, axes, order, translate, or units. If any of these paramters are set to None (the default), then the old values are used.
The units
, axes
, and order
attributes can be changed globally.
The scale
and translation
changes will be applied to the largest image, then a scaling / translation vector will be calculated to express this change, and that
vector will be multiplied / added to the scale
/ translation
attributes of all the other images.