Skip to content

Instantly share code, notes, and snippets.

@mrocklin
Last active August 4, 2019 17:02
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 mrocklin/2de0244ae306cab715fd20be7cec4322 to your computer and use it in GitHub Desktop.
Save mrocklin/2de0244ae306cab715fd20be7cec4322 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setup Dask Cluster\n",
"\n",
"ITK doesn't seem to release the GIL, so we use many single-threaded processes.\n",
"\n",
"- See [ITK issue #1134](https://github.com/InsightSoftwareConsortium/ITK/issues/1134)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table style=\"border: 2px solid white;\">\n",
"<tr>\n",
"<td style=\"vertical-align: top; border: 0px solid white\">\n",
"<h3 style=\"text-align: left;\">Client</h3>\n",
"<ul style=\"text-align: left; list-style: none; margin: 0; padding: 0;\">\n",
" <li><b>Scheduler: </b>tcp://127.0.0.1:45423</li>\n",
" <li><b>Dashboard: </b><a href='http://127.0.0.1:8787/status' target='_blank'>http://127.0.0.1:8787/status</a>\n",
"</ul>\n",
"</td>\n",
"<td style=\"vertical-align: top; border: 0px solid white\">\n",
"<h3 style=\"text-align: left;\">Cluster</h3>\n",
"<ul style=\"text-align: left; list-style:none; margin: 0; padding: 0;\">\n",
" <li><b>Workers: </b>20</li>\n",
" <li><b>Cores: </b>20</li>\n",
" <li><b>Memory: </b>1.08 TB</li>\n",
"</ul>\n",
"</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"<Client: scheduler='tcp://127.0.0.1:45423' processes=20 cores=20>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from dask.distributed import Client, LocalCluster\n",
"\n",
"cluster = LocalCluster(n_workers=20, threads_per_worker=1)\n",
"client = Client(cluster)\n",
"client"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load our data from last time"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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=\"519\" height=\"291\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"69\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"14\" x2=\"69\" y2=\"14\" />\n",
" <line x1=\"0\" y1=\"28\" x2=\"69\" y2=\"28\" />\n",
" <line x1=\"0\" y1=\"42\" x2=\"69\" y2=\"42\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"42\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"42\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"42\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"42\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"42\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"42\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"46\" y1=\"0\" x2=\"46\" y2=\"42\" />\n",
" <line x1=\"46\" y1=\"0\" x2=\"46\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"53\" y1=\"0\" x2=\"53\" y2=\"42\" />\n",
" <line x1=\"53\" y1=\"0\" x2=\"53\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"60\" y1=\"0\" x2=\"60\" y2=\"42\" />\n",
" <line x1=\"60\" y1=\"0\" x2=\"60\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"66\" y1=\"0\" x2=\"66\" y2=\"42\" />\n",
" <line x1=\"66\" y1=\"0\" x2=\"66\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.000000,0.000000 69.812645,0.000000 69.812645,42.354361 0.000000,42.354361\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"34.906322\" y=\"62.354361\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >199</text>\n",
" <text x=\"89.812645\" y=\"21.177180\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,89.812645,21.177180)\">3</text>\n",
"\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"180\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"139\" y1=\"200\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"139\" y2=\"200\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"41\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"139.000000,0.000000 180.108197,41.108197 180.108197,241.108197 139.000000,200.000000\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"289\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"41\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"180\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"289\" y1=\"0\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"139.000000,0.000000 289.000000,0.000000 330.108197,41.108197 180.108197,41.108197\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"180\" y1=\"41\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"241\" x2=\"330\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"180\" y1=\"41\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
" <line x1=\"330\" y1=\"41\" x2=\"330\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"180.108197,41.108197 330.108197,41.108197 330.108197,241.108197 180.108197,241.108197\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"255.108197\" y=\"261.108197\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >768</text>\n",
" <text x=\"350.108197\" y=\"141.108197\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,350.108197,141.108197)\">1024</text>\n",
" <text x=\"149.554098\" y=\"240.554098\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,149.554098,240.554098)\">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": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import dask.array as da\n",
"\n",
"imgs = da.from_zarr(\"/public/AOLLSMData_m4_raw.zarr/\", \"data\")\n",
"imgs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Load our Point Spread Function (PSF)"
]
},
{
"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> 2.48 MB </td> <td> 827.39 kB </td></tr>\n",
" <tr><th> Shape </th><td> (3, 1, 101, 64, 64) </td> <td> (1, 1, 101, 64, 64) </td></tr>\n",
" <tr><th> Count </th><td> 6 Tasks </td><td> 3 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=\"518\" height=\"294\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"42\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"17\" x2=\"42\" y2=\"17\" />\n",
" <line x1=\"0\" y1=\"34\" x2=\"42\" y2=\"34\" />\n",
" <line x1=\"0\" y1=\"52\" x2=\"42\" y2=\"52\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"52\" style=\"stroke-width:2\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"52\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.000000,0.000000 42.354361,0.000000 42.354361,52.218099 0.000000,52.218099\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"21.177180\" y=\"72.218099\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >1</text>\n",
" <text x=\"62.354361\" y=\"26.109050\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,62.354361,26.109050)\">3</text>\n",
"\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"112\" y1=\"0\" x2=\"229\" y2=\"117\" style=\"stroke-width:2\" />\n",
" <line x1=\"112\" y1=\"126\" x2=\"229\" y2=\"244\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"112\" y1=\"0\" x2=\"112\" y2=\"126\" style=\"stroke-width:2\" />\n",
" <line x1=\"229\" y1=\"117\" x2=\"229\" y2=\"244\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"112.000000,0.000000 229.647059,117.647059 229.647059,244.379732 112.000000,126.732673\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"112\" y1=\"0\" x2=\"238\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"229\" y1=\"117\" x2=\"356\" y2=\"117\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"112\" y1=\"0\" x2=\"229\" y2=\"117\" style=\"stroke-width:2\" />\n",
" <line x1=\"238\" y1=\"0\" x2=\"356\" y2=\"117\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"112.000000,0.000000 238.732673,0.000000 356.379732,117.647059 229.647059,117.647059\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"229\" y1=\"117\" x2=\"356\" y2=\"117\" style=\"stroke-width:2\" />\n",
" <line x1=\"229\" y1=\"244\" x2=\"356\" y2=\"244\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"229\" y1=\"117\" x2=\"229\" y2=\"244\" style=\"stroke-width:2\" />\n",
" <line x1=\"356\" y1=\"117\" x2=\"356\" y2=\"244\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"229.647059,117.647059 356.379732,117.647059 356.379732,244.379732 229.647059,244.379732\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"293.013395\" y=\"264.379732\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >64</text>\n",
" <text x=\"376.379732\" y=\"181.013395\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,376.379732,181.013395)\">64</text>\n",
" <text x=\"160.823529\" y=\"205.556203\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,160.823529,205.556203)\">101</text>\n",
"</svg>\n",
"</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"dask.array<getitem, shape=(3, 1, 101, 64, 64), dtype=uint16, chunksize=(1, 1, 101, 64, 64)>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import dask.array.image\n",
"\n",
"psf = dask.array.image.imread(\"/public/AOLLSMData/m4/psfs_z0p1/*.tif\")[:, None, ...]\n",
"psf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Convert data to float32 for computation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"imgs = imgs.astype(np.float32)\n",
"psf = psf.astype(np.float32)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Apply Richardson-Lucy Deconvolution"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"def richardson_lucy_deconvolution(img, psf, iterations=1):\n",
" \"\"\" Apply deconvolution to a single chunk of data \"\"\"\n",
" import itk\n",
" \n",
" img = img.squeeze() # remove leading two length-one dimensions\n",
" psf = psf.squeeze() # remove leading two length-one dimensions\n",
" \n",
" image = itk.image_view_from_array(img) # Convert to ITK object\n",
" kernel = itk.image_view_from_array(psf) # Convert to ITK object\n",
" \n",
" deconvolved = itk.richardson_lucy_deconvolution_image_filter(image,\n",
" kernel_image=kernel,\n",
" number_of_iterations=iterations)\n",
" \n",
" result = itk.array_from_image(deconvolved) # Convert back to Numpy array\n",
" result = result[None, None, ...] # Add back the leading length-one dimensions\n",
"\n",
" return result\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"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> 377.48 GB </td> <td> 632.29 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> 1801 Tasks </td><td> 597 Chunks </td></tr>\n",
" <tr><th> Type </th><td> float32 </td><td> numpy.ndarray </td></tr>\n",
" </tbody></table>\n",
"</td>\n",
"<td>\n",
"<svg width=\"519\" height=\"291\" style=\"stroke:rgb(0,0,0);stroke-width:1\" >\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"69\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"14\" x2=\"69\" y2=\"14\" />\n",
" <line x1=\"0\" y1=\"28\" x2=\"69\" y2=\"28\" />\n",
" <line x1=\"0\" y1=\"42\" x2=\"69\" y2=\"42\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" style=\"stroke-width:2\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" />\n",
" <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"1\" y1=\"0\" x2=\"1\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"2\" y1=\"0\" x2=\"2\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"3\" y1=\"0\" x2=\"3\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"4\" y1=\"0\" x2=\"4\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"5\" y1=\"0\" x2=\"5\" y2=\"42\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"42\" />\n",
" <line x1=\"6\" y1=\"0\" x2=\"6\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"7\" y1=\"0\" x2=\"7\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"8\" y1=\"0\" x2=\"8\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"9\" y1=\"0\" x2=\"9\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"10\" y1=\"0\" x2=\"10\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"11\" y1=\"0\" x2=\"11\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"12\" y1=\"0\" x2=\"12\" y2=\"42\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"42\" />\n",
" <line x1=\"13\" y1=\"0\" x2=\"13\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"14\" y1=\"0\" x2=\"14\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"15\" y1=\"0\" x2=\"15\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"16\" y1=\"0\" x2=\"16\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"17\" y1=\"0\" x2=\"17\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"18\" y1=\"0\" x2=\"18\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"19\" y1=\"0\" x2=\"19\" y2=\"42\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"42\" />\n",
" <line x1=\"20\" y1=\"0\" x2=\"20\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"21\" y1=\"0\" x2=\"21\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"22\" y1=\"0\" x2=\"22\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"23\" y1=\"0\" x2=\"23\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"24\" y1=\"0\" x2=\"24\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"25\" y1=\"0\" x2=\"25\" y2=\"42\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"42\" />\n",
" <line x1=\"26\" y1=\"0\" x2=\"26\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"27\" y1=\"0\" x2=\"27\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"28\" y1=\"0\" x2=\"28\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"29\" y1=\"0\" x2=\"29\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"30\" y1=\"0\" x2=\"30\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"31\" y1=\"0\" x2=\"31\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"32\" y1=\"0\" x2=\"32\" y2=\"42\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"42\" />\n",
" <line x1=\"33\" y1=\"0\" x2=\"33\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"34\" y1=\"0\" x2=\"34\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"35\" y1=\"0\" x2=\"35\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"36\" y1=\"0\" x2=\"36\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"37\" y1=\"0\" x2=\"37\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"38\" y1=\"0\" x2=\"38\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"39\" y1=\"0\" x2=\"39\" y2=\"42\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"42\" />\n",
" <line x1=\"40\" y1=\"0\" x2=\"40\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"41\" y1=\"0\" x2=\"41\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"42\" y1=\"0\" x2=\"42\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"43\" y1=\"0\" x2=\"43\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"44\" y1=\"0\" x2=\"44\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"45\" y1=\"0\" x2=\"45\" y2=\"42\" />\n",
" <line x1=\"46\" y1=\"0\" x2=\"46\" y2=\"42\" />\n",
" <line x1=\"46\" y1=\"0\" x2=\"46\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"47\" y1=\"0\" x2=\"47\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"48\" y1=\"0\" x2=\"48\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"49\" y1=\"0\" x2=\"49\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"51\" y1=\"0\" x2=\"51\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"52\" y1=\"0\" x2=\"52\" y2=\"42\" />\n",
" <line x1=\"53\" y1=\"0\" x2=\"53\" y2=\"42\" />\n",
" <line x1=\"53\" y1=\"0\" x2=\"53\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"54\" y1=\"0\" x2=\"54\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"55\" y1=\"0\" x2=\"55\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"56\" y1=\"0\" x2=\"56\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"57\" y1=\"0\" x2=\"57\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"58\" y1=\"0\" x2=\"58\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"59\" y1=\"0\" x2=\"59\" y2=\"42\" />\n",
" <line x1=\"60\" y1=\"0\" x2=\"60\" y2=\"42\" />\n",
" <line x1=\"60\" y1=\"0\" x2=\"60\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"61\" y1=\"0\" x2=\"61\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"62\" y1=\"0\" x2=\"62\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"63\" y1=\"0\" x2=\"63\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"64\" y1=\"0\" x2=\"64\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"65\" y1=\"0\" x2=\"65\" y2=\"42\" />\n",
" <line x1=\"66\" y1=\"0\" x2=\"66\" y2=\"42\" />\n",
" <line x1=\"66\" y1=\"0\" x2=\"66\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"67\" y1=\"0\" x2=\"67\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"68\" y1=\"0\" x2=\"68\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" />\n",
" <line x1=\"69\" y1=\"0\" x2=\"69\" y2=\"42\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"0.000000,0.000000 69.812645,0.000000 69.812645,42.354361 0.000000,42.354361\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"34.906322\" y=\"62.354361\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >199</text>\n",
" <text x=\"89.812645\" y=\"21.177180\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(0,89.812645,21.177180)\">3</text>\n",
"\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"180\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"139\" y1=\"200\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"139\" y2=\"200\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"41\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"139.000000,0.000000 180.108197,41.108197 180.108197,241.108197 139.000000,200.000000\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"289\" y2=\"0\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"41\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"139\" y1=\"0\" x2=\"180\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"289\" y1=\"0\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"139.000000,0.000000 289.000000,0.000000 330.108197,41.108197 180.108197,41.108197\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Horizontal lines -->\n",
" <line x1=\"180\" y1=\"41\" x2=\"330\" y2=\"41\" style=\"stroke-width:2\" />\n",
" <line x1=\"180\" y1=\"241\" x2=\"330\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Vertical lines -->\n",
" <line x1=\"180\" y1=\"41\" x2=\"180\" y2=\"241\" style=\"stroke-width:2\" />\n",
" <line x1=\"330\" y1=\"41\" x2=\"330\" y2=\"241\" style=\"stroke-width:2\" />\n",
"\n",
" <!-- Colored Rectangle -->\n",
" <polygon points=\"180.108197,41.108197 330.108197,41.108197 330.108197,241.108197 180.108197,241.108197\" style=\"fill:#ECB172A0;stroke-width:0\"/>\n",
"\n",
" <!-- Text -->\n",
" <text x=\"255.108197\" y=\"261.108197\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" >768</text>\n",
" <text x=\"350.108197\" y=\"141.108197\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(-90,350.108197,141.108197)\">1024</text>\n",
" <text x=\"149.554098\" y=\"240.554098\" font-size=\"1.0rem\" font-weight=\"100\" text-anchor=\"middle\" transform=\"rotate(45,149.554098,240.554098)\">201</text>\n",
"</svg>\n",
"</td>\n",
"</tr>\n",
"</table>"
],
"text/plain": [
"dask.array<richardson_lucy_deconvolution, shape=(3, 199, 201, 1024, 768), dtype=float32, chunksize=(1, 1, 201, 1024, 768)>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"out = da.map_blocks(richardson_lucy_deconvolution, imgs, psf, dtype=np.float32)\n",
"out"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Compute and write to disk"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"out.to_zarr(\"/raid/mrocklin/tmp.zarr\", \"deconvolved\", overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment