dacapo.experiments.tasks.predictors.inner_distance_predictor

Attributes

logger

Classes

InnerDistancePredictor

Predict signed distances for a binary segmentation task.

Module Contents

dacapo.experiments.tasks.predictors.inner_distance_predictor.logger
class dacapo.experiments.tasks.predictors.inner_distance_predictor.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)