dacapo.experiments.tasks.predictors

Submodules

Classes

DummyPredictor

A dummy predictor class that inherits from the base Predictor class.

DistancePredictor

Predict signed distances for a binary segmentation task.

OneHotPredictor

A predictor that uses one-hot encoding for classification tasks.

Predictor

A predictor is a class that defines how to train a model to predict a

AffinitiesPredictor

A predictor for generating affinity predictions from input data.

InnerDistancePredictor

Predict signed distances for a binary segmentation task.

HotDistancePredictor

Predict signed distances and one hot embedding (as a proxy task) for a binary segmentation task.

Package Contents

class dacapo.experiments.tasks.predictors.DummyPredictor(embedding_dims)

A dummy predictor class that inherits from the base Predictor class.

embedding_dims

The number of embedding dimensions.

Type:

int

__init__(self, embedding_dims

int): Initializes a new instance of the DummyPredictor class.

create_model(self, architecture)

Creates a model using the given architecture.

create_target(self, gt)

Creates a target based on the ground truth.

create_weight(self, gt, target, mask, moving_class_counts=None)

Creates a weight based on the ground truth, target, and mask.

output_array_type()

Gets the output array type.

Notes

This is a subclass of Predictor.

embedding_dims
create_model(architecture)

Creates a model using the given architecture.

Parameters:

architecture – The architecture to use for creating the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Creates a target based on the ground truth.

Parameters:

gt – The ground truth.

Returns:

The created target.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Creates a weight based on the ground truth, target, and mask.

Parameters:
  • gt – The ground truth.

  • target – The target.

  • mask – The mask.

  • moving_class_counts – The moving class counts.

Returns:

The created weight and None.

Return type:

Tuple[NumpyArray, None]

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Gets the output array type.
Returns:

The output array type.

Return type:

EmbeddingArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.output_array_type
class dacapo.experiments.tasks.predictors.DistancePredictor(channels: List[str], scale_factor: float, mask_distances: bool, clipmin: float = 0.05, clipmax: float = 0.95)

Predict signed distances for a binary segmentation task. Distances deep within background are pushed to -inf, distances deep within the foreground object are pushed to inf. After distances have been calculated they are passed through a tanh so that distances saturate at +-1. Multiple classes can be predicted via multiple distance channels. The names of each class that is being segmented can be passed in as a list of strings in the channels argument.

channels

The list of class labels.

Type:

List[str]

scale_factor

The scale factor for the distance transform.

Type:

float

mask_distances

Whether to mask distances.

Type:

bool

clipmin

The minimum value to clip the weights to.

Type:

float

clipmax

The maximum value to clip the weights to.

Type:

float

__init__(self, channels

List[str], scale_factor: float, mask_distances: bool, clipmin: float = 0.05, clipmax: float = 0.95): Initializes the DistancePredictor.

create_model(self, architecture)

Create the model for the predictor.

create_target(self, gt)

Create the target array for training.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight array for training.

output_array_type()

Get the output array type.

create_distance_mask(self, distances, mask, voxel_size, normalize=None, normalize_args=None)

Create the distance mask.

process(self, labels, voxel_size, normalize=None, normalize_args=None)

Process the labels array.

gt_region_for_roi(self, target_spec)

Get the ground-truth region for the ROI.

padding(self, gt_voxel_size

Coordinate) -> Coordinate: Get the padding needed for the ground-truth array.

Notes

The DistancePredictor is used to predict signed distances for a binary segmentation task. The distances are calculated using the distance_transform_edt function from scipy.ndimage.morphology. The distances are then passed through a tanh function to saturate the distances at +-1. The distances are calculated for each class that is being segmented and are stored in separate channels. The names of each class that is being segmented can be passed in as a list of strings in the channels argument. The scale_factor argument is used to scale the distances. The mask_distances argument is used to determine whether to mask distances. The clipmin argument is used to determine the minimum value to clip the weights to. The clipmax argument is used to determine the maximum value to clip the weights to.

channels
norm = 'tanh'
dt_scale_factor
mask_distances
max_distance
epsilon = 0.05
threshold = 0.8
clipmin
clipmax
property embedding_dims
Get the number of embedding dimensions.
Returns:

The number of embedding dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> embedding_dims = predictor.embedding_dims
create_model(architecture)

Create the model for the predictor.

Parameters:

architecture – The architecture for the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target array for training.

Parameters:

gt – The ground-truth array.

Returns:

The created target array.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight array for training, given a ground-truth and associated target array.

