dacapo.experiments.datasplits.datasets.arrays.binarize_array

Classes

BinarizeArray

This is wrapper around a ZarrArray containing uint annotations.

Module Contents

class dacapo.experiments.datasplits.datasets.arrays.binarize_array.BinarizeArray(array_config)

This is wrapper around a ZarrArray containing uint annotations. Because we often want to predict classes that are a combination of a set of labels we wrap a ZarrArray with the BinarizeArray and provide something like groupings=[(“mito”, [3,4,5])] where 4 corresponds to mito_mem (mitochondria membrane), 5 is mito_ribo (mitochondria ribosomes), and 3 is everything else that is part of a mitochondria. The BinarizeArray will simply combine labels 3,4,5 into a single binary channel for the class of “mito”.

We use a single channel per class because some classes may overlap. For example if you had groupings=[(“mito”, [3,4,5]), (“membrane”, [4, 8, 1])] where 4 is mito_mem, 8 is er_mem (ER membrane), and 1 is pm (plasma membrane). Now you can have a binary classification for membrane or not which in some cases overlaps with the channel for mitochondria which includes the mito membrane.

name

The name of the array.

Type:

str

source_array

The source array to binarize.

Type:

Array

background

The label to treat as background.

Type:

int

groupings

A list of tuples where the first element is the name of the class and the second element is a list of labels that should be combined into a single binary channel.

Type:

List[Tuple[str, List[int]]]

__init__(self, array_config)

This method initializes the BinarizeArray object.

__attrs_post_init__(self)

This method is called after the instance has been initialized by the constructor. It is used to set the default_config to an instance of ArrayConfig if it is None.

__getitem__(self, roi

Roi) -> np.ndarray: This method returns the binary channels for the given region of interest.

_can_neuroglance(self)

This method returns True if the source array can be visualized in neuroglance.

_neuroglancer_source(self)

This method returns the source array for neuroglancer.

_neuroglancer_layer(self)

This method returns the neuroglancer layer for the source array.

_source_name(self)

This method returns the name of the source array.

Note

This class is used to create a BinarizeArray object which is a wrapper around a ZarrArray containing uint annotations.

name
background
property attrs
This method returns the attributes of the source array.
Returns:

The attributes of the source array.

Return type:

Dict

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.attrs

Note

This method is used to return the attributes of the source array.

property axes
This method returns the axes of the source array.
Returns:

The axes of the source array.

Return type:

List[str]

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.axes

Note

This method is used to return the axes of the source array.

property dims: int

This method returns the dimensions of the source array.

Returns:

The dimensions of the source array.

Return type:

int

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.dims

Note

This method is used to return the dimensions of the source array.

property voxel_size: funlib.geometry.Coordinate

This method returns the voxel size of the source array.

Returns:

The voxel size of the source array.

Return type:

Coordinate

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.voxel_size

Note

This method is used to return the voxel size of the source array.

property roi: funlib.geometry.Roi

This method returns the region of interest of the source array.

Returns:

The region of interest of the source array.

Return type:

Roi

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.roi

Note

This method is used to return the region of interest of the source array.

property writable: bool

This method returns True if the source array is writable.

Returns:

True if the source array is writable.

Return type:

bool

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.writable

Note

This method is used to return True if the source array is writable.

property dtype
This method returns the data type of the source array.
Returns:

The data type of the source array.

Return type:

np.dtype

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.dtype

Note

This method is used to return the data type of the source array.

property num_channels: int

This method returns the number of channels in the source array.

Returns:

The number of channels in the source array.

Return type:

int

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.num_channels

Note

This method is used to return the number of channels in the source array.

property data
This method returns the data of the source array.
Returns:

The data of the source array.

Return type:

np.ndarray

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.data

Note

This method is used to return the data of the source array.

property channels
This method returns the channel names of the source array.
Returns:

The channel names of the source array.

Return type:

Iterator[str]

Raises:

ValueError – If the source array is not writable.

Examples

>>> binarize_array.channels

Note

This method is used to return the channel names of the source array.