Skip to content

Commit

Permalink
Merge bd5a7b4 into b563b6b
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-l-kong committed Nov 16, 2022
2 parents b563b6b + bd5a7b4 commit 291017f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 52 deletions.
40 changes: 19 additions & 21 deletions templates/2_Cluster_Pixels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
"outputs": [],
"source": [
"# select fovs to display\n",
"pixel_fovs = ['fov0', 'fov1']"
"subset_pixel_fovs = ['fov0', 'fov1']"
]
},
{
Expand All @@ -710,10 +710,9 @@
" img_sub_folder, io_utils.list_files(os.path.join(tiff_dir, fovs[0], img_sub_folder), substrs=['.tiff'])[0]\n",
" )\n",
"\n",
"# generate and save the pixel cluster masks for each fov in pixel_fovs\n",
"\n",
"# generate and save the pixel cluster masks for each fov in subset_pixel_fovs\n",
"data_utils.generate_and_save_pixel_cluster_masks(\n",
" fovs=pixel_fovs,\n",
" fovs=subset_pixel_fovs,\n",
" base_dir=base_dir,\n",
" save_dir=os.path.join(base_dir, pixel_output_dir),\n",
" tiff_dir=tiff_dir,\n",
Expand Down Expand Up @@ -793,23 +792,22 @@
}
],
"source": [
"subset_pixel_fovs = pixel_fovs\n",
"\n",
"pixel_cluster_masks = load_utils.load_imgs_from_dir(\n",
" data_dir = os.path.join(base_dir, pixel_output_dir, \"pixel_masks\"),\n",
" files=[f + \"_pixel_mask.tiff\" for f in subset_pixel_fovs],\n",
" trim_suffix=\"_pixel_mask\",\n",
" match_substring=\"_pixel_mask\",\n",
" xr_dim_name=\"pixel_mask\",\n",
" xr_channel_names=None,\n",
")\n",
"for pixel_fov in subset_pixel_fovs:\n",
" pixel_cluster_mask = load_utils.load_imgs_from_dir(\n",
" data_dir=os.path.join(base_dir, pixel_output_dir, \"pixel_masks\"),\n",
" files=[pixel_fov + \"_pixel_mask.tiff\"],\n",
" trim_suffix=\"_pixel_mask\",\n",
" match_substring=\"_pixel_mask\",\n",
" xr_dim_name=\"pixel_mask\",\n",
" xr_channel_names=None,\n",
" )\n",
"\n",
"plot_utils.plot_pixel_cell_cluster_overlay(\n",
" pixel_cluster_masks,\n",
" pixel_fovs,\n",
" os.path.join(base_dir, pixel_meta_cluster_remap_name),\n",
" metacluster_colors=raw_cmap\n",
")"
" plot_utils.plot_pixel_cell_cluster_overlay(\n",
" pixel_cluster_mask,\n",
" [pixel_fov],\n",
" os.path.join(base_dir, pixel_meta_cluster_remap_name),\n",
" metacluster_colors=raw_cmap\n",
" )"
]
},
{
Expand Down Expand Up @@ -882,7 +880,7 @@
"outputs": [],
"source": [
"plot_utils.create_mantis_dir(\n",
" fovs=pixel_fovs,\n",
" fovs=subset_pixel_fovs,\n",
" mantis_project_path=os.path.join(base_dir, pixel_output_dir, \"mantis\"),\n",
" img_data_path=tiff_dir,\n",
" mask_output_dir=os.path.join(base_dir, pixel_output_dir, \"pixel_masks\"),\n",
Expand Down
39 changes: 19 additions & 20 deletions templates/3_Cluster_Cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@
"outputs": [],
"source": [
"# select fovs to display\n",
"cell_fovs = ['fov0', 'fov1']"
"subset_cell_fovs = ['fov0', 'fov1']"
]
},
{
Expand All @@ -628,9 +628,9 @@
},
"outputs": [],
"source": [
"# generate and save the cell cluster masks for each fov in cell_fovs\n",
"# generate and save the cell cluster masks for each fov in subset_cell_fovs\n",
"data_utils.generate_and_save_cell_cluster_masks(\n",
" fovs=cell_fovs,\n",
" fovs=subset_cell_fovs,\n",
" base_dir=base_dir,\n",
" save_dir=os.path.join(base_dir, \"pixie\", cell_output_dir),\n",
" seg_dir=os.path.join(base_dir, segmentation_dir, \"deepcell_output\"),\n",
Expand Down Expand Up @@ -658,23 +658,22 @@
},
"outputs": [],
"source": [
"subset_cell_fovs = cell_fovs\n",
"for cell_fov in subset_cell_fovs:\n",
" cell_cluster_mask = load_utils.load_imgs_from_dir(\n",
" data_dir = os.path.join(base_dir, \"pixie\", cell_output_dir, \"cell_masks\"),\n",
" files=[cell_fov + \"_cell_mask.tiff\"],\n",
" trim_suffix=\"_cell_mask\",\n",
" match_substring=\"_cell_mask\",\n",
" xr_dim_name=\"cell_mask\",\n",
" xr_channel_names=None,\n",
" )\n",
"\n",
"cell_cluster_masks = load_utils.load_imgs_from_dir(\n",
" data_dir = os.path.join(base_dir, \"pixie\", cell_output_dir, \"cell_masks\"),\n",
" files=[f + \"_cell_mask.tiff\" for f in subset_cell_fovs],\n",
" trim_suffix=\"_cell_mask\",\n",
" match_substring=\"_cell_mask\",\n",
" xr_dim_name=\"cell_mask\",\n",
" xr_channel_names=None,\n",
")\n",
"\n",
"plot_utils.plot_pixel_cell_cluster_overlay(\n",
" cell_cluster_masks,\n",
" cell_fovs,\n",
" os.path.join(base_dir, cell_meta_cluster_remap_name),\n",
" metacluster_colors=raw_cmap\n",
")"
" plot_utils.plot_pixel_cell_cluster_overlay(\n",
" cell_cluster_mask,\n",
" [cell_fov],\n",
" os.path.join(base_dir, cell_meta_cluster_remap_name),\n",
" metacluster_colors=raw_cmap\n",
" )"
]
},
{
Expand Down Expand Up @@ -726,7 +725,7 @@
"outputs": [],
"source": [
"plot_utils.create_mantis_dir(\n",
" fovs=cell_fovs,\n",
" fovs=subset_cell_fovs,\n",
" mantis_project_path=os.path.join(base_dir, \"pixie\", cell_output_dir, \"mantis\"),\n",
" img_data_path=tiff_dir,\n",
" mask_output_dir=os.path.join(base_dir, \"pixie\", cell_output_dir, \"cell_masks\"),\n",
Expand Down
23 changes: 12 additions & 11 deletions templates/example_neighborhood_analysis_script.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@
"outputs": [],
"source": [
"# select fovs to display\n",
"fovs = ['fov6']\n",
"subset_neighborhood_fovs = ['fov6']\n",
"\n",
"# generate and save the neighborhood masks for the fovs to display\n",
"data_utils.generate_and_save_neighborhood_cluster_masks(\n",
" fovs,\n",
" subset_neighborhood_fovs,\n",
" overlay_out_dir,\n",
" all_data_cluster_labeled,\n",
" seg_output,\n",
Expand All @@ -487,16 +487,17 @@
],
"source": [
"# load the masks in and plot them\n",
"neighborhood_masks = load_utils.load_imgs_from_dir(\n",
" data_dir=overlay_out_dir,\n",
" files=[f + \"_neighborhood_mask.tiff\" for f in fovs],\n",
" trim_suffix=\"_neighborhood_mask\",\n",
" match_substring=\"_neighborhood_mask\",\n",
" xr_dim_name=\"neighborhood_mask\",\n",
" xr_channel_names=None,\n",
")\n",
"for fov in subset_neighborhood_fovs:\n",
" neighborhood_mask = load_utils.load_imgs_from_dir(\n",
" data_dir=overlay_out_dir,\n",
" files=[fov + \"_neighborhood_mask.tiff\"],\n",
" trim_suffix=\"_neighborhood_mask\",\n",
" match_substring=\"_neighborhood_mask\",\n",
" xr_dim_name=\"neighborhood_mask\",\n",
" xr_channel_names=None,\n",
" )\n",
"\n",
"plot_utils.plot_neighborhood_cluster_result(neighborhood_masks, fovs, k=k, save_dir=None)"
" plot_utils.plot_neighborhood_cluster_result(neighborhood_mask, [fov], k=k, save_dir=None)"
]
},
{
Expand Down

0 comments on commit 291017f

Please sign in to comment.