diff --git a/docs/demo.ipynb b/docs/demo.ipynb
index 4e3d9d7..0b2513b 100644
--- a/docs/demo.ipynb
+++ b/docs/demo.ipynb
@@ -25,12 +25,32 @@
{
"cell_type": "code",
"execution_count": 1,
- "id": "ca154076",
+ "id": "774acd58-1c4a-4673-bd81-50d9ff53f55b",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'0.7.0'"
+ ]
+ },
+ "execution_count": 1,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"import stackview\n",
- "\n",
+ "stackview.__version__"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "49a9caad-0ce0-4a91-ad44-2cd06c3ad111",
+ "metadata": {},
+ "outputs": [],
+ "source": [
"import numpy as np\n",
"from skimage.io import imread\n",
"from skimage.filters import gaussian"
@@ -38,7 +58,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"id": "21067204",
"metadata": {},
"outputs": [],
@@ -57,7 +77,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 4,
"id": "4cf3f9d3",
"metadata": {
"tags": []
@@ -66,7 +86,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9cada5d6698a4223881f352d59533350",
+ "model_id": "f0d81e4f4f864f05807ae7bbc9c05472",
"version_major": 2,
"version_minor": 0
},
@@ -74,7 +94,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlider(value=60, des…"
]
},
- "execution_count": 3,
+ "execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -94,7 +114,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 5,
"id": "be919845-f8fc-4dd6-8b0b-6e729c9d0fc2",
"metadata": {},
"outputs": [
@@ -104,7 +124,7 @@
"
\n",
"\n",
"\n",
- "\n",
+ "\n",
" | \n",
"\n",
"\n",
@@ -114,7 +134,7 @@
" |
size | 5.9 MB |
\n",
"min | 0 |
max | 65535 |
\n",
"
\n",
- "\n",
+ "\n",
"\n",
"\n",
""
@@ -172,7 +192,7 @@
" dtype=uint16)"
]
},
- "execution_count": 4,
+ "execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -192,14 +212,14 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 6,
"id": "5c731a2b-c875-497c-a5c0-4e76e1f3e706",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6abd304a93794998bb0a521a37495b46",
+ "model_id": "ac30494fde414703b67af76b27fa2891",
"version_major": 2,
"version_minor": 0
},
@@ -207,7 +227,7 @@
"VBox(children=(HBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), VBox(chi…"
]
},
- "execution_count": 5,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -230,14 +250,14 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"id": "64731189",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "ded51bc2b13247cc8406ae1a7461c032",
+ "model_id": "2053d3f20a114645acc26d3b175320f0",
"version_major": 2,
"version_minor": 0
},
@@ -245,7 +265,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlider(value=60, des…"
]
},
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -265,14 +285,14 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"id": "42dd2614",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "a75a51586a3f4fd18d8a2eea0f1fcfd0",
+ "model_id": "6c83476107514a2ba2e7cd895323e111",
"version_major": 2,
"version_minor": 0
},
@@ -280,7 +300,7 @@
"HBox(children=(VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlide…"
]
},
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -300,7 +320,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"id": "d4ee961e",
"metadata": {},
"outputs": [],
@@ -310,14 +330,14 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"id": "ab1dc868",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "1c41738be4204c3bbe0a37434bd555fc",
+ "model_id": "7b46916c3a084e92954df3c96b8bc0df",
"version_major": 2,
"version_minor": 0
},
@@ -325,7 +345,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlider(value=60, des…"
]
},
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -344,7 +364,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 11,
"id": "e421b46f-f738-4048-9a77-09dc54070715",
"metadata": {},
"outputs": [],
@@ -354,14 +374,14 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 12,
"id": "24f8a418-b261-4a6e-97de-025046326a13",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "7c195a39d3bd410e946224341ae894af",
+ "model_id": "abc6f38cfea84b5eb3add1807b97a373",
"version_major": 2,
"version_minor": 0
},
@@ -369,7 +389,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlider(value=60, des…"
]
},
- "execution_count": 11,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -388,14 +408,14 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 13,
"id": "91a89968-9f2c-48bb-abfa-d6e123dcf51d",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "d5cf6db677624dde99c005b14c4ffe5a",
+ "model_id": "4bc2e84eab154d1fab39ac8fb124b843",
"version_major": 2,
"version_minor": 0
},
@@ -403,7 +423,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=160, width=160),)),)), IntSlider(value=60, des…"
]
},
- "execution_count": 12,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -422,7 +442,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 14,
"id": "2f21ee1d",
"metadata": {},
"outputs": [],
@@ -432,7 +452,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 15,
"id": "bd7d1317",
"metadata": {},
"outputs": [],
@@ -443,7 +463,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 16,
"id": "652721ec-6dfd-4518-9554-a3335ef27c6a",
"metadata": {},
"outputs": [
@@ -453,7 +473,7 @@
"((254, 256), (254, 256))"
]
},
- "execution_count": 15,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -464,14 +484,14 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 17,
"id": "6b5dd31a",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6b7c30c27dad4367833192734c33d6c6",
+ "model_id": "fe77be7b15f84a898babf9ed6492d835",
"version_major": 2,
"version_minor": 0
},
@@ -479,7 +499,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=254, width=256),)),)), IntSlider(value=127, de…"
]
},
- "execution_count": 16,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -498,7 +518,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 18,
"id": "f39bacd7-6ca3-4c28-bb4f-25d2251b0c9a",
"metadata": {},
"outputs": [],
@@ -509,14 +529,14 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 19,
"id": "1ad031f5-ab80-473c-95c5-12bd08256d56",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b0af9bd54fee4f4888ddfc7f5c5609da",
+ "model_id": "2485c5da744a4d0d9bc4c4a2ef4983fe",
"version_major": 2,
"version_minor": 0
},
@@ -524,7 +544,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=254, width=256),)),)), IntSlider(value=127, de…"
]
},
- "execution_count": 18,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -544,7 +564,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 20,
"id": "7bf91429",
"metadata": {},
"outputs": [],
@@ -554,14 +574,14 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 21,
"id": "5ad9ebf9",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "8b42f9383c774f82bb4c746d7a52b6cf",
+ "model_id": "1e7539cd3f37466ca23901dcd0ea8988",
"version_major": 2,
"version_minor": 0
},
@@ -569,7 +589,7 @@
"VBox(children=(HBox(children=(HBox(children=(VBox(children=(ImageWidget(height=235, width=389),)),)), HBox(chi…"
]
},
- "execution_count": 20,
+ "execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -580,7 +600,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 22,
"id": "97a16fec-21a0-4aa6-8dee-660ce345238e",
"metadata": {},
"outputs": [],
@@ -590,14 +610,14 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 23,
"id": "b948942f-b1c1-474f-a8cb-cf3f104b65bf",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "3261218ac4a94a23b3019bcae5a3ef54",
+ "model_id": "04616c876e274e258a029d76dfac5da1",
"version_major": 2,
"version_minor": 0
},
@@ -605,7 +625,7 @@
"VBox(children=(HBox(children=(HBox(children=(VBox(children=(ImageWidget(height=389, width=235),)),)), HBox(chi…"
]
},
- "execution_count": 22,
+ "execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
@@ -625,14 +645,14 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 24,
"id": "6a3c528a-164a-47f8-8f89-bb06961d035c",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "72ddeeadda4b4f9f82e61bc97d0dafb7",
+ "model_id": "05e353a7e0e0401b8075284435e56366",
"version_major": 2,
"version_minor": 0
},
@@ -640,7 +660,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=254, width=256),)),)), HBox(children=(Button(d…"
]
},
- "execution_count": 23,
+ "execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
@@ -655,14 +675,40 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 25,
+ "id": "c2300e4a-37cf-4c71-a59d-8b1e03bb6104",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "b493882ae0ec40eeb21a87e7cc1c5667",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=389, width=235),)),)), HBox(children=(Button(d…"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "stackview.switch([image_stack[1:], image_stack[:-1]])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
"id": "5eefda44-4c39-435f-aef7-1cc173c7d5ff",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "61bc1a81c45a4889980bf150b2d26c3f",
+ "model_id": "40ec1628df8345c195c2297dffa6508c",
"version_major": 2,
"version_minor": 0
},
@@ -670,7 +716,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=254, width=256),)),)), HBox(children=(Button(d…"
]
},
- "execution_count": 24,
+ "execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
@@ -685,14 +731,36 @@
},
{
"cell_type": "code",
- "execution_count": 25,
- "id": "852de202-ca56-46ee-a12a-0ac3163efb6d",
+ "execution_count": 27,
+ "id": "d44f586a-7a0d-44e9-aa15-60d3238a0c8d",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(512, 672, 3)"
+ ]
+ },
+ "execution_count": 27,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "hela_cells = imread(\"data/hela-cells.tif\")\n",
+ "hela_cells.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "id": "238118b8-7f3e-4580-87cb-cad4728f87c6",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "da38c4b0760546f3823ca255aafc6d34",
+ "model_id": "18d740cf32434d46b943e1806718cb6e",
"version_major": 2,
"version_minor": 0
},
@@ -700,14 +768,12 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=512, width=672),)),)), HBox(children=(ToggleBu…"
]
},
- "execution_count": 25,
+ "execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
- "hela_cells = imread(\"data/hela-cells.tif\")\n",
- "\n",
"stackview.switch(\n",
" {\"lysosomes\": hela_cells[:,:,0],\n",
" \"mitochondria\":hela_cells[:,:,1],\n",
@@ -729,14 +795,14 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 29,
"id": "078a817f-aded-4ca9-b754-e4e7e32407b3",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "6c0988d299704d0db2079d908060b3e9",
+ "model_id": "b100c9206ccd432ab89c620078fa6be2",
"version_major": 2,
"version_minor": 0
},
@@ -744,7 +810,7 @@
"_Cropper(children=(IntRangeSlider(value=(0, 100), description='Z'), IntRangeSlider(value=(0, 389), description…"
]
},
- "execution_count": 26,
+ "execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
@@ -764,7 +830,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 30,
"id": "088cfe7b-b09e-4bfa-a6ad-58aee2cb4697",
"metadata": {},
"outputs": [
@@ -774,7 +840,7 @@
"(slice(0, 100, 1), slice(0, 389, 1), slice(0, 235, 1))"
]
},
- "execution_count": 27,
+ "execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
@@ -793,7 +859,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 31,
"id": "5184f33f-f153-46f3-b799-e4e4945c02f0",
"metadata": {},
"outputs": [
@@ -803,7 +869,7 @@
"\n",
"\n",
"\n",
- "\n",
+ "\n",
" | \n",
"\n",
"\n",
@@ -813,7 +879,7 @@
" |
size | 8.7 MB |
\n",
"min | 0 |
max | 255 |
\n",
"
\n",
- "\n",
+ "\n",
"\n",
"\n",
""
@@ -870,7 +936,7 @@
" [155, 125, 115, ..., 76, 66, 82]]], dtype=uint8)"
]
},
- "execution_count": 28,
+ "execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
@@ -890,14 +956,14 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 32,
"id": "41b75598",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "1d19404fa9b04557849dcd9b15f91f44",
+ "model_id": "8ee331eace174394a0ee504dbc38c085",
"version_major": 2,
"version_minor": 0
},
@@ -905,7 +971,7 @@
"VBox(children=(interactive(children=(IntSlider(value=0, description='footprint'), Output()), _dom_classes=('wi…"
]
},
- "execution_count": 29,
+ "execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
@@ -917,14 +983,14 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": 33,
"id": "ba9bfc67",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "c19e39b2e047405689c97c6f8472594f",
+ "model_id": "71b8adaee445458b9a63e96e3c6b357b",
"version_major": 2,
"version_minor": 0
},
@@ -932,7 +998,7 @@
"VBox(children=(interactive(children=(FloatSlider(value=1.0, description='sigma', max=25.0, step=1.0), Output()…"
]
},
- "execution_count": 30,
+ "execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
@@ -952,14 +1018,14 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 34,
"id": "11f6e31e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "3cd4a90ac5184c089b1325781c505e8a",
+ "model_id": "ec4e14233d264754a0604db33dc178fd",
"version_major": 2,
"version_minor": 0
},
@@ -967,7 +1033,7 @@
"VBox(children=(interactive(children=(FloatSlider(value=1.0, description='sigma', max=25.0, step=1.0), Checkbox…"
]
},
- "execution_count": 31,
+ "execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@@ -998,7 +1064,7 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 35,
"id": "8abc8e06",
"metadata": {
"tags": []
@@ -1007,7 +1073,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "38915d03c6ed4aebb99d4928a258b521",
+ "model_id": "8f58a777e96c4bc494d8be849908afc5",
"version_major": 2,
"version_minor": 0
},
@@ -1015,7 +1081,7 @@
"VBox(children=(interactive(children=(FloatSlider(value=15.0, description='sigma'), Output()), _dom_classes=('w…"
]
},
- "execution_count": 32,
+ "execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
@@ -1037,14 +1103,14 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 36,
"id": "f2cfc7b6-c868-4e40-8e60-2f9cbde70b50",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "9e46c93348844f88bc97fa27e37339f0",
+ "model_id": "73e84c94539448e981d67fb5d42bc5f1",
"version_major": 2,
"version_minor": 0
},
@@ -1052,7 +1118,7 @@
"VBox(children=(Text(value='', description='Search', placeholder='Type here to search'), Dropdown(description='…"
]
},
- "execution_count": 33,
+ "execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
@@ -1071,7 +1137,7 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 37,
"id": "9cd2f2e5",
"metadata": {
"tags": []
@@ -1080,7 +1146,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "84f027c1c0ca4fa49fbffbaf0540d666",
+ "model_id": "e0b2860d749a4e93aa0fd5b7c543279b",
"version_major": 2,
"version_minor": 0
},
@@ -1088,7 +1154,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=100, width=100),)),)), IntSlider(value=50, des…"
]
},
- "execution_count": 34,
+ "execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
@@ -1104,14 +1170,14 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": 38,
"id": "c1c350b5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
- "model_id": "b841c00fdddb4a06802be8850d9311fc",
+ "model_id": "3d153abdc1bb45e6aea73410c7b590d5",
"version_major": 2,
"version_minor": 0
},
@@ -1119,7 +1185,7 @@
"VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=60, width=60),)),)), IntSlider(value=1, descri…"
]
},
- "execution_count": 35,
+ "execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
@@ -1157,7 +1223,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.9.15"
+ "version": "3.9.16"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
diff --git a/docs/images/biapol.png b/docs/images/biapol.png
new file mode 100644
index 0000000..60e8b16
Binary files /dev/null and b/docs/images/biapol.png differ
diff --git a/docs/rgb_images.ipynb b/docs/rgb_images.ipynb
new file mode 100644
index 0000000..a7c22b9
--- /dev/null
+++ b/docs/rgb_images.ipynb
@@ -0,0 +1,203 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "7e865722-e4ad-4c38-8d2f-12c65c79b0ec",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from skimage.io import imread\n",
+ "import stackview\n",
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "fe939c02-bfa5-4a76-9e31-8bb4b2f172f0",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(298, 298, 3)"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "image = imread(\"images/biapol.png\")\n",
+ "image.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "454ce886-c4eb-4b95-b7bf-ee64e3e02211",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "ce9130f7-2187-43fa-a4ab-e19638e8b32a",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ " | \n",
+ "\n",
+ "\n",
+ "\n",
+ "shape | (298, 298, 3) | \n",
+ "dtype | uint8 | \n",
+ "size | 260.2 kB | \n",
+ "min | 0 | max | 255 | \n",
+ " \n",
+ "\n",
+ " | \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ "StackViewNDArray([[[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]],\n",
+ "\n",
+ " [[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]],\n",
+ "\n",
+ " [[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]],\n",
+ "\n",
+ " ...,\n",
+ "\n",
+ " [[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]],\n",
+ "\n",
+ " [[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]],\n",
+ "\n",
+ " [[255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " ...,\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255],\n",
+ " [255, 255, 255]]], dtype=uint8)"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "stackview.insight(image)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "96a02f63-5a77-4cc2-9eff-f91468ec6f37",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(6, 298, 298, 3)"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list_images = np.asarray([image * 0.2, image * 0.4, image * 0.6, image * 0.8, image * 0.9, image])\n",
+ "list_images.shape"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "b5616bee-5d21-48a3-b783-5a196d7bd30d",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "application/vnd.jupyter.widget-view+json": {
+ "model_id": "779b8ad117b041a1b84a0da63108ce59",
+ "version_major": 2,
+ "version_minor": 0
+ },
+ "text/plain": [
+ "VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=298, width=298),)),)), IntSlider(value=3, desc…"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "stackview.slice(list_images)"
+ ]
+ }
+ ],
+ "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
+}
diff --git a/stackview/__init__.py b/stackview/__init__.py
index 2b717f1..6aadb3c 100644
--- a/stackview/__init__.py
+++ b/stackview/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "0.6.4"
+__version__ = "0.7.0"
from ._static_view import jupyter_displayable_output, insight
from ._utilities import merge_rgb
diff --git a/stackview/_image_widget.py b/stackview/_image_widget.py
index 9b368a5..ba99910 100644
--- a/stackview/_image_widget.py
+++ b/stackview/_image_widget.py
@@ -4,7 +4,7 @@
class ImageWidget(Canvas):
def __init__(self, image, zoom_factor:float=1.0, zoom_spline_order:int=0, colormap:str=None, display_min:float=None, display_max:float=None):
- if not ((len(image.shape) == 2) or (len(image.shape) == 3 and image.shape[-1] == 3)):
+ if not ((len(image.shape) == 2) or (len(image.shape) in [3, 4] and image.shape[-1] == 3)):
raise NotImplementedError("Only 2D images are supported" + str(image.shape))
height = image.shape[0] * zoom_factor
width = image.shape[1] * zoom_factor
@@ -43,7 +43,7 @@ def _update_image(self):
self.put_image_data(_img_to_rgb(zoomed, colormap=self.colormap, display_min=self.display_min, display_max=self.display_max), 0, 0)
def _zoom(self, data):
- if len(data.shape) == 3:
+ if len(data.shape) > 2 and data.shape[-1] == 3:
# handle RGB images
return np.asarray([self._zoom(data[:,:,i]) for i in range(data.shape[2])]).swapaxes(0, 2).swapaxes(1, 0)
@@ -72,7 +72,7 @@ def _img_to_rgb(image,
display_max=None):
from ._colormaps import _labels_lut, create_colormap
- if len(image.shape) == 3 and image.shape[2] == 3:
+ if len(image.shape) > 2 and image.shape[-1] == 3:
return image
if image.dtype == bool:
diff --git a/stackview/_slice_viewer.py b/stackview/_slice_viewer.py
index 20e196d..ab73574 100644
--- a/stackview/_slice_viewer.py
+++ b/stackview/_slice_viewer.py
@@ -23,7 +23,7 @@ def __init__(self,
if slice_number is None:
slice_number = int(image.shape[axis] / 2)
- if len(self.image.shape) == 3 and self.image.shape[-1] != 3:
+ if len(self.image.shape) > 2: # and self.image.shape[-1] != 3:
sliced_image = np.take(image, slice_number, axis=axis)
else:
sliced_image = image
@@ -49,6 +49,11 @@ def configuration_updated(event=None):
if len(self.image.shape) == 3 and self.image.shape[-1] != 3:
self.slice_slider.layout.display = None
self.view.data = np.take(self.image, self.slice_slider.value, axis=axis)
+ elif len(self.image.shape) == 4 and self.image.shape[-1] == 3:
+ self.slice_slider.layout.display = None
+ self.view.data = np.take(self.image, self.slice_slider.value, axis=axis)
+ elif len(self.image.shape) == 4:
+ raise NotImplementedError("Only 2D and 3D images are supported" + str(image.shape))
else:
self.view.data = self.image
self.slice_slider.layout.display = 'none'
diff --git a/stackview/_static_view.py b/stackview/_static_view.py
index b3decc7..aaaec01 100644
--- a/stackview/_static_view.py
+++ b/stackview/_static_view.py
@@ -199,6 +199,14 @@ def _imshow(image, title: str = None, labels: bool = False, min_display_intensit
"""
import numpy as np
+ if len(image.shape) == 3 and image.shape[2] == 3: # RGB image
+ import matplotlib.pyplot as plt
+ plt.imshow(image, vmin=min_display_intensity, vmax=max_display_intensity,
+ interpolation='nearest', alpha=alpha)
+ if not continue_drawing:
+ plt.show()
+ return
+
if len(image.shape) == 3:
image = np.asarray(image).max(axis=0)
diff --git a/stackview/_switch.py b/stackview/_switch.py
index 7822637..5a25515 100644
--- a/stackview/_switch.py
+++ b/stackview/_switch.py
@@ -90,11 +90,15 @@ def switch(images,
if toggleable:
def display_(buttons, images, colormap, display_min, display_max):
- display_image = np.zeros([images[0].shape[0], images[0].shape[1], 3])
+ display_image = np.zeros(list(images[0].shape) + [3])
for button, image, colormap_, display_min_, display_max_ in zip(buttons, images, colormap,
display_min, display_max):
if button.value:
- display_image_to_add = _img_to_rgb(image, display_min=display_min_, display_max=display_max_, colormap=colormap_)
+ if len(image.shape) == 3 and image.shape[-1] != 3:
+ display_image_to_add = np.asarray([_img_to_rgb(i, display_min=display_min_, display_max=display_max_, colormap=colormap_) for i in image])
+ else:
+ display_image_to_add = _img_to_rgb(image, display_min=display_min_, display_max=display_max_, colormap=colormap_)
+
if display_image is None:
display_image = display_image_to_add
else: