Detect cell boundaries based on ssDNA images¶
The following tutorial descibes a simple demo example for cell segmentation pipeline based on nuclei staining image. The core function was built on cellprofiler which you can refer to CellProfiler as a Python package
[ ]:
import sys
sys.path.append('../../')
[1]:
import cv2
%matplotlib inline
import matplotlib.pyplot as plt
we have include a demo image file for your testing, you can find with name ‘demo.tif’
[4]:
image = cv2.imread('../../../WACCA/cellsegmentation/demo.tif')
plt.imshow(image)
[4]:
<matplotlib.image.AxesImage at 0x14bb538e0>
import modules for image processing and cell object detection
[5]:
import objseg
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[5], line 1
----> 1 import objseg
ModuleNotFoundError: No module named 'objseg'
using clahe method to enhancing image with two iteration
[ ]:
image = objseg.clahe(image, iter=2, return_gray=True)
plt.imshow(image, cmap='binary_r')
<matplotlib.image.AxesImage at 0x2609f25f9a0>
In the enhanced image, cell nuclei in dark region were brighten to promote the detection of objects. Now starting the segmentation with cellprofiler.
[ ]:
image
[ ]:
x = image[:,:]
[ ]:
x
convert the image ndarray from rgb to gray
[ ]:
cell_mask, cell_boundary, img_boundary = objseg.pycellprofiler(
x, return_image=True,)
***Error: ConfigBase.Write(): argument 2 has unexpected type 'WindowsPath'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
d:\CodeSpace\4D-BioReconX\Preprocess\cellsegmentation\cell-segmente-on-ssDNA.ipynb Cell 15 line 1
----> <a href='vscode-notebook-cell:/d%3A/CodeSpace/4D-BioReconX/Preprocess/cellsegmentation/cell-segmente-on-ssDNA.ipynb#X22sZmlsZQ%3D%3D?line=0'>1</a> cell_mask, cell_boundary, img_boundary = objseg.pycellprofiler(
<a href='vscode-notebook-cell:/d%3A/CodeSpace/4D-BioReconX/Preprocess/cellsegmentation/cell-segmente-on-ssDNA.ipynb#X22sZmlsZQ%3D%3D?line=1'>2</a> x, return_image=True,)
TypeError: cannot unpack non-iterable NoneType object
[ ]:
image
[ ]:
plt.imshow(img_boundary)
except the returned numpy array of cell_mask and cell_boundary,
Reference: