Skip to content

Commit

Permalink
Merge pull request #299 from clEsperanto/fix_typo_in_parameter_names
Browse files Browse the repository at this point in the history
fix typo in parameter names; backwards compatible
  • Loading branch information
haesleinhuepf authored Apr 14, 2023
2 parents 907808e + f6a0666 commit efb38e9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyclesperanto_prototype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
from ._tier10 import *
from ._tier11 import *

__version__ = "0.24.0"
__version__ = "0.24.1"
__common_alias__ = "cle"
26 changes: 19 additions & 7 deletions pyclesperanto_prototype/_tier3/_exclude_labels_on_edges.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from pyclesperanto_prototype._tier0 import execute
from pyclesperanto_prototype._tier0 import plugin_function
from pyclesperanto_prototype._tier0 import Image
Expand All @@ -9,7 +11,7 @@
import numpy as np

@plugin_function(categories=['label processing', 'in assistant'], priority=1, output_creator=create_labels_like)
def exclude_labels_on_edges(label_map_input : Image, label_map_destination : Image = None, exlude_in_x:bool = True, exlude_in_y:bool = True, exlude_in_z:bool = True) -> Image:
def exclude_labels_on_edges(label_map_input : Image, label_map_destination : Image = None, exclude_in_x:bool = True, exclude_in_y:bool = True, exclude_in_z:bool = True, exlude_in_x:bool = None, exlude_in_y:bool = None, exlude_in_z:bool = None) -> Image:
"""Removes all labels from a label map which touch the edges of the image
(in X, Y and Z if the image is 3D).
Expand All @@ -19,11 +21,11 @@ def exclude_labels_on_edges(label_map_input : Image, label_map_destination : Ima
----------
label_map_input : Image
label_map_destination : Image, optional
exlude_in_x : bool, optional
exclude_in_x : bool, optional
Exclude labels along min and max x (default is True)
exlude_in_y : bool, optional
exclude_in_y : bool, optional
Exclude labels along min and max y (default is True)
exlude_in_z : bool, optional
exclude_in_z : bool, optional
Exclude labels along min and max z (default is True)
Returns
Expand All @@ -39,6 +41,16 @@ def exclude_labels_on_edges(label_map_input : Image, label_map_destination : Ima
----------
.. [1] https://clij.github.io/clij2-docs/reference_excludeLabelsOnEdges
"""
if exlude_in_x is not None:
warnings.warn("exlude_in_x parameter of cle.exclude_labels_on_edges() is deprecated. Use exclude_in_x instead.")
exclude_in_x = exlude_in_x
if exlude_in_y is not None:
warnings.warn("exlude_in_y parameter of cle.exclude_labels_on_edges() is deprecated. Use exclude_in_y instead.")
exclude_in_y = exlude_in_y
if exlude_in_z is not None:
warnings.warn("exlude_in_z parameter of cle.exclude_labels_on_edges() is deprecated. Use exclude_in_z instead.")
exclude_in_z = exlude_in_z

num_labels = int(maximum_of_all_pixels(label_map_input))

label_indices = range(0, num_labels + 1)
Expand All @@ -62,15 +74,15 @@ def exclude_labels_on_edges(label_map_input : Image, label_map_destination : Ima
label_map_input.shape[1]
]

if (len(label_map_input.shape) == 3 and exlude_in_z):
if (len(label_map_input.shape) == 3 and exclude_in_z):
global_sizes = [1, dimensions[1], dimensions[2]]
execute(__file__, "../clij-opencl-kernels/kernels/exclude_labels_on_edges_3d_x.cl", "exclude_on_edges_z_3d", global_sizes, parameters)

if exlude_in_y:
if exclude_in_y:
global_sizes = [dimensions[0], 1 ,dimensions[2]]
execute(__file__, "../clij-opencl-kernels/kernels/exclude_labels_on_edges_3d_x.cl", "exclude_on_edges_y_3d", global_sizes, parameters)

if exlude_in_x:
if exclude_in_x:
global_sizes = [dimensions[0], dimensions[1], 1]
execute(__file__, "../clij-opencl-kernels/kernels/exclude_labels_on_edges_3d_x.cl", "exclude_on_edges_x_3d", global_sizes, parameters)

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyclesperanto_prototype
version = 0.24.0
version = 0.24.1
author = Robert Haase
author_email = robert.haase@tu-dresden.de
url = https://github.com/clEsperanto/pyclesperanto_prototype
Expand Down
4 changes: 2 additions & 2 deletions tests/test_exclude_labels_on_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_exclude_labels_on_edges_blobs_2():
binary = cle.threshold_otsu(blurred)
labeled = cle.connected_components_labeling_box(binary)

wo_edges = cle.exclude_labels_on_edges(labeled, exlude_in_y=False)
wo_edges = cle.exclude_labels_on_edges(labeled, exclude_in_y=False)

# The maxmium intensity in a label image corresponds to the number of objects
num_labels = cle.maximum_of_all_pixels(wo_edges)
Expand All @@ -167,7 +167,7 @@ def test_exclude_labels_on_edges_blobs_2():

assert num_labels == 52

wo_edges = cle.exclude_labels_on_edges(labeled, exlude_in_x=False)
wo_edges = cle.exclude_labels_on_edges(labeled, exclude_in_x=False)

# The maxmium intensity in a label image corresponds to the number of objects
num_labels = cle.maximum_of_all_pixels(wo_edges)
Expand Down

0 comments on commit efb38e9

Please sign in to comment.