API pyClesperanto V.S. Prototype

This is a basic exploration of the API function in pyclesperanto and prototype. We have automatically listed the differences between the two package of pyclesperanto.

This is a crude comparison based on function name and localisation in the package. Indeed, some function may simply been renamed or moved to another tier. We encourage to rely on the search function to find specific operation, or to refere to the migration section of the documentation focussing on the main API modification between the two.

[71]:
import pyclesperanto as cle
import pyclesperanto_prototype as clep

print(f"pyclesperanto ({cle.__version__}) v.s. pyclespernato_prototype ({clep.__version__})")
pyclesperanto (0.10.3) v.s. pyclespernato_prototype (0.24.4)
[72]:
modules = ["_core", "_array", "_memory", "_functionalities", "_utils", "_operators", "_interoperability"]
core_cle = {func for module in modules for func in dir(getattr(cle, module, [])) if not func.startswith("_") and not func[0].isupper()}
core_clep = {func for func in dir(getattr(clep, "_tier0", []))  if not func.startswith("_") and not func[0].isupper()}

Core functions

In both pyclesperanto and prototype

[73]:
print("\n".join(core_cle.intersection(core_clep)))
push
create_like
operations
pull
execute
select_device
create
get_device

New in pyclesperanto

[74]:
print("\n".join(core_cle.difference(core_clep)))
empty_like
sort
path
select_backend
empty
wait_for_kernel_to_finish
remove
warnings
set
info
list_operations
from_array
get
to_device
pop
clear
count
np
index
list_available_devices
list_available_backends
imshow
native_execute
zeros_like
is_image
zeros
default_initialisation
insert
append
cl_buffer_datatype_dict
copy
extend
reverse

Only in pyclesperanto

[75]:
print("\n".join(core_clep.difference(core_cle)))
create_2d_yz
sigma_to_kernel_size
create_pointlist_from_labelmap
create_2d_xz
available_device_names
create_matrix_from_pointlists
create_2d_zx
push_zyx
asarray
search_operation_names
platform
create_vector_from_square_matrix
nparray
empty_image
create_square_matrix_from_labelmap
categories
create_from_pointlist
create_image
set_device_scoring_key
create_2d_xy
create_2d_yx
empty_image_like
operation
create_square_matrix_from_pointlist
create_zyx
cl_info
set_wait_for_kernel_finish
create_vector_from_labelmap
create_binary_like
pull_zyx
create_square_matrix_from_two_labelmaps
radius_to_kernel_size
plugin_function
create_none
create_labels_like
create_2d_zy

Tiers functions

[76]:
def compare_tiers(module1, module2, module1_name, module2_name, tier_number):
    tier_name = f"_tier{tier_number}"
    module1_tier_funcs = {func for func in dir(getattr(module1, tier_name, [])) if not func.startswith("_") and not func[0].isupper()}
    module2_tier_funcs = {func for func in dir(getattr(module2, tier_name, [])) if not func.startswith("_") and not func[0].isupper()}

    shared_in_both = module1_tier_funcs.intersection(module2_tier_funcs)
    missing_in_module1 = module2_tier_funcs.difference(module1_tier_funcs)
    missing_in_module2 = module1_tier_funcs.difference(module2_tier_funcs)

    if missing_in_module1 or missing_in_module2 or shared_in_both:
        print(f"\033[1mTier {tier_number} functions:\033[0m")
        if shared_in_both:
            print(f"\033[1m- Functions in both {module2_name} and {module1_name}:\033[0m")
            for func in sorted(shared_in_both):
                   print(f"\t- {func}")
            print()
        if missing_in_module2:
            print(f"\033[1m- Functions in {module1_name} not in {module2_name}:\033[0m")
            for func in sorted(missing_in_module2):
                   print(f"\t- {func}")
            print()
        if missing_in_module1:
            print(f"\033[1m- Functions in {module2_name} not in {module1_name}:\033[0m")
            for func in sorted(missing_in_module1):
                   print(f"\t- {func}")
            print()
        print()  # Add a newline for better separation

Tier 1

