dacapo.blockwise.empanada_function
Attributes
Functions
|
Segment a 3D block using the empanada-napari library. |
|
Perform inference on a single axis of a 3D volume. |
|
Perform inference on the orthogonal planes of a 3D volume. |
|
Segment a 3D volume using the empanada-napari library. |
|
Relabels and filters each class defined in trackers. Yields a numpy |
|
Calculate the orthoplane consensus from trackers. Yields a numpy |
Module Contents
- dacapo.blockwise.empanada_function.logger
- dacapo.blockwise.empanada_function.default_parameters
- dacapo.blockwise.empanada_function.segment_function(input_array, block, **parameters)
Segment a 3D block using the empanada-napari library.
- Parameters:
input_array (np.ndarray) – The 3D array to segment.
block (daisy.Block) – The block object.
**parameters – Parameters for the empanada-napari segmenter.
- Returns:
The segmented 3D array.
- Return type:
np.ndarray
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> import numpy as np >>> from dask import array as da >>> from dacapo.blockwise.empanada_function import segment_function >>> input_array = np.random.rand(64, 64, 64) >>> block = da.from_array(input_array, chunks=(32, 32, 32)) >>> segmented_array = segment_function(block, model_config="MitoNet_v1")
Note
The model_config parameter should be one of the following: - MitoNet_v1 - MitoNet_v2 - MitoNet_v3 - MitoNet_v4 - MitoNet_v5 - MitoNet_v6
- Reference:
doi: 10.1016/j.cels.2022.12.006
- dacapo.blockwise.empanada_function.model_configs
- dacapo.blockwise.empanada_function.stack_inference(engine, volume, axis_name)
Perform inference on a single axis of a 3D volume.
- Parameters:
engine (Engine3d) – The engine object.
volume (np.ndarray) – The 3D volume to segment.
axis_name (str) – The axis name to segment.
- Returns:
The stack, axis name, and trackers dictionary.
- Return type:
tuple
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> import numpy as np >>> from empanada_napari.inference import Engine3d >>> from dacapo.blockwise.empanada_function import stack_inference >>> model_config = "MitoNet_v1" >>> use_gpu = True >>> use_quantized = False >>> engine = Engine3d(model_config, use_gpu=use_gpu, use_quantized=use_quantized) >>> volume = np.random.rand(64, 64, 64) >>> axis_name = "xy" >>> stack, axis_name, trackers_dict = stack_inference(engine, volume, axis_name)
Note
The axis_name parameter should be one of the following:
- dacapo.blockwise.empanada_function.orthoplane_inference(engine, volume)
Perform inference on the orthogonal planes of a 3D volume.
- Parameters:
engine (Engine3d) – The engine object.
volume (np.ndarray) – The 3D volume to segment.
- Returns:
The trackers dictionary.
- Return type:
dict
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> import numpy as np >>> from empanada_napari.inference import Engine3d >>> from dacapo.blockwise.empanada_function import orthoplane_inference >>> model_config = "MitoNet_v1" >>> use_gpu = True >>> use_quantized = False >>> engine = Engine3d(model_config, use_gpu=use_gpu, use_quantized=use_quantized) >>> volume = np.random.rand(64, 64, 64) >>> trackers_dict = orthoplane_inference(engine, volume)
Note
The model_config parameter should be one of the following: - MitoNet_v1 - MitoNet_v2 - MitoNet_v3 - MitoNet_v4 - MitoNet_v5 - MitoNet_v6
- dacapo.blockwise.empanada_function.empanada_segmenter(image, model_config='MitoNet_v1', use_gpu=True, use_quantized=False, multigpu=False, downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=21, fine_boundaries=True, semantic_only=False, median_slices=11, min_size=10000, min_extent=50, maximum_objects_per_class=1000000, inference_plane='xy', orthoplane=True, return_panoptic=False, pixel_vote_thr=1, allow_one_view=False)
Segment a 3D volume using the empanada-napari library.
- Parameters:
image (np.ndarray) – The 3D volume to segment.
model_config (str) – The model configuration to use.
use_gpu (bool) – Whether to use the GPU.
use_quantized (bool) – Whether to use quantized inference.
multigpu (bool) – Whether to use multiple GPUs.
downsampling (int) – The downsampling factor.
confidence_thr (float) – The confidence threshold.
center_confidence_thr (float) – The center confidence threshold.
min_distance_object_centers (int) – The minimum distance between object centers.
fine_boundaries (bool) – Whether to use fine boundaries.
semantic_only (bool) – Whether to use semantic segmentation only.
median_slices (int) – The number of median slices.
min_size (int) – The minimum size of objects.
min_extent (int) – The minimum extent.
maximum_objects_per_class (int) – The maximum number of objects per class.
inference_plane (str) – The inference plane.
orthoplane (bool) – Whether to use orthoplane inference.
return_panoptic (bool) – Whether to return the panoptic segmentation.
pixel_vote_thr (int) – The pixel vote threshold.
allow_one_view (bool) – Whether to allow one view.
- Returns:
The volume, class name, and tracker.
- Return type:
tuple
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> import numpy as np >>> from empanada_napari.inference import Engine3d >>> from dacapo.blockwise.empanada_function import empanada_segmenter >>> image = np.random.rand(64, 64, 64) >>> model_config = "MitoNet_v1" >>> use_gpu = True >>> use_quantized = False >>> multigpu = False >>> downsampling = 1 >>> confidence_thr = 0.5 >>> center_confidence_thr = 0.1 >>> min_distance_object_centers = 21 >>> fine_boundaries = True >>> semantic_only = False >>> median_slices = 11 >>> min_size = 10000 >>> min_extent = 50 >>> maximum_objects_per_class = 1000000 >>> inference_plane = "xy" >>> orthoplane = True >>> return_panoptic = False >>> pixel_vote_thr = 1 >>> allow_one_view = False >>> for vol, class_name, tracker in empanada_segmenter( ... image, ... model_config=model_config, ... use_gpu=use_gpu, ... use_quantized=use_quantized, ... multigpu=multigpu, ... downsampling=downsampling, ... confidence_thr=confidence_thr, ... center_confidence_thr=center_confidence_thr, ... min_distance_object_centers=min_distance_object_centers, ... fine_boundaries=fine_boundaries, ... semantic_only=semantic_only, ... median_slices=median_slices, ... min_size=min_size, ... min_extent=min_extent, ... maximum_objects_per_class=maximum_objects_per_class, ... inference_plane=inference_plane, ... orthoplane=orthoplane, ... return_panoptic=return_panoptic, ... pixel_vote_thr=pixel_vote_thr, ... allow_one_view=allow_one_view ... ): ... print(vol.shape, class_name, tracker)
Note
The model_config parameter should be one of the following: - MitoNet_v1 - MitoNet_v2 - MitoNet_v3 - MitoNet_v4 - MitoNet_v5 - MitoNet_v6
- Reference:
doi: 10.1016/j.cels.2022.12.006
- dacapo.blockwise.empanada_function.stack_postprocessing(trackers, model_config, label_divisor=1000, min_size=200, min_extent=4, dtype=np.uint32)
Relabels and filters each class defined in trackers. Yields a numpy or zarr volume along with the name of the class that is segmented.
- Parameters:
trackers (dict) – The trackers dictionary.
model_config (str) – The model configuration to use.
label_divisor (int) – The label divisor.
min_size (int) – The minimum size of objects.
min_extent (int) – The minimum extent of objects.
dtype (type) – The data type.
- Returns:
The generator object.
- Return type:
generator
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> for vol, class_name, tracker in stack_postprocessing(trackers, model_config): ... print(vol.shape, class_name, tracker)
Note
The model_config parameter should be one of the following: - MitoNet_v1 - MitoNet_v2 - MitoNet_v3 - MitoNet_v4 - MitoNet_v5 - MitoNet_v6
- Reference:
doi: 10.1016/j.cels.2022.12.006
- dacapo.blockwise.empanada_function.tracker_consensus(trackers, model_config, pixel_vote_thr=2, cluster_iou_thr=0.75, allow_one_view=False, min_size=200, min_extent=4, dtype=np.uint32)
Calculate the orthoplane consensus from trackers. Yields a numpy or zarr volume along with the name of the class that is segmented.
- Parameters:
trackers (dict) – The trackers dictionary.
model_config (str) – The model configuration to use.
pixel_vote_thr (int) – The pixel vote threshold.
cluster_iou_thr (float) – The cluster IoU threshold.
allow_one_view (bool) – Whether to allow one view.
min_size (int) – The minimum size of objects.
min_extent (int) – The minimum extent of objects.
dtype (type) – The data type.
- Returns:
The generator object.
- Return type:
generator
- Raises:
ImportError – If empanada-napari is not installed.
Examples
>>> for vol, class_name, tracker in tracker_consensus(trackers, model_config): ... print(vol.shape, class_name, tracker)
Note
The model_config parameter should be one of the following: - MitoNet_v1 - MitoNet_v2 - MitoNet_v3 - MitoNet_v4 - MitoNet_v5 - MitoNet_v6
- Reference:
doi: 10.1016/j.cels.2022.12.006