spatialdata.models.Labels2DModel#

class spatialdata.models.Labels2DModel(*args, **kwargs)#

Attributes table#

Methods table#

parse(data[, dims, transformations, ...])

Validate (or parse) raster data.

to_json(**dumps_kws)

rtype:

str

validate(data)

Validate data.

Attributes#

Labels2DModel.array_type = <xarray_schema.components.ArrayTypeSchema object>#
Labels2DModel.attrs = <xarray_schema.components.AttrsSchema object>#
Labels2DModel.checks#
Labels2DModel.chunks#
Labels2DModel.coords#
Labels2DModel.dims = <xarray_schema.components.DimsSchema object>#
Labels2DModel.dtype#
Labels2DModel.json#
Labels2DModel.name#
Labels2DModel.shape#

Methods#

classmethod Labels2DModel.parse(data, dims=None, transformations=None, scale_factors=None, method=None, chunks=None, **kwargs)#

Validate (or parse) raster data.

Parameters:
  • data (ndarray[Any, dtype[float64]] | DataArray | Array) – Data to validate (or parse). The shape of the data should be c(z)yx for 2D (3D) images and (z)yx for 2D ( 3D) labels. If you have a 2D image with shape yx, you can use numpy.expand_dims() (or an equivalent function) to add a channel dimension.

  • dims (Optional[Sequence[str]] (default: None)) – Dimensions of the data.

  • transformations (Optional[dict[str, BaseTransformation]] (default: None)) – Transformations to apply to the data.

  • scale_factors (Optional[Sequence[Union[dict[str, int], int]]] (default: None)) – Scale factors to apply for multiscale. If not None, a xarray.DataArray is returned.

  • method (Optional[Methods] (default: None)) – Method to use for multiscale.

  • chunks (Union[int, tuple[int, ...], tuple[tuple[int, ...], ...], Mapping[Any, Union[None, int, tuple[int, ...]]], None] (default: None)) – Chunks to use for dask array.

  • kwargs (Any) – Additional arguments for to_spatial_image(). In particular the c_coords kwargs argument (an iterable) can be used to set the channel coordinates for image data. c_coords is not available for labels data as labels do not have channels.

Return type:

DataArray | DataTree

Returns:

: xarray.DataArray or datatree.DataTree.

Labels2DModel.to_json(**dumps_kws)#
Return type:

str

Labels2DModel.validate(data)#

Validate data.

Parameters:

data (Any) – Data to validate.

Raises:

ValueError – If data is not valid.

Return type:

None