Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion nanshe_ipython.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"postfix_sub = \"_sub\"\n",
"postfix_f_f0 = \"_f_f0\"\n",
"postfix_wt = \"_wt\"\n",
"postfix_diff = \"_diff\"\n",
"postfix_norm = \"_norm\"\n",
"postfix_dict = \"_dict\"\n",
"postfix_post = \"_post\"\n",
Expand Down Expand Up @@ -989,6 +990,65 @@
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Difference\n",
"\n",
"* `block_space` (`int`): extent of each spatial dimension for each block (run in parallel).\n",
"* `norm_frames` (`int`): number of frames for use during normalization of each full frame block (run in parallel)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
"\n",
"\n",
"block_frames = 40\n",
"norm_frames = 100\n",
"\n",
"\n",
"with get_executor(client) as executor:\n",
" dask_io_remove(data_basename + postfix_diff + zarr_ext, executor)\n",
"\n",
"\n",
" with open_zarr(data_basename + postfix_wt + zarr_ext, \"r\") as f:\n",
" # Load and prep data for computation.\n",
" imgs = f[\"images\"]\n",
" da_imgs = da.from_array(\n",
" imgs, chunks=(block_frames,) + (imgs.ndim - 1) * (block_space,)\n",
" )\n",
"\n",
" da_imgs_flt = da_imgs\n",
" if not (issubclass(da_imgs_flt.dtype.type, np.floating) and \n",
" da_imgs_flt.dtype.itemsize >= 4):\n",
" da_imgs_flt = da_imgs_flt.astype(np.float32)\n",
"\n",
" da_result = da_imgs_flt[1:] - da_imgs_flt[:-1]\n",
"\n",
" # Store denoised data\n",
" dask_store_zarr(data_basename + postfix_diff + zarr_ext, [\"images\"], [da_result], executor)\n",
"\n",
"\n",
" zip_zarr(data_basename + postfix_diff + zarr_ext, executor)\n",
"\n",
"\n",
"if __IPYTHON__:\n",
" result_image_stack = LazyZarrDataset(data_basename + postfix_diff + zarr_ext, \"images\")\n",
"\n",
" mplsv = plt.figure(FigureClass=MPLViewer)\n",
" mplsv.set_images(\n",
" result_image_stack,\n",
" vmin=par_compute_min_projection(num_frames=norm_frames)(result_image_stack).min(),\n",
" vmax=par_compute_max_projection(num_frames=norm_frames)(result_image_stack).max()\n",
" )"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -1015,7 +1075,7 @@
" dask_io_remove(data_basename + postfix_norm + zarr_ext, executor)\n",
"\n",
"\n",
" with open_zarr(data_basename + postfix_wt + zarr_ext, \"r\") as f:\n",
" with open_zarr(data_basename + postfix_diff + zarr_ext, \"r\") as f:\n",
" # Load and prep data for computation.\n",
" imgs = f[\"images\"]\n",
" da_imgs = da.from_array(\n",
Expand Down