[77]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 1)
Tier 1 functions:
- Functions in both prototype and pyclesperanto:
        - absolute
        - add_image_and_scalar
        - add_images_weighted
        - binary_and
        - binary_edge_detection
        - binary_not
        - binary_or
        - binary_subtract
        - binary_xor
        - convolve
        - copy
        - copy_horizontal_slice
        - copy_slice
        - copy_vertical_slice
        - crop
        - cubic_root
        - detect_label_edges
        - dilate_box
        - dilate_sphere
        - divide_images
        - divide_scalar_by_image
        - equal
        - equal_constant
        - erode_box
        - erode_sphere
        - exponential
        - flip
        - gaussian_blur
        - generate_distance_matrix
        - gradient_x
        - gradient_y
        - gradient_z
        - greater
        - greater_constant
        - greater_or_equal
        - greater_or_equal_constant
        - hessian_eigenvalues
        - laplace_box
        - laplace_diamond
        - logarithm
        - mask
        - mask_label
        - maximum
        - maximum_box
        - maximum_image_and_scalar
        - maximum_images
        - maximum_sphere
        - maximum_x_projection
        - maximum_y_projection
        - maximum_z_projection
        - mean_box
        - mean_sphere
        - mean_x_projection
        - mean_y_projection
        - mean_z_projection
        - median_box
        - median_sphere
        - minimum
        - minimum_box
        - minimum_image_and_scalar
        - minimum_images
        - minimum_sphere
        - minimum_x_projection
        - minimum_y_projection
        - minimum_z_projection
        - mode_box
        - mode_sphere
        - modulo_images
        - multiply_image_and_scalar
        - multiply_images
        - multiply_matrix
        - nan_to_num
        - nonzero_maximum_box
        - nonzero_maximum_diamond
        - nonzero_minimum_box
        - nonzero_minimum_diamond
        - not_equal
        - not_equal_constant
        - onlyzero_overwrite_maximum_box
        - onlyzero_overwrite_maximum_diamond
        - paste
        - power
        - power_images
        - range
        - reciprocal
        - set
        - set_column
        - set_image_borders
        - set_nonzero_pixels_to_pixelindex
        - set_plane
        - set_ramp_x
        - set_ramp_y
        - set_ramp_z
        - set_row
        - set_where_x_equals_y
        - set_where_x_greater_than_y
        - set_where_x_smaller_than_y
        - sign
        - smaller
        - smaller_constant
        - smaller_or_equal
        - smaller_or_equal_constant
        - sobel
        - square_root
        - subtract_image_from_scalar
        - sum_x_projection
        - sum_y_projection
        - sum_z_projection
        - transpose_xy
        - transpose_xz
        - transpose_yz
        - undefined_to_zero
        - variance_box
        - variance_sphere
        - write_values_to_positions

- Functions in pyclesperanto not in prototype:
        - block_enumerate
        - dilate
        - erode
        - laplace
        - local_cross_correlation
        - mean
        - median
        - mode
        - multiply_image_and_position
        - nonzero_maximum
        - nonzero_minimum
        - np
        - onlyzero_overwrite_maximum
        - plugin_function
        - read_values_from_positions
        - replace_value
        - replace_values
        - std_z_projection
        - sum_reduction_x
        - variance
        - warnings
        - x_position_of_maximum_x_projection
        - x_position_of_minimum_x_projection
        - y_position_of_maximum_y_projection
        - y_position_of_minimum_y_projection
        - z_position_of_maximum_z_projection
        - z_position_of_minimum_z_projection

- Functions in prototype not in pyclesperanto:
        - average_distance_of_n_closest_points
        - average_distance_of_n_far_off_distances
        - average_distance_of_n_far_off_points
        - average_distance_of_n_nearest_distances
        - average_distance_of_n_shortest_distances
        - average_distance_of_touching_neighbors
        - binary_intersection
        - binary_union
        - cbrt
        - count_touching_neighbors
        - detect_maxima_box
        - detect_minima_box
        - dilate_box_slice_by_slice
        - dilate_sphere_slice_by_slice
        - downsample_slice_by_slice_half_median
        - downsample_xy_by_half_median
        - draw_box
        - draw_line
        - draw_sphere
        - erode_box_slice_by_slice
        - erode_sphere_slice_by_slice
        - execute_separable_kernel
        - exp
        - fabs
        - fill_diagonal
        - generate_angle_matrix
        - generate_binary_overlap_matrix
        - generate_touch_matrix
        - label_to_mask
        - log
        - logical_and
        - logical_not
        - logical_or
        - logical_xor
        - map_array
        - maximum_distance_of_n_closest_points
        - maximum_distance_of_n_shortest_distances
        - maximum_distance_of_touching_neighbors
        - minimum_distance_of_touching_neighbors
        - mod
        - multiply_image_and_coordinate
        - n_closest_points
        - point_index_list_to_mesh
        - point_index_list_to_touch_matrix
        - read_intensities_from_map
        - read_intensities_from_positions
        - remainder
        - replace_intensities
        - replace_intensity
        - resample
        - set_non_zero_pixels_to_pixel_index
        - sqrt
        - standard_deviation_z_projection
        - threshold
        - touch_matrix_to_mesh


Tier 2

[78]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 2)
Tier 2 functions:
- Functions in both prototype and pyclesperanto:
        - add_images
        - bottom_hat_box
        - bottom_hat_sphere
        - clip
        - closing_box
        - closing_sphere
        - crop_border
        - degrees_to_radians
        - invert
        - label_spots
        - large_hessian_eigenvalue
        - maximum_of_all_pixels
        - minimum_of_all_pixels
        - minimum_of_masked_pixels
        - opening_box
        - opening_sphere
        - radians_to_degrees
        - small_hessian_eigenvalue
        - square
        - standard_deviation_box
        - standard_deviation_sphere
        - subtract_images
        - sum_of_all_pixels
        - top_hat_box
        - top_hat_sphere

