{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9fe071ae-a71d-4464-aeb3-11317319ddda", "metadata": {}, "outputs": [], "source": [ "import pyclesperanto_prototype as cle\n", "from napari_segment_blobs_and_things_with_membranes import local_minima_seeded_watershed\n", "from skimage.data import cells3d\n", "import stackview\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "id": "16f1e666-5a67-4194-85c3-e880aa7f6d9e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "cle._ image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeuint16
size128.0 kB
min277.0
max44092.0
\n", "\n", "
" ], "text/plain": [ "cl.OCLArray([[4496, 5212, 6863, ..., 2917, 2680, 2642],\n", " [4533, 5146, 7555, ..., 2843, 2857, 2748],\n", " [4640, 6082, 8452, ..., 3372, 3039, 3128],\n", " ...,\n", " [1339, 1403, 1359, ..., 4458, 4314, 4795],\n", " [1473, 1560, 1622, ..., 3967, 4531, 4204],\n", " [1380, 1368, 1649, ..., 3091, 3558, 3682]], dtype=uint16)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "image = cle.asarray(cells3d()[30, 0]).astype(np.uint16) \n", "\n", "image" ] }, { "cell_type": "code", "execution_count": 3, "id": "ad1af5ee-8d49-407e-a804-62238fb90e75", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "nsbatwm made image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeint32
size256.0 kB
min1
max35
\n", "\n", "
" ], "text/plain": [ "StackViewNDArray([[ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " ...,\n", " [32, 32, 32, ..., 35, 35, 35],\n", " [32, 32, 32, ..., 35, 35, 35],\n", " [32, 32, 32, ..., 35, 35, 35]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "labels = local_minima_seeded_watershed(image, spot_sigma=5)\n", "labels" ] }, { "cell_type": "code", "execution_count": 4, "id": "76e70e62-8bf2-48f4-ab3f-19c2e9207a57", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1f4ec0560da1412a85a5ec8b344c282f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=256, width=256),)),)), Label(value='[]:')))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "stackview.picker(labels)" ] }, { "cell_type": "code", "execution_count": 5, "id": "70769d97-628c-4aa0-b766-91346ad67677", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3171.804\n" ] } ], "source": [ "tmi = cle.generate_touch_mean_intensity_matrix(image, labels)\n", "print(tmi[13,15])" ] }, { "cell_type": "code", "execution_count": 6, "id": "a7b51db9-2b0e-482c-911e-c10735030bc4", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "cle._ image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeuint32
size256.0 kB
min1.0
max33.0
\n", "\n", "
" ], "text/plain": [ "cl.OCLArray([[ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " ...,\n", " [31, 31, 31, ..., 33, 33, 33],\n", " [31, 31, 31, ..., 33, 33, 33],\n", " [31, 31, 31, ..., 33, 33, 33]], dtype=uint32)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cle.merge_labels_with_border_intensity_within_range(image, labels, maximum_intensity=2000)" ] }, { "cell_type": "code", "execution_count": 7, "id": "6f49b9c8-c577-422e-a693-7c715055760d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "cle._ image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeuint32
size256.0 kB
min1.0
max32.0
\n", "\n", "
" ], "text/plain": [ "cl.OCLArray([[ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " ...,\n", " [30, 30, 30, ..., 32, 32, 32],\n", " [30, 30, 30, ..., 32, 32, 32],\n", " [30, 30, 30, ..., 32, 32, 32]], dtype=uint32)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cle.merge_labels_with_border_intensity_within_range(image, labels, maximum_intensity=3000)" ] }, { "cell_type": "code", "execution_count": 8, "id": "d1708789-72d3-40fa-a89b-1afd64f4b422", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "cle._ image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeuint32
size256.0 kB
min1.0
max21.0
\n", "\n", "
" ], "text/plain": [ "cl.OCLArray([[ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " [ 5, 5, 5, ..., 3, 3, 3],\n", " ...,\n", " [20, 20, 20, ..., 21, 21, 21],\n", " [20, 20, 20, ..., 21, 21, 21],\n", " [20, 20, 20, ..., 21, 21, 21]], dtype=uint32)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cle.merge_labels_with_border_intensity_within_range(image, labels, maximum_intensity=5000)" ] }, { "cell_type": "code", "execution_count": 9, "id": "f98e0001-0542-4848-973e-c3c9820d6c58", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "cle._ image
\n", "\n", "\n", "\n", "\n", "\n", "
shape(256, 256)
dtypeuint32
size256.0 kB
min1.0
max8.0
\n", "\n", "
" ], "text/plain": [ "cl.OCLArray([[7, 7, 7, ..., 3, 3, 3],\n", " [7, 7, 7, ..., 3, 3, 3],\n", " [7, 7, 7, ..., 3, 3, 3],\n", " ...,\n", " [8, 8, 8, ..., 8, 8, 8],\n", " [8, 8, 8, ..., 8, 8, 8],\n", " [8, 8, 8, ..., 8, 8, 8]], dtype=uint32)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cle.merge_labels_with_border_intensity_within_range(image, labels, maximum_intensity=8000)" ] }, { "cell_type": "code", "execution_count": null, "id": "b8b2384d-7c71-4c04-90c3-1ad108c12bec", "metadata": {}, "outputs": [], "source": [] } ], "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.13" } }, "nbformat": 4, "nbformat_minor": 5 }