Parameters:
  • gt – The ground-truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The weight array and the moving class counts.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Get the output array type.
Returns:

The output array type.

Return type:

DistanceArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.output_array_type
create_distance_mask(distances: numpy.ndarray, mask: numpy.ndarray, voxel_size: funlib.geometry.Coordinate, normalize=None, normalize_args=None)

Create a distance mask.

Parameters:
  • distances (np.ndarray) – The distances array.

  • mask (np.ndarray) – The mask array.

  • voxel_size (Coordinate) – The voxel size.

  • normalize (str) – The normalization method.

  • normalize_args – The normalization arguments.

Returns:

The distance mask.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_distance_mask(distances, mask, voxel_size, normalize, normalize_args)
process(labels: numpy.ndarray, voxel_size: funlib.geometry.Coordinate, normalize=None, normalize_args=None)

Process the labels array and convert it to one-hot encoding.

Parameters:
  • labels (np.ndarray) – The labels array.

  • voxel_size (Coordinate) – The voxel size.

  • normalize (str) – The normalization method.

  • normalize_args – The normalization arguments.

Returns:

The distances array.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.process(labels, voxel_size, normalize, normalize_args)
gt_region_for_roi(target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI. By default, uses the same ROI.

Parameters:

target_spec – The ROI for which the target is requested.

Returns:

The ROI for which the ground-truth is requested.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.gt_region_for_roi(target_spec)
padding(gt_voxel_size: funlib.geometry.Coordinate) funlib.geometry.Coordinate

Return the padding needed for the ground-truth array.

Parameters:

gt_voxel_size (Coordinate) – The voxel size of the ground-truth array.

Returns:

The padding needed for the ground-truth array.

Return type:

Coordinate

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.padding(gt_voxel_size)
class dacapo.experiments.tasks.predictors.OneHotPredictor(classes: List[str])

A predictor that uses one-hot encoding for classification tasks.

classes

The list of class labels.

Type:

List[str]

__init__(self, classes

List[str]): Initializes the OneHotPredictor.

create_model(self, architecture)

Create the model for the predictor.

create_target(self, gt)

Create the target array for training.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight array for training.

output_array_type()

Get the output array type.

process(self, labels

np.ndarray): Process the labels array and convert it to one-hot encoding.

Notes

This is a subclass of Predictor.

classes
property embedding_dims
Get the number of embedding dimensions.
Returns:

The number of embedding dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> embedding_dims = predictor.embedding_dims
create_model(architecture)

Create the model for the predictor.

Parameters:

architecture – The architecture for the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target array for training.

Parameters:

gt – The ground truth array.

Returns:

The created target array.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> target = predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight array for training.

Parameters:
  • gt – The ground truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The created weight array and None.

Return type:

Tuple[NumpyArray, None]

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Get the output array type.
Returns:

The output array type.

Return type:

ProbabilityArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> output_array_type = predictor.output_array_type
process(labels: numpy.ndarray)

Process the labels array and convert it to one-hot encoding.

Parameters:

labels (np.ndarray) – The labels array.

Returns:

The one-hot encoded array.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> one_hots = predictor.process(labels)

Notes

Assumes labels has a singleton channel dim and channel dim is first.

class dacapo.experiments.tasks.predictors.Predictor

A predictor is a class that defines how to train a model to predict a certain output from a certain input.

A predictor is responsible for creating the model, the target, the weight, and the output array type for a given training architecture.

create_model(self, architecture

“Architecture”) -> “Model”: Given a training architecture, create a model for this predictor.

create_target(self, gt

“Array”) -> “Array”: Create the target array for training, given a ground-truth array.

create_weight(self, gt

“Array”, target: “Array”, mask: “Array”, moving_class_counts: Any) -> Tuple[“Array”, Any]: Create the weight array for training, given a ground-truth and associated target array.

gt_region_for_roi(self, target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI.

padding(self, gt_voxel_size

Coordinate) -> Coordinate: Return the padding needed for the ground-truth array.

Notes

This is a subclass of ABC.

abstract create_model(architecture: dacapo.experiments.architectures.architecture.Architecture) dacapo.experiments.model.Model

Given a training architecture, create a model for this predictor. This is usually done by appending extra layers to the output of the architecture to get the output tensor of the architecture into the right shape for this predictor.

Parameters:

architecture – The training architecture.

Returns:

The model.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_model(architecture)
abstract create_target(gt: dacapo.experiments.datasplits.datasets.arrays.Array) dacapo.experiments.datasplits.datasets.arrays.Array

Create the target array for training, given a ground-truth array.

In general, the target is different from the ground-truth.

The target is the array that is passed to the loss, and hence directly compared to the prediction (i.e., the output of the model). Depending on the predictor, the target can therefore be different from the ground-truth (e.g., an instance segmentation ground-truth would have to be converted into boundaries, if the model is predicting boundaries).

By default, it is assumed that the spatial dimensions of ground-truth and target are the same.

If your predictor needs more ground-truth context to create a target (e.g., because it predicts the distance to a boundary, up to a certain threshold), you can request a larger ground-truth region. See method gt_region_for_roi.

Parameters:

gt – The ground-truth array.

Returns:

The target array.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_target(gt)
abstract create_weight(gt: dacapo.experiments.datasplits.datasets.arrays.Array, target: dacapo.experiments.datasplits.datasets.arrays.Array, mask: dacapo.experiments.datasplits.datasets.arrays.Array, moving_class_counts: Any) Tuple[dacapo.experiments.datasplits.datasets.arrays.Array, Any]

Create the weight array for training, given a ground-truth and associated target array.

Parameters:
  • gt – The ground-truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The weight array and the moving class counts.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
abstract property output_array_type
gt_region_for_roi(target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI. By default, uses the same ROI.

Overwrite this method to request ground-truth in a larger ROI, as needed.

Parameters:

target_spec – The ROI for which the target is requested.

Returns:

The ROI for which the ground-truth is requested.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.gt_region_for_roi(target_spec)
padding(gt_voxel_size: funlib.geometry.Coordinate) funlib.geometry.Coordinate

Return the padding needed for the ground-truth array.

Parameters:

gt_voxel_size – The voxel size of the ground-truth array.

Returns:

The padding needed for the ground-truth array.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.padding(gt_voxel_size)
class dacapo.experiments.tasks.predictors.AffinitiesPredictor(neighborhood: List[funlib.geometry.Coordinate], lsds: bool = True, num_voxels: int = 20, downsample_lsds: int = 1, grow_boundary_iterations: int = 0, affs_weight_clipmin: float = 0.05, affs_weight_clipmax: float = 0.95, lsd_weight_clipmin: float = 0.05, lsd_weight_clipmax: float = 0.95, background_as_object: bool = False)

A predictor for generating affinity predictions from input data.

neighborhood

The neighborhood.

Type:

List[Coordinate]

lsds

Whether to compute local shape descriptors.

Type:

bool

num_voxels

The number of voxels.

Type:

int

downsample_lsds

The downsample rate for LSDs.

Type:

int

grow_boundary_iterations

The number of iterations to grow the boundary.

Type:

int

affs_weight_clipmin

The minimum weight for affinities.

Type:

float

affs_weight_clipmax

The maximum weight for affinities.

Type:

float

lsd_weight_clipmin

The minimum weight for LSDs.

Type:

float

lsd_weight_clipmax

The maximum weight for LSDs.

Type:

float

background_as_object

Whether to treat the background as an object.

Type:

bool

__init__(

self, neighborhood: List[Coordinate], lsds: bool = True, num_voxels: int = 20, downsample_lsds: int = 1, grow_boundary_iterations: int = 0, affs_weight_clipmin: float = 0.05, affs_weight_clipmax: float = 0.95, lsd_weight_clipmin: float = 0.05, lsd_weight_clipmax: float = 0.95, background_as_object: bool = False

)

Initializes the AffinitiesPredictor.

extractor(self, voxel_size)

Get the LSD extractor.

dims()

Get the number of dimensions.

sigma(self, voxel_size)

Compute the sigma value for LSD computation.

lsd_pad(self, voxel_size)

Compute the padding for LSD computation.

num_channels()

Get the number of channels.

create_model(self, architecture)

Create the model.

create_target(self, gt)

Create the target data.

_grow_boundaries(self, mask, slab)

Grow the boundaries of the mask.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight data.

gt_region_for_roi(self, target_spec)

Get the ground truth region for the target region of interest (ROI).

output_array_type()

Get the output array type.

Notes

This is a subclass of Predictor.

neighborhood
lsds
num_voxels
grow_boundary_iterations
affs_weight_clipmin
affs_weight_clipmax
lsd_weight_clipmin
lsd_weight_clipmax
background_as_object
extractor(voxel_size)

Get the LSD extractor.

Parameters:

voxel_size (Coordinate) – The voxel size.

Returns:

The LSD extractor.

Return type:

LsdExtractor

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> extractor = predictor.extractor(voxel_size)
property dims
Get the number of dimensions.
Returns:

The number of dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.dims
sigma(voxel_size)

Compute the sigma value for LSD computation.

Parameters:

voxel_size (Coordinate) – The voxel size.

Returns:

The sigma value.

Return type:

Coordinate

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.sigma(voxel_size)
lsd_pad(voxel_size)

Compute the padding for LSD computation.

Parameters:

voxel_size (Coordinate) – The voxel size.

Returns:

The padding value.

Return type:

Coordinate

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.lsd_pad(voxel_size)
property num_channels
Get the number of channels.
Returns:

The number of channels.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.num_channels
create_model(architecture)

Create the model.

Parameters:

architecture – The architecture for the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target data.

Parameters:

gt – The ground truth data.

Returns:

The created target data.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight data.

Parameters:
  • gt – The ground truth data.

  • target – The target data.

  • mask – The mask data.

  • moving_class_counts – The moving class counts.

Returns:

The created weight data and moving class counts.

Return type:

Tuple[NumpyArray, Tuple]

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
gt_region_for_roi(target_spec)

Get the ground truth region for the target region of interest (ROI).

Parameters:

target_spec – The target region of interest (ROI) specification.

Returns:

The ground truth region specification.

Raises:

NotImplementedError – This method is not implemented.

property output_array_type
Get the output array type.
Returns:

The output array type.

Return type:

EmbeddingArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.output_array_type
class dacapo.experiments.tasks.predictors.InnerDistancePredictor(channels: List[str], scale_factor: float)

Predict signed distances for a binary segmentation task.

Distances deep within background are pushed to -inf, distances deep within the foreground object are pushed to inf. After distances have been calculated they are passed through a tanh so that distances saturate at +-1. Multiple classes can be predicted via multiple distance channels. The names of each class that is being segmented can be passed in as a list of strings in the channels argument.

channels

The list of channel names.

Type:

List[str]

scale_factor

The amount by which to scale distances before applying a tanh normalization.

Type:

float

__init__(self, channels

List[str], scale_factor: float): Initializes the InnerDistancePredictor.

create_model(self, architecture)

Create the model for the predictor.

create_target(self, gt)

Create the target array for training.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight array for training.

output_array_type()

Get the output array type.

process(self, labels

np.ndarray, voxel_size: Coordinate, normalize=None, normalize_args=None): Process the labels array and convert it to signed distances.

__find_boundaries(self, labels)

Find the boundaries in a labels array.

__normalize(self, distances, norm, normalize_args)

Normalize the distances.

gt_region_for_roi(self, target_spec)

Get the ground-truth region for the given ROI.

padding(self, gt_voxel_size

Coordinate) -> Coordinate: Get the padding needed for the ground-truth array.

Notes

This is a subclass of Predictor.

channels
norm = 'tanh'
dt_scale_factor
max_distance
epsilon = 0.05
threshold = 0.8
property embedding_dims
Get the number of embedding dimensions.
Returns:

The number of embedding dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> embedding_dims = predictor.embedding_dims
create_model(architecture)

Create the model for the predictor.

Parameters:

architecture – The architecture for the model.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target array for training.

Parameters:

gt – The ground-truth array.

Returns:

The DistanceArray.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight array for training, given a ground-truth and associated target array.

Parameters:
  • gt – The ground-truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The weight array and the moving class counts.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Get the output array type.
Returns:

The DistanceArray.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.output_array_type
process(labels: numpy.ndarray, voxel_size: funlib.geometry.Coordinate, normalize=None, normalize_args=None)

Process the labels array and convert it to signed distances.

Parameters:
  • labels – The labels array.

  • voxel_size – The voxel size.

  • normalize – The normalization method.

  • normalize_args – The normalization arguments.

Returns:

The signed distances.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.process(labels, voxel_size, normalize, normalize_args)
gt_region_for_roi(target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI. By default, uses the same ROI.

Parameters:

target_spec – The ROI for which the target is requested.

Returns:

The ROI for which the ground-truth is requested.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.gt_region_for_roi(target_spec)
padding(gt_voxel_size: funlib.geometry.Coordinate) funlib.geometry.Coordinate

Return the padding needed for the ground-truth array.

Parameters:

gt_voxel_size – The voxel size of the ground-truth array.

Returns:

The padding needed for the ground-truth array.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.padding(gt_voxel_size)
class dacapo.experiments.tasks.predictors.HotDistancePredictor(channels: List[str], scale_factor: float, mask_distances: bool)

Predict signed distances and one hot embedding (as a proxy task) for a binary segmentation task. Distances deep within background are pushed to -inf, distances deep within the foreground object are pushed to inf. After distances have been calculated they are passed through a tanh so that distances saturate at +-1. Multiple classes can be predicted via multiple distance channels. The names of each class that is being segmented can be passed in as a list of strings in the channels argument.

channels

List of strings, each string is the name of a class that is being segmented.

scale_factor

The scale factor for the distance transform.

mask_distances

Whether to mask distances based on the distance to the boundary.

norm

The normalization function to use for the distance transform.

dt_scale_factor

The scale factor for the distance transform.

max_distance

The maximum distance to consider for the distance transform.

epsilon

The epsilon value to use for the distance transform.

threshold

The threshold value to use for the distance transform.

__init__(self, channels

List[str], scale_factor: float, mask_distances: bool): Initializes the HotDistancePredictor.

create_model(self, architecture)

Create the model for the predictor.

create_target(self, gt)

Create the target array for training.

create_weight(self, gt, target, mask, moving_class_counts=None)

Create the weight array for training.

create_distance_mask(self, distances, mask, voxel_size, normalize=None, normalize_args=None)

Create the distance mask for training.

process(self, labels, voxel_size, normalize=None, normalize_args=None)

Process the labels array and convert it to one-hot encoding.

gt_region_for_roi(self, target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI.

padding(self, gt_voxel_size)

Return the padding needed for the ground-truth

Notes

This is a subclass of Predictor.

channels
norm = 'tanh'
dt_scale_factor
mask_distances
max_distance
epsilon = 0.05
threshold = 0.8
property embedding_dims
Get the number of embedding dimensions.
Returns:

The number of embedding dimensions.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> embedding_dims = predictor.embedding_dims
property classes
Get the number of classes.
Returns:

The number of classes.

Return type:

int

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> classes = predictor.classes
create_model(architecture)

Create the model for the predictor.

Parameters:

architecture – The architecture for the model.

Returns:

The created model.

Return type:

Model

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> model = predictor.create_model(architecture)
create_target(gt)

Create the target array for training.

Parameters:

gt – The ground truth array.

Returns:

The created target array.

Return type:

NumpyArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> target = predictor.create_target(gt)
create_weight(gt, target, mask, moving_class_counts=None)

Create the weight array for training, given a ground-truth and associated target array.

Parameters:
  • gt – The ground-truth array.

  • target – The target array.

  • mask – The mask array.

  • moving_class_counts – The moving class counts.

Returns:

The weight array and the moving class counts.

Return type:

Tuple[NumpyArray, np.ndarray]

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.create_weight(gt, target, mask, moving_class_counts)
property output_array_type
Get the output array type.
Returns:

The output array type.

Return type:

ProbabilityArray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> output_array_type = predictor.output_array_type

Notes

Technically this is a probability array + distance array, but it is only ever referenced for interpolatability (which is true for both).

create_distance_mask(distances: numpy.ndarray, mask: numpy.ndarray, voxel_size: funlib.geometry.Coordinate, normalize=None, normalize_args=None)

Create the distance mask for training.

Parameters:
  • distances – The distances array.

  • mask – The mask array.

  • voxel_size – The voxel size.

  • normalize – The normalization function to use.

  • normalize_args – The normalization arguments.

Returns:

The distance mask.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> distance_mask = self.create_distance_mask(distances, mask, voxel_size, normalize, normalize_args)
process(labels: numpy.ndarray, voxel_size: funlib.geometry.Coordinate, normalize=None, normalize_args=None)

Process the labels array and convert it to one-hot encoding.

Parameters:
  • labels – The labels array.

  • voxel_size – The voxel size.

  • normalize – The normalization function to use.

  • normalize_args – The normalization arguments.

Returns:

The one-hot encoded array.

Return type:

np.ndarray

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.process(labels, voxel_size, normalize, normalize_args)
gt_region_for_roi(target_spec)

Report how much spatial context this predictor needs to generate a target for the given ROI. By default, uses the same ROI.

Parameters:

target_spec – The ROI for which the target is requested.

Returns:

The ROI for which the ground-truth is requested.

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.gt_region_for_roi(target_spec)
padding(gt_voxel_size: funlib.geometry.Coordinate) funlib.geometry.Coordinate

Return the padding needed for the ground-truth array.

Parameters:

gt_voxel_size – The voxel size of the ground-truth array.

Returns:

The padding needed for the ground-truth array.

Return type:

Coordinate

Raises:

NotImplementedError – This method is not implemented.

Examples

>>> predictor.padding(gt_voxel_size)