Skip to content

Instantly share code, notes, and snippets.

@thewtex
Last active August 2, 2019 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewtex/29a0b7681a107d28c969fe6d1b477f89 to your computer and use it in GitHub Desktop.
Save thewtex/29a0b7681a107d28c969fe6d1b477f89 to your computer and use it in GitHub Desktop.
Light sheet Richardson-Lucy deconvolution
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"import dask.array as da\n",
"import itk\n",
"import numpy as np\n",
"\n",
"from itkwidgets import view"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data_dir = '/home/kitware/data/LightSheet/m4/'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"image = da.from_zarr(os.path.join(data_dir, 'stacked.zarr'))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<tr>\n",
"<td>\n",
"<table> <thead> <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr><th> Bytes </th><td> 188.74 GB </td> <td> 316.15 MB </td></tr>\n",
" <tr><th> Shape </th><td> (3, 199, 201, 1024, 768) </td> <td> (1, 1, 201, 1024, 768) </td></tr>\n",
" <tr><th> Count </th><td> 598 Tasks </td><td> 597 Chunks </td></tr>\n",
" <tr><th> Type </th><td> uint16 </td><td> numpy.ndarray </td></tr>\n",
" </tbody></table>\n",
"</td>\n",
"<td>\n",
"<svg width=\"386\" height=\"194\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"41\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"8\" x2=\"41\" y2=\"8\" />\n",
" <line x1=\"0\" y1=\"16\" x2=\"41\" y2=\"16\" />\n",
" <line x1=\"0\" y1=\"25\" x2=\"41\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"25\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"25\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"25\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"25\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"25\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"25\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"25\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"25\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"25\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"25\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"25\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"25\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"25\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"25\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"25\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"25\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"25\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"25\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"25\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"25\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"25\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"25\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"25\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"25\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"25\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"25\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"25\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"25\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"25\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"25\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"25\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"25\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"25\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"25\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"25\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"25\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"25\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"25\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"25\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"25\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"25\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"25\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"25\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"25\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"25\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"25\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"25\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"25\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"25\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"25\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"25\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"25\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"25\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"25\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"25\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"25\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"25\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"25\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"25\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"25\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"25\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"25\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"25\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"25\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"25\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"25\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"25\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"25\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"25\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"25\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"25\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"25\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"25\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"25\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"25\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"25\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"25\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"25\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"25\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"25\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"25\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"25\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"25\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"25\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"25\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"25\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"25\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"25\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"25\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"25\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"25\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"25\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"25\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"25\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"25\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"25\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"25\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"25\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"25\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"25\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"25\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"25\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"25\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"25\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"25\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"25\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"25\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"25\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"25\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"25\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"25\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"25\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"25\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"25\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"25\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"25\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"25\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"25\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"25\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"25\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"25\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"25\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"25\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"25\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"25\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"25\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"25\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"25\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"25\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"25\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"25\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"25\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"25\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"25\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"25\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"25\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"25\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"25\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"25\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"25\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"25\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"25\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"25\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"25\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"25\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"25\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"25\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"25\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"25\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"25\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"25\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"25\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"25\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"25\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"25\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"25\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"25\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"25\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"25\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"25\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"25\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"25\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"25\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"25\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"25\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.000000,0.000000 41.887587,0.000000 41.887587,25.412617 0.000000,25.412617\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"20.943793\" y=\"45.412617\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >199</text>\n",
" <text x=\"61.887587\" y=\"12.706308\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,61.887587,12.706308)\">3</text>\n",
"\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"111\" y1=\"0\" x2=\"135\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"111\" y1=\"120\" x2=\"135\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"111\" y1=\"0\" x2=\"111\" y2=\"120\" style=\"stroke-width:2\" />\n",
" <line x1=\"135\" y1=\"24\" x2=\"135\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"111.000000,0.000000 135.664918,24.664918 135.664918,144.664918 111.000000,120.000000\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"111\" y1=\"0\" x2=\"201\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"135\" y1=\"24\" x2=\"225\" y2=\"24\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"111\" y1=\"0\" x2=\"135\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"201\" y1=\"0\" x2=\"225\" y2=\"24\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"111.000000,0.000000 201.000000,0.000000 225.664918,24.664918 135.664918,24.664918\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"135\" y1=\"24\" x2=\"225\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"135\" y1=\"144\" x2=\"225\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"135\" y1=\"24\" x2=\"135\" y2=\"144\" style=\"stroke-width:2\" />\n",
" <line x1=\"225\" y1=\"24\" x2=\"225\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"135.664918,24.664918 225.664918,24.664918 225.664918,144.664918 135.664918,144.664918\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"180.664918\" y=\"164.664918\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >768</text>\n",
" <text x=\"245.664918\" y=\"84.664918\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,245.664918,84.664918)\">1024</text>\n",
" <text x=\"113.332459\" y=\"152.332459\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,113.332459,152.332459)\">201</text>\n",
"</svg>\n",
"</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"dask.array<from-zarr, shape=(3, 199, 201, 1024, 768), dtype=uint16, chunksize=(1, 1, 201, 1024, 768)>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"image_chunk = image[0,0,...]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<tr>\n",
"<td>\n",
"<table> <thead> <tr><td> </td><th> Array </th><th> Chunk </th></tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr><th> Bytes </th><td> 316.15 MB </td> <td> 316.15 MB </td></tr>\n",
" <tr><th> Shape </th><td> (201, 1024, 768) </td> <td> (201, 1024, 768) </td></tr>\n",
" <tr><th> Count </th><td> 599 Tasks </td><td> 1 Chunks </td></tr>\n",
" <tr><th> Type </th><td> uint16 </td><td> numpy.ndarray </td></tr>\n",
" </tbody></table>\n",
"</td>\n",
"<td>\n",
"<svg width=\"174\" height=\"194\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"34\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"10\" y1=\"120\" x2=\"34\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"120\" style=\"stroke-width:2\" />\n",
" <line x1=\"34\" y1=\"24\" x2=\"34\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"10.000000,0.000000 34.664918,24.664918 34.664918,144.664918 10.000000,120.000000\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"100\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"34\" y1=\"24\" x2=\"124\" y2=\"24\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"10\" y1=\"0\" x2=\"34\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"100\" y1=\"0\" x2=\"124\" y2=\"24\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"10.000000,0.000000 100.000000,0.000000 124.664918,24.664918 34.664918,24.664918\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"34\" y1=\"24\" x2=\"124\" y2=\"24\" style=\"stroke-width:2\" />\n",
" <line x1=\"34\" y1=\"144\" x2=\"124\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"34\" y1=\"24\" x2=\"34\" y2=\"144\" style=\"stroke-width:2\" />\n",
" <line x1=\"124\" y1=\"24\" x2=\"124\" y2=\"144\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"34.664918,24.664918 124.664918,24.664918 124.664918,144.664918 34.664918,144.664918\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"79.664918\" y=\"164.664918\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >768</text>\n",
" <text x=\"144.664918\" y=\"84.664918\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,144.664918,84.664918)\">1024</text>\n",
" <text x=\"12.332459\" y=\"152.332459\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,12.332459,152.332459)\">201</text>\n",
"</svg>\n",
"</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"dask.array<getitem, shape=(201, 1024, 768), dtype=uint16, chunksize=(201, 1024, 768)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"image_chunk"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "874c779cf58e425ca4c7a481b8fd6bf8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageUS3; proxy …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(image_chunk)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Note: 488nm corresponds to the first channel of the image data\n",
"psf_file = os.path.join(data_dir, 'psfs_z0p1/PSF_488nm_dz100nm.tif')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e41b403c46464843b6fe3651059ee6c6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageUS3; proxy …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"psf = itk.array_from_image(itk.imread(psf_file))\n",
"view(psf, slicing_planes=True, shadow=False, ui_collapsed=True)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0d4a6745600f43cdb5dc6470f6b1bcb7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageUS3; proxy …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Trim the PSF for compute\n",
"psf_sub = psf[41:60,24:40,24:40]\n",
"view(psf_sub, slicing_planes=True, shadow=False, ui_collapsed=True)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def richardson_lucy_deconvolution(img, psf, iterations=1):\n",
" image = itk.image_view_from_array(np.ascontiguousarray(img))\n",
" kernel = itk.image_view_from_array(np.ascontiguousarray(psf))\n",
" \n",
" deconvolved = itk.richardson_lucy_deconvolution_image_filter(image,\n",
" kernel_image=kernel,\n",
" number_of_iterations=iterations)\n",
" return itk.array_from_image(deconvolved)\n",
"\n",
"deconvolved = richardson_lucy_deconvolution(image_chunk, psf_sub)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6c0b08f777704674a26a34d653d68874",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Viewer(geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<itkImagePython.itkImageF3; proxy o…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view(deconvolved)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment