Skip to content

Commit

Permalink
Merge pull request #30 from angelolab/small_fix
Browse files Browse the repository at this point in the history
Fixed a small bug in the cell analyzer
  • Loading branch information
JLrumberger authored Nov 22, 2024
2 parents 115a17d + 049e6af commit 089f9a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/nimbus_inference/cell_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def create_composite_image(self, path_dict, add_boundaries=True):
if self.segmentation_naming_convention and add_boundaries:
fov_path = os.path.split(list(path_dict.values())[0])[0]
seg_path = self.segmentation_naming_convention(fov_path)
seg_img = io.imread(seg_path)
seg_img = np.squeeze(io.imread(seg_path))
seg_boundaries = find_boundaries(seg_img, mode='inner')
individual_cell_boundary = seg_boundaries.copy()
cell_mask = seg_img == self.cell_df[
Expand All @@ -166,7 +166,7 @@ def create_instance_image(self, path_dict, cell_id):
# add overlay of instances
fov_path = os.path.split(list(path_dict.values())[0])[0]
seg_path = self.segmentation_naming_convention(fov_path)
seg_img = io.imread(seg_path)
seg_img = np.squeeze(io.imread(seg_path))
seg_boundaries = find_boundaries(seg_img, mode='inner')
seg_img[seg_boundaries] = 0
seg_img_clipped = np.clip(seg_img, 0, 1) * 0.2
Expand Down
29 changes: 14 additions & 15 deletions templates/3_analyze_individual_cells.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,20 @@
"metadata": {},
"outputs": [],
"source": [
"off_diagonal_df = pd.DataFrame(\n",
" {\n",
" \"Cell ID\": [1, 2, 3, 4],\n",
" \"pixie_ct\": [\"Eosinophil\", \"Neutrophil\", \"Lymphocyte\", \"Monocyte\"],\n",
" \"nimbus_ct\": [\"Neutrophil\", \"Lymphocyte\", \"Monocyte\", \"Eosinophil\"],\n",
" \"fov\": [\"TMA32_R4C6\", \"TMA32_R4C6\", \"TMA32_R5C4\", \"TMA32_R5C4\"],\n",
" \"label\": [451, 123, 234, 345],\n",
" } \n",
")\n",
"base_dir = os.path.normpath(\"C:/Users/lorenz/Desktop/angelo_lab/data/SPAIN_TNBC_fov_subset\")\n",
"tiff_dir = os.path.join(base_dir, \"image_data\")\n",
"deepcell_output_dir = os.path.join(base_dir, \"segmentation\", \"deepcell_output\")\n",
"off_diagonal_df = pd.read_csv(\"E:/angelo_lab/data/DCIS/cell_tables/potchara_data.csv\")\n",
"base_dir = os.path.normpath(\"E:/angelo_lab/data/DCIS\")\n",
"tiff_dir = os.path.join(base_dir, \"20230317_DCIS\", \"image_data\")\n",
"deepcell_output_dir = os.path.join(base_dir, \"deepcell_output\")\n",
"segmentation_naming_convention = prep_naming_convention(deepcell_output_dir)\n",
"\n",
"off_diagonal_df"
"fov_paths = [os.path.join(tiff_dir, f) for f in os.listdir(tiff_dir) if os.path.isdir(os.path.join(tiff_dir, f))]\n",
"# test segmentation_naming_convention\n",
"if os.path.exists(segmentation_naming_convention(fov_paths[0])):\n",
" print(\"Segmentation data exists for fov 0 and naming convention is correct\")\n",
"else:\n",
" print(\"Segmentation data does not exist for fov 0 or naming convention is incorrect\")\n",
"\n",
"off_diagonal_df[\"Cell ID\"] = off_diagonal_df.index.values"
]
},
{
Expand All @@ -89,7 +88,7 @@
" output_dir=base_dir,\n",
" segmentation_naming_convention=segmentation_naming_convention,\n",
" img_width='600px',\n",
" context=200)\n",
" context=120)\n",
"viewer.display()"
]
}
Expand All @@ -110,7 +109,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 089f9a2

Please sign in to comment.