LabelImage

class starfish.morphology.LabelImage(label_image: DataArray)[source]

Wraps an xarray that contains a 2D or 3D labeled image. Each axis is labeled with physical coordinate data.

Attributes:
log

Returns a copy of the provenance data.

xarray

Returns the xarray that contains the label image and the physical coordinates.

Methods

from_label_array_and_ticks(array, ...)

Constructs a LabelImage from an array containing the labels, a set of physical coordinates, and an optional log of how this label image came to be.

open_netcdf(path)

Load a label image saved as a netcdf file from disk.

to_netcdf(path)

Save the label image as a netcdf file.

classmethod from_label_array_and_ticks(array: ndarray, pixel_ticks: Optional[Union[Mapping[Axes, Union[DataArray, ndarray, Sequence[int]]], Mapping[str, Union[DataArray, ndarray, Sequence[int]]]]], physical_ticks: Union[Mapping[Coordinates, Union[DataArray, ndarray, Sequence[Union[int, float]]]], Mapping[str, Union[DataArray, ndarray, Sequence[Union[int, float]]]]], log: Optional[Log]) LabelImage[source]

Constructs a LabelImage from an array containing the labels, a set of physical coordinates, and an optional log of how this label image came to be.

Parameters:
arraynp.ndarray

A 2D or 3D array containing the labels. The ordering of the axes must be Y, X for 2D images and ZPLANE, Y, X for 3D images.

pixel_ticksOptional[Union[Mapping[Axes, ArrayLike[int]], Mapping[str, ArrayLike[int]]]]

A map from the axis to the values for that axis. For any axis that exist in the array but not in pixel_coordinates, the pixel coordinates are assigned from 0..N-1, where N is the size along that axis.

physical_ticksUnion[Mapping[Coordinates, ArrayLike[Number]], Mapping[str,
ArrayLike[Number]]]

A map from the physical coordinate type to the values for axis. For 2D label images, X and Y physical coordinates must be provided. For 3D label images, Z physical coordinates must also be provided.

logOptional[Log]

A log of how this label image came to be.

property log: Log

Returns a copy of the provenance data. Modifications to this copy will not affect the log stored on this label image.

classmethod open_netcdf(path: Union[str, Path]) LabelImage[source]

Load a label image saved as a netcdf file from disk.

Parameters:
pathUnion[str, Path]

Path of the label image to instantiate from.

Returns:
label_imageLabelImage

Label image from the path.

to_netcdf(path: Union[str, Path])[source]

Save the label image as a netcdf file.

Parameters:
pathUnion[str, Path]

Path of the netcdf file to write to.

property xarray

Returns the xarray that contains the label image and the physical coordinates.