- Functions in pyclesperanto not in prototype:
        - absolute_difference
        - bottom_hat
        - closing
        - concatenate_along_x
        - concatenate_along_y
        - concatenate_along_z
        - count_touching_neighbors
        - detect_maxima
        - detect_maxima_box
        - detect_minima
        - detect_minima_box
        - difference_of_gaussian
        - divide_by_gaussian_background
        - extend_labeling_via_voronoi
        - np
        - opening
        - plugin_function
        - reduce_labels_to_label_edges
        - squared_difference
        - standard_deviation
        - subtract_gaussian_background
        - top_hat
        - warnings

- Functions in prototype not in pyclesperanto:
        - arg_maximum_x_projection
        - arg_maximum_y_projection
        - arg_maximum_z_projection
        - arg_minimum_x_projection
        - arg_minimum_y_projection
        - arg_minimum_z_projection
        - block_enumerate
        - combine_horizontally
        - combine_vertically
        - concatenate_stacks
        - distance_matrix_to_mesh
        - flag_existing_intensities
        - flag_existing_labels
        - gamma_correction
        - generate_maximum_intensity_between_points_matrix
        - generate_mean_intensity_between_points_matrix
        - generate_minimum_intensity_between_points_matrix
        - generate_should_touch_matrix
        - generate_standard_deviation_intensity_between_points_matrix
        - maximum_of_touching_neighbors
        - mean_of_touching_neighbors
        - median_of_touching_neighbors
        - minimum_of_touching_neighbors
        - mode_of_touching_neighbors
        - neighbors_of_neighbors
        - pointlist_to_labelled_spots
        - prefix_in_x
        - reduce_stack
        - standard_deviation_of_touching_neighbors
        - sub_stack
        - sum_reduction_x
        - symmetric_maximum_matrix
        - symmetric_mean_matrix
        - symmetric_minimum_matrix
        - symmetric_sum_matrix
        - touch_matrix_to_adjacency_matrix
        - x_position_of_maximum_x_projection
        - x_position_of_minimum_x_projection
        - y_position_of_maximum_y_projection
        - y_position_of_minimum_y_projection
        - z_position_of_maximum_z_projection
        - z_position_of_minimum_z_projection
        - z_position_projection


Tier 3

[79]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 3)
Tier 3 functions:
- Functions in both prototype and pyclesperanto:
        - bounding_box
        - center_of_mass
        - exclude_labels
        - exclude_labels_on_edges
        - histogram
        - jaccard_index
        - labelled_spots_to_pointlist
        - maximum_position
        - mean_of_all_pixels
        - minimum_position

- Functions in pyclesperanto not in prototype:
        - flag_existing_labels
        - gamma_correction
        - generate_binary_overlap_matrix
        - generate_touch_matrix
        - np
        - plugin_function
        - warnings

- Functions in prototype not in pyclesperanto:
        - absolute_difference
        - close_index_gaps_in_label_map
        - difference_of_gaussian
        - divide_by_gaussian_background
        - exclude_labels_out_of_size_range
        - exclude_labels_outside_size_range
        - exclude_labels_with_values_equal_to_constant
        - exclude_labels_with_values_not_equal_to_constant
        - exclude_labels_with_values_out_of_range
        - exclude_labels_with_values_within_range
        - generate_distal_neighbors_matrix
        - generate_n_nearest_neighbors_matrix
        - generate_proximal_neighbors_matrix
        - generate_touch_count_matrix
        - generate_touch_mean_intensity_matrix
        - maximum_of_distal_neighbors_map
        - maximum_of_n_most_touching_neighbors_map
        - maximum_of_n_nearest_neighbors_map
        - maximum_of_proximal_neighbors_map
        - maximum_of_touch_portion_within_range_neighbors_map
        - maximum_of_touching_neighbors_map
        - mean_of_distal_neighbors_map
        - mean_of_n_most_touching_neighbors_map
        - mean_of_n_nearest_neighbors_map
        - mean_of_proximal_neighbors_map
        - mean_of_touch_portion_within_range_neighbors_map
        - mean_of_touching_neighbors_map
        - minimum_of_distal_neighbors_map
        - minimum_of_n_most_touching_neighbors_map
        - minimum_of_n_nearest_neighbors_map
        - minimum_of_proximal_neighbors_map
        - minimum_of_touch_portion_within_range_neighbors_map
        - minimum_of_touching_neighbors_map
        - mode_of_distal_neighbors_map
        - mode_of_n_most_touching_neighbors_map
        - mode_of_n_nearest_neighbors_map
        - mode_of_proximal_neighbors_map
        - mode_of_touch_portion_within_range_neighbors_map
        - mode_of_touching_neighbors_map
        - proximal_other_labels_count
        - relabel_sequential
        - squared_difference
        - standard_deviation_of_distal_neighbors_map
        - standard_deviation_of_n_most_touching_neighbors_map
        - standard_deviation_of_n_nearest_neighbors_map
        - standard_deviation_of_proximal_neighbors_map
        - standard_deviation_of_touch_portion_within_range_neighbors_map
        - standard_deviation_of_touching_neighbors_map
        - stitch_horizontally_linear_blending
        - stitch_vertically_linear_blending
        - subtract_gaussian_background
        - z_position_range_projection


Tier 4

[80]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 4)
Tier 4 functions:
- Functions in both prototype and pyclesperanto:
        - mean_squared_error
        - spots_to_pointlist

- Functions in pyclesperanto not in prototype:
        - label_bounding_box
        - np
        - plugin_function
        - relabel_sequential
        - threshold_otsu
        - warnings

- Functions in prototype not in pyclesperanto:
        - combine_labels
        - connected_components_labeling_box
        - dilate_labels
        - erode_connected_labels
        - erode_labels
        - exclude_labels_with_average_values_out_of_range
        - exclude_labels_with_average_values_within_range
        - exclude_labels_with_map_values_equal_to_constant
        - exclude_labels_with_map_values_not_equal_to_constant
        - exclude_labels_with_map_values_out_of_range
        - exclude_labels_with_map_values_within_range
        - exclude_large_labels
        - exclude_small_labels
        - extend_labeling_via_voronoi
        - extend_labels_with_maximum_radius
        - extended_depth_of_focus_variance_projection
        - generate_n_most_touching_neighbors_matrix
        - generate_touch_portion_matrix
        - generate_touch_portion_within_range_neighbors_matrix
        - label
        - label_nonzero_pixel_count_map
        - label_nonzero_pixel_count_ratio_map
        - label_overlap_count_map
        - local_cross_correlation
        - local_maximum_touching_neighbor_count_map
        - local_mean_touching_neighbor_count_map
        - local_median_touching_neighbor_count_map
        - local_minimum_touching_neighbor_count_map
        - local_standard_deviation_touching_neighbor_count_map
        - merge_touching_labels
        - proximal_neighbor_count
        - proximal_neighbor_count_map
        - proximal_other_labels_count_map
        - sorensen_dice_coefficient
        - subtract_labels
        - touch_portion_within_range_neighbor_count
        - touch_portion_within_range_neighbor_count_map
        - touching_neighbor_count_map


Tier 5

[81]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 5)
Tier 5 functions:
- Functions in both prototype and pyclesperanto:
        - array_equal

- Functions in pyclesperanto not in prototype:
        - combine_labels
        - connected_components_labeling
        - np
        - plugin_function
        - warnings

- Functions in prototype not in pyclesperanto:
        - array_equiv
        - closing_labels
        - connected_components_labeling_diamond
        - fill_zeros_inpainting
        - generate_touch_mean_intensity_within_range_matrix
        - is_matrix_symmetric
        - masked_voronoi_labeling
        - merge_labels_according_to_touch_matrix
        - opening_labels
        - voronoi_labeling


Tier 6

[82]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 6)
Tier 6 functions:
- Functions in pyclesperanto not in prototype:
        - dilate_labels
        - erode_labels
        - gauss_otsu_labeling
        - masked_voronoi_labeling
        - np
        - plugin_function
        - voronoi_labeling
        - warnings

- Functions in prototype not in pyclesperanto:
        - merge_annotated_touching_labels
        - merge_labels_with_border_intensity_within_range
        - smooth_labels


Tier 7

[83]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 7)
Tier 7 functions:
- Functions in pyclesperanto not in prototype:
        - affine_transform
        - closing_labels
        - erode_connected_labels
        - eroded_otsu_labeling
        - np
        - opening_labels
        - plugin_function
        - rigid_transform
        - rotate
        - scale
        - translate
        - voronoi_otsu_labeling
        - warnings

- Functions in prototype not in pyclesperanto:
        - append
        - clear
        - copy
        - count
        - extend
        - index
        - insert
        - pop
        - remove
        - reverse
        - sort


Tier 8

[84]:
compare_tiers(cle, clep, "pyclesperanto", "prototype", 8)
Tier 8 functions:
- Functions in pyclesperanto not in prototype:
        - np
        - plugin_function
        - smooth_connected_labels
        - smooth_labels
        - warnings

- Functions in prototype not in pyclesperanto:
        - affine_transform
        - apply_vector_field
        - deskew_x
        - deskew_y
        - rigid_transform
        - rotate
        - scale
        - translate