diff --git a/demo/basics/test_max_position.ipynb b/demo/basics/test_max_position.ipynb new file mode 100644 index 00000000..3c139284 --- /dev/null +++ b/demo/basics/test_max_position.ipynb @@ -0,0 +1,384 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "870625e2-dcd1-4dc1-9e87-a6f9773238d7", + "metadata": {}, + "outputs": [], + "source": [ + "import scipy.ndimage as ndi\n", + "import numpy as np\n", + "import pyclesperanto_prototype as cle" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "a430434b-177c-41fa-b39b-7e5b37531df4", + "metadata": {}, + "outputs": [], + "source": [ + "array3d = np.random.rand(100, 100, 100)\n", + "array3d[11, 6, 0] = 1\n", + "array3d[10, 48, 0] = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c21e7352-28ff-4bd5-bdce-a62d0d363a8a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(10, 48, 0)\n", + "(10, 48, 0)\n" + ] + } + ], + "source": [ + "print(ndi.maximum_position(array3d))\n", + "print(cle.maximum_position(array3d))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "f577db23-9530-4a24-b3f3-463ec4bc84ba", + "metadata": {}, + "outputs": [], + "source": [ + "array2d = np.random.rand(100, 80)\n", + "array2d[89, 2] = 1\n", + "array2d[90, 40] = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "0ca92364-832f-412d-885c-3f4778c7203b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(89, 2)\n", + "(89, 2)\n" + ] + } + ], + "source": [ + "print(ndi.maximum_position(array2d))\n", + "print(cle.maximum_position(array2d))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "f68acd41-2ee1-4700-a4e2-be921eff31f2", + "metadata": {}, + "outputs": [], + "source": [ + "array1d = np.random.rand(100)\n", + "array1d[56] = 1\n", + "array1d[20] = 1" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "42e0a94f-497a-4efd-8fd3-0fa947c352ff", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(20,)\n", + "(20,)\n" + ] + } + ], + "source": [ + "print(ndi.maximum_position(array1d))\n", + "print(cle.maximum_position(array1d))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "baba9ca4-1c35-410b-86bc-ddb7650add1c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[30 50 20]\n", + "[1000 20 1]\n", + "[10, 20979]\n" + ] + } + ], + "source": [ + "array = np.random.randint(0, 10, (30, 50, 20))\n", + "array[20, 48, 19] = 10\n", + "\n", + "dims = np.array(np.asarray(array).shape)\n", + "# see numpy.unravel_index to understand this line.\n", + "dim_prod = np.cumprod([1] + list(dims[:0:-1]))[::-1]\n", + "\n", + "print(dims)\n", + "print(dim_prod)\n", + "positions = np.arange(array.size).reshape(array.shape)\n", + "\n", + "result = []\n", + "result += [array.max()]\n", + "result += [positions[array == array.max()][0]]\n", + "\n", + "print(result)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "87d554c1-a0d4-46c1-adbe-5603c21f8937", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(5, 8, 3)\n", + "[[[7 4 1]\n", + " [3 9 4]\n", + " [9 3 2]\n", + " [2 7 2]\n", + " [1 3 6]\n", + " [1 2 7]\n", + " [0 4 7]\n", + " [3 6 2]]\n", + "\n", + " [[4 9 2]\n", + " [1 4 8]\n", + " [9 7 3]\n", + " [2 9 4]\n", + " [3 3 6]\n", + " [7 3 8]\n", + " [1 3 7]\n", + " [5 9 0]]\n", + "\n", + " [[9 9 3]\n", + " [3 3 9]\n", + " [3 7 0]\n", + " [6 2 2]\n", + " [6 1 7]\n", + " [0 9 8]\n", + " [5 6 4]\n", + " [1 6 7]]\n", + "\n", + " [[5 5 5]\n", + " [7 0 0]\n", + " [3 0 5]\n", + " [5 4 6]\n", + " [8 6 9]\n", + " [1 1 8]\n", + " [7 2 7]\n", + " [1 2 1]]\n", + "\n", + " [[2 6 7]\n", + " [8 6 9]\n", + " [0 1 7]\n", + " [8 4 5]\n", + " [8 7 1]\n", + " [6 4 0]\n", + " [4 3 4]\n", + " [8 3 9]]]\n", + "[[7. 9. 9. 5. 7.]\n", + " [9. 8. 9. 7. 9.]\n", + " [9. 9. 7. 5. 7.]\n", + " [7. 9. 6. 6. 8.]\n", + " [6. 6. 7. 9. 8.]\n", + " [7. 8. 9. 8. 6.]\n", + " [7. 7. 6. 7. 4.]\n", + " [6. 9. 7. 2. 9.]]\n", + "[[9. 9. 7. 7. 7.]\n", + " [9. 9. 8. 8. 8.]\n", + " [9. 9. 9. 9. 9.]\n", + " [8. 6. 9. 9. 9.]\n", + " [8. 7. 9. 9. 9.]\n", + " [8. 7. 9. 9. 9.]\n", + " [8. 7. 9. 9. 9.]\n", + " [8. 7. 9. 9. 9.]]\n", + "[[9. 9. 7. 7. 7.]\n", + " [8. 9. 9. 9. 9.]\n", + " [9. 7. 7. 7. 7.]\n", + " [8. 9. 6. 6. 6.]\n", + " [8. 7. 9. 9. 9.]\n", + " [7. 9. 8. 8. 8.]\n", + " [7. 6. 7. 7. 7.]\n", + " [8. 9. 9. 9. 9.]]\n" + ] + } + ], + "source": [ + "array = np.random.randint(0, 10, (5, 8, 3))\n", + "dimensionality = array.shape\n", + "print(dimensionality)\n", + "print(array)\n", + "temp_max = cle.create([1, dimensionality[1], dimensionality[0]])\n", + "pos_x = cle.create([1, dimensionality[1], dimensionality[0]])\n", + "\n", + "temp_max = cle.maximum_x_projection(array)\n", + "cle.x_position_of_maximum_x_projection(array, pos_x)\n", + "print(temp_max)\n", + "\n", + "source = temp_max\n", + "pos_y = cle.create([1, 1, dimensionality[0]])\n", + "temp_max = cle.maximum_y_projection(array, temp_max)\n", + "cle.y_position_of_maximum_y_projection(array, pos_y)\n", + "print(temp_max)\n", + "\n", + "source = temp_max\n", + "pos_z = cle.create([1, 1, 1])\n", + "temp_max = cle.maximum_z_projection(array, temp_max)\n", + "cle.z_position_of_maximum_z_projection(array, pos_z)\n", + "print(temp_max)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "5bd99c52-a7a6-4dd9-abd3-4a5d4d5b28b1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[9 2 2 2 2 5 4 9]\n", + " [3 4 3 1 1 5 1 6]\n", + " [7 7 1 2 6 3 8 4]\n", + " [5 4 9 2 7 9 6 4]\n", + " [8 6 5 8 4 2 3 5]\n", + " [3 3 5 2 3 6 5 2]]\n", + "[[9.]\n", + " [6.]\n", + " [8.]\n", + " [9.]\n", + " [8.]\n", + " [6.]]\n", + "[[9.]\n", + " [6.]\n", + " [8.]\n", + " [9.]\n", + " [8.]\n", + " [6.]]\n" + ] + } + ], + "source": [ + "array = np.random.randint(0, 10, (6, 8))\n", + "dimensionality = array.shape\n", + "\n", + "print(array)\n", + "\n", + "temp_max = cle.create([dimensionality[0], 1])\n", + "pos_x = cle.create([dimensionality[0], 1])\n", + "\n", + "print(cle.maximum_x_projection(array))\n", + "cle.maximum_x_projection(array, temp_max)\n", + "print(temp_max)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "82ee9f36-c393-4ca7-8e0d-a2ea5b2aea0c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[7.]\n", + " [9.]\n", + " [6.]\n", + " [9.]\n", + " [9.]\n", + " [9.]]\n", + "[[9.]]\n" + ] + } + ], + "source": [ + "array = np.random.randint(0, 10, (6, 8))\n", + "max_ = cle.maximum_x_projection(array)\n", + "print(max_)\n", + "\n", + "max_ = cle.maximum_y_projection(max_)\n", + "print(max_)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "9e240c69-181d-45ba-81c3-3b10f2336b13", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4 2 0\n" + ] + } + ], + "source": [ + "array3d = np.random.randint(0, 10, (6, 4, 3))\n", + "array3d[4, 2, 0] = 10\n", + "\n", + "temp = cle.maximum_x_projection(array3d)\n", + "x_pos = cle.x_position_of_maximum_x_projection(array3d)\n", + "source = temp\n", + "\n", + "temp = cle.maximum_y_projection(source)\n", + "y_pos = cle.y_position_of_maximum_y_projection(source)\n", + "source = temp\n", + "\n", + "z_pos = cle.x_position_of_maximum_x_projection(source)\n", + "\n", + "z_coord = int(z_pos[0][0])\n", + "y_coord = int(y_pos[0][z_coord])\n", + "x_coord = int(x_pos[y_coord][z_coord])\n", + "\n", + "print(z_coord, y_coord, x_coord)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.15" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/pyclesperanto_prototype/_tier2/__init__.py b/pyclesperanto_prototype/_tier2/__init__.py index e12bc360..52f7cb13 100644 --- a/pyclesperanto_prototype/_tier2/__init__.py +++ b/pyclesperanto_prototype/_tier2/__init__.py @@ -48,6 +48,10 @@ from ._top_hat_box import top_hat_box from ._top_hat_sphere import top_hat_sphere from ._touch_matrix_to_adjacency_matrix import touch_matrix_to_adjacency_matrix +from ._x_position_of_maximum_x_projection import x_position_of_maximum_x_projection +from ._x_position_of_maximum_x_projection import x_position_of_maximum_x_projection as arg_maximum_x_projection +from ._y_position_of_maximum_y_projection import y_position_of_maximum_y_projection +from ._y_position_of_maximum_y_projection import y_position_of_maximum_y_projection as arg_maximum_y_projection from ._z_position_of_maximum_z_projection import z_position_of_maximum_z_projection from ._z_position_of_maximum_z_projection import z_position_of_maximum_z_projection as arg_maximum_z_projection from ._z_position_of_minimum_z_projection import z_position_of_minimum_z_projection diff --git a/pyclesperanto_prototype/_tier2/_x_position_of_maximum_x_projection.py b/pyclesperanto_prototype/_tier2/_x_position_of_maximum_x_projection.py new file mode 100644 index 00000000..e86aac3b --- /dev/null +++ b/pyclesperanto_prototype/_tier2/_x_position_of_maximum_x_projection.py @@ -0,0 +1,31 @@ +from pyclesperanto_prototype._tier0 import plugin_function, Image, create_2d_yz, execute + +@plugin_function(output_creator = create_2d_yz, categories=['projection', 'in assistant']) +def x_position_of_maximum_x_projection(source : Image, destination : Image = None) -> Image: + """Determines an X-position of the maximum intensity along X and writes it into the resulting image. + + If there are multiple x-slices with the same value, the smallest X will be chosen. + + Parameters + ---------- + source : Image + Input image stack + destination : Image, optional + altitude map + + Returns + ------- + destination + + See Also + -------- + ..[1] https://clij.github.io/clij2-docs/reference_zPositionOfMaximumZProjection + """ + parameters = { + "dst_arg":destination, + "src":source, + } + + execute(__file__, 'x_position_of_maximum_x_projection_x.cl', 'x_position_of_maximum_x_projection', destination.shape, parameters) + + return destination diff --git a/pyclesperanto_prototype/_tier2/_y_position_of_maximum_y_projection.py b/pyclesperanto_prototype/_tier2/_y_position_of_maximum_y_projection.py new file mode 100644 index 00000000..70163c61 --- /dev/null +++ b/pyclesperanto_prototype/_tier2/_y_position_of_maximum_y_projection.py @@ -0,0 +1,31 @@ +from pyclesperanto_prototype._tier0 import plugin_function, Image, create_2d_zx, execute + +@plugin_function(output_creator = create_2d_zx, categories=['projection', 'in assistant']) +def y_position_of_maximum_y_projection(source : Image, destination : Image = None) -> Image: + """Determines an Y-position of the maximum intensity along Y and writes it into the resulting image. + + If there are multiple y-slices with the same value, the smallest Y will be chosen. + + Parameters + ---------- + source : Image + Input image stack + destination : Image, optional + altitude map + + Returns + ------- + destination + + See Also + -------- + ..[1] https://clij.github.io/clij2-docs/reference_zPositionOfMaximumZProjection + """ + parameters = { + "dst_arg":destination, + "src":source, + } + + execute(__file__, 'y_position_of_maximum_y_projection_x.cl', 'y_position_of_maximum_y_projection', destination.shape, parameters) + + return destination diff --git a/pyclesperanto_prototype/_tier2/x_position_of_maximum_x_projection_x.cl b/pyclesperanto_prototype/_tier2/x_position_of_maximum_x_projection_x.cl new file mode 100644 index 00000000..992a93cb --- /dev/null +++ b/pyclesperanto_prototype/_tier2/x_position_of_maximum_x_projection_x.cl @@ -0,0 +1,21 @@ + +__kernel void x_position_of_maximum_x_projection ( + IMAGE_dst_arg_TYPE dst_arg, + IMAGE_src_TYPE src +) { + const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; + + const int z = get_global_id(0); + const int y = get_global_id(1); + float max = 0; + int max_pos = 0; + for(int x = 0; x < GET_IMAGE_WIDTH(src); x++) + { + float value = READ_src_IMAGE(src,sampler,POS_src_INSTANCE(x,y,z,0)).x; + if (value > max || x == 0) { + max = value; + max_pos = x; + } + } + WRITE_dst_arg_IMAGE(dst_arg,POS_dst_arg_INSTANCE(z,y,0,0), CONVERT_dst_arg_PIXEL_TYPE(max_pos)); +} \ No newline at end of file diff --git a/pyclesperanto_prototype/_tier2/y_position_of_maximum_y_projection_x.cl b/pyclesperanto_prototype/_tier2/y_position_of_maximum_y_projection_x.cl new file mode 100644 index 00000000..45437e66 --- /dev/null +++ b/pyclesperanto_prototype/_tier2/y_position_of_maximum_y_projection_x.cl @@ -0,0 +1,21 @@ + +__kernel void y_position_of_maximum_y_projection ( + IMAGE_dst_arg_TYPE dst_arg, + IMAGE_src_TYPE src +) { + const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; + + const int x = get_global_id(0); + const int z = get_global_id(1); + float max = 0; + int max_pos = 0; + for(int y = 0; y < GET_IMAGE_HEIGHT(src); y++) + { + float value = READ_src_IMAGE(src,sampler,POS_src_INSTANCE(x,y,z,0)).x; + if (value > max || y == 0) { + max = value; + max_pos = y; + } + } + WRITE_dst_arg_IMAGE(dst_arg,POS_dst_arg_INSTANCE(x,z,0,0), CONVERT_dst_arg_PIXEL_TYPE(max_pos)); +} \ No newline at end of file diff --git a/pyclesperanto_prototype/_tier3/__init__.py b/pyclesperanto_prototype/_tier3/__init__.py index 19bd0bc3..767d7a63 100644 --- a/pyclesperanto_prototype/_tier3/__init__.py +++ b/pyclesperanto_prototype/_tier3/__init__.py @@ -28,6 +28,7 @@ from ._maximum_of_touching_neighbors_map import maximum_of_touching_neighbors_map from ._maximum_of_proximal_neighbors_map import maximum_of_proximal_neighbors_map from ._maximum_of_proximal_neighbors_map import maximum_of_proximal_neighbors_map as maximum_of_distal_neighbors_map +from ._maximum_position import maximum_position from ._mean_of_all_pixels import mean_of_all_pixels from ._mean_of_n_most_touching_neighbors_map import mean_of_n_most_touching_neighbors_map from ._mean_of_n_nearest_neighbors_map import mean_of_n_nearest_neighbors_map diff --git a/pyclesperanto_prototype/_tier3/_maximum_position.py b/pyclesperanto_prototype/_tier3/_maximum_position.py new file mode 100644 index 00000000..b109a457 --- /dev/null +++ b/pyclesperanto_prototype/_tier3/_maximum_position.py @@ -0,0 +1,67 @@ +from .._tier0 import create +from .._tier0 import pull +from .._tier0 import plugin_function +from .._tier0 import Image + + +@plugin_function +def maximum_position(source: Image) -> tuple: + """Determines the position of the maximum of all pixels in a given image. + + Parameters + ---------- + source : Image + The image of which the position of the maximum of all pixels or voxels will be determined. + + Returns + ------- + tuple + + Examples + -------- + >>> import pyclesperanto_prototype as cle + >>> cle.maximum_position(source) + """ + from .._tier1 import maximum_x_projection + from .._tier1 import maximum_y_projection + from .._tier1 import maximum_z_projection + from .._tier2 import x_position_of_maximum_x_projection + from .._tier2 import y_position_of_maximum_y_projection + from .._tier2 import z_position_of_maximum_z_projection + + # Find maximum projections and positions along each axis, reducing the dimensionality of the array + # To have the same properties as ndi.maximum_position, find projections in the order X -> Y -> Z + + dimensionality = source.shape + + z_coord, y_coord, x_coord = 0, 0, 0 + pos_z, pos_y, pos_x = None, None, None + max_position = [] + + temp_max = maximum_x_projection(source) + pos_x = x_position_of_maximum_x_projection(source) + source = temp_max + + if len(dimensionality) > 1: + temp_max = maximum_y_projection(source) + pos_y = y_position_of_maximum_y_projection(source) + source = temp_max + + if len(dimensionality) > 2: + # Use x position as the updated input array is 2d + pos_z = x_position_of_maximum_x_projection(source) + + # Use calculated max positions to find coordinates of each axis + if pos_z is not None: + z_coord = int(pos_z[0][0]) + max_position += [z_coord] + + if pos_y is not None: + y_coord = int(pos_y[0][z_coord]) + max_position += [y_coord] + + if pos_x is not None: + x_coord = int(pos_x[y_coord][z_coord]) + max_position += [x_coord] + + return tuple(max_position) diff --git a/tests/test_maximum_position.py b/tests/test_maximum_position.py new file mode 100644 index 00000000..1d132802 --- /dev/null +++ b/tests/test_maximum_position.py @@ -0,0 +1,61 @@ +import pyclesperanto_prototype as cle +import numpy as np +from scipy import ndimage + +def test_maximum_position_3d(): + np_input= np.asarray([ + [ + [1, 2, 3, 10], + [4, 16, 6, 11], + [7, 8, 9, 12] + ], + [ + [1, 2, 3, 13], + [4, 5, 6, 16], + [7, 8, 9, 15] + ] + ]) + + reference = ndimage.maximum_position(np_input) + gpu_input = cle.push(np_input) + result = cle.maximum_position(gpu_input) + + assert (result == reference) + +def test_maximum_position_3d_2(): + np_input = np.zeros((10,11,12)) + + np_input[1, 2, 3] = 1 + np_input[6, 7, 8] = 1 + + reference = ndimage.maximum_position(np_input) + gpu_input = cle.push(np_input) + result = cle.maximum_position(gpu_input) + + assert (result == reference) + +def test_maximum_position_2d(): + np_input= np.asarray([ + [1, 2, 3, 10], + [4, 16, 6, 11], + [7, 8, 9, 12] + ]) + + reference = ndimage.maximum_position(np_input) + gpu_input = cle.push(np_input) + result = cle.maximum_position(gpu_input) + + assert (result == reference) + + +def test_maximum_position_2d_2(): + np_input = np.zeros((10, 11)) + + np_input[1, 2] = 1 + np_input[6, 7] = 1 + + reference = ndimage.maximum_position(np_input) + gpu_input = cle.push(np_input) + result = cle.maximum_position(gpu_input) + + assert (result == reference) diff --git a/tests/test_x_position_of_maximum_x_projection.py b/tests/test_x_position_of_maximum_x_projection.py new file mode 100644 index 00000000..95d3d501 --- /dev/null +++ b/tests/test_x_position_of_maximum_x_projection.py @@ -0,0 +1,61 @@ +import pyclesperanto_prototype as cle +import numpy as np + +test1 = cle.push(np.asarray([ + [ + [1, 0, 0, 0, 9], + [0, 2, 0, 8, 0], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + ], [ + [0, 2, 0, 8, 0], + [1, 0, 0, 0, 9], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + ], [ + [0, 2, 0, 8, 0], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + [1, 0, 0, 0, 9], + ] +])) + +reference = cle.push(np.asarray([ + [4, 3, 3], + [3, 4, 4], + [4, 4, 3], + [3, 3, 4] +])) + +def test_x_position_of_maximum_x_projection(): + + result = cle.create(reference) + cle.x_position_of_maximum_x_projection(test1, result) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b)) + + +def test_x_position_of_maximum_x_projection_creator(): + result = cle.x_position_of_maximum_x_projection(test1) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b)) + +def test_x_position_of_maximum_x_projection_creator_passing_none(): + result = cle.x_position_of_maximum_x_projection(test1, None) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b)) diff --git a/tests/test_y_position_of_maximum_y_projection.py b/tests/test_y_position_of_maximum_y_projection.py new file mode 100644 index 00000000..a888bd9c --- /dev/null +++ b/tests/test_y_position_of_maximum_y_projection.py @@ -0,0 +1,60 @@ +import pyclesperanto_prototype as cle +import numpy as np + +test1 = cle.push(np.asarray([ + [ + [1, 0, 0, 0, 9], + [0, 2, 0, 8, 0], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + ], [ + [0, 2, 0, 8, 0], + [1, 0, 0, 0, 9], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + ], [ + [0, 2, 0, 8, 0], + [3, 0, 1, 0, 10], + [0, 4, 0, 7, 0], + [1, 0, 0, 0, 9], + ] +])) + +reference = cle.push(np.asarray([ + [2, 3, 2, 1, 2], + [2, 3, 2, 0, 2], + [1, 2, 1, 0, 1] +])) + +def test_y_position_of_maximum_y_projection(): + + result = cle.create(reference) + cle.y_position_of_maximum_y_projection(test1, result) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b)) + + +def test_y_position_of_maximum_y_projection_creator(): + result = cle.y_position_of_maximum_y_projection(test1) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b)) + +def test_y_position_of_maximum_y_projection_creator_passing_none(): + result = cle.y_position_of_maximum_y_projection(test1, None) + + a = cle.pull(result) + b = cle.pull(reference) + + print(a) + + assert (np.array_equal(a, b))