{ "cells": [ { "cell_type": "markdown", "id": "ea3a34b3-c104-48bd-93b9-95d8145fe0d6", "metadata": {}, "source": [ "# switch\n", "The `switch` function allows you to visualize multiple channels and blending them in and out." ] }, { "cell_type": "code", "execution_count": 1, "id": "02a9e08a-62c9-4652-b23d-c7904e8664d9", "metadata": {}, "outputs": [], "source": [ "from skimage import data\n", "from skimage.filters import gaussian\n", "from skimage.measure import label\n", "import stackview" ] }, { "cell_type": "code", "execution_count": 2, "id": "1d419fa5-4366-4eac-8eea-6ea07400a29e", "metadata": {}, "outputs": [], "source": [ "nuclei = data.cells3d()[:,1]" ] }, { "cell_type": "code", "execution_count": 3, "id": "f028bacf-7175-4fe7-819e-7a161938f52c", "metadata": {}, "outputs": [], "source": [ "blurred = gaussian(nuclei, sigma=2)" ] }, { "cell_type": "code", "execution_count": 4, "id": "a8600160-8087-43c4-a3ff-4b70bd5b7adb", "metadata": {}, "outputs": [], "source": [ "binary = blurred > 0.15" ] }, { "cell_type": "code", "execution_count": 5, "id": "72b27208-bc44-4b54-b39e-15c325bbf0f1", "metadata": {}, "outputs": [], "source": [ "labels = label(binary)" ] }, { "cell_type": "code", "execution_count": 6, "id": "904c18e8-51ee-411c-991f-be88a4921def", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2ed116ce238d4eb88caf1435bcf861dc", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=256, width=256),)),)), HBox(children=(ToggleBu…" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stackview.switch([nuclei, blurred, binary, labels],\n", " toggleable=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "e4079648-6226-4fb9-afed-c18d1097a2bf", "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.16" } }, "nbformat": 4, "nbformat_minor": 5 }