haesleinhuepf / git-bob-playground

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[BioImage Analysis]: Cell segmentation - algorithm selection #78

Open haesleinhuepf opened 3 weeks ago

haesleinhuepf commented 3 weeks ago

What algorithms / Python packages would be suited for segmenting cells in this kind of microscopy image?

membranes

git-bob answer

github-actions[bot] commented 3 weeks ago

This message was generated by git-bob (version: 0.12.1dev, model: claude-3-5-sonnet-20241022, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

Hi! 👋

For segmenting cells in membrane-stained microscopy images like this, I recommend trying these approaches:

  1. Using scikit-image's watershed segmentation with markers from cell centers would work well here. Here's a quick example notebook:
import numpy as np
from skimage import io, filters, segmentation, feature
import matplotlib.pyplot as plt
%matplotlib inline

# Load and preprocess image
img = io.imread('membranes.tif')
smooth = filters.gaussian(img, sigma=1)

# Detect seeds/markers
distance = feature.peak_local_max(
    -smooth, 
    min_distance=20,
    indices=False
)
markers = segmentation.label(distance)

# Watershed segmentation
labels = segmentation.watershed(
    smooth,
    markers=markers,
    watershed_line=True
)

# Visualize results
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12,6))
ax1.imshow(img)
ax2.imshow(labels, cmap='nipy_spectral') 
plt.show()
  1. Alternatively, you could try Cellpose which is specialized for cell segmentation tasks: https://github.com/mouseland/cellpose

Let me know if you'd like me to elaborate on any of these approaches!

Best regards, git-bob