haesleinhuepf / git-bob-bioimage-analysis-example

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

[Analysis Request]: Segment cells with marked membranes #56

Open haesleinhuepf opened 1 week ago

haesleinhuepf commented 1 week ago

Bio-Image Analysis Support Request

Image Upload

📎 Drag & drop your microscopy image here (JPG, PNG, GIF, 512x512 or 1024x1024, 2D only).

membranes

Analysis Goal

Python Tools

Note: Your images and the text you enter here may be sent to OpenAI's online serivce where we use a large language model to answer your request. Do not upload any data you cannot share openly. Also do not enter any private or secret information. By submitting this github issue, you confirm that you understand these conditions.

Once submitted, @haesleinhuepf will review and consult git-bob, an AI-assistant for bio-image analysis suggestions.

haesleinhuepf commented 1 week ago

git-bob think about this

github-actions[bot] commented 1 week ago

This message was generated by git-bob (version: 0.5.5, model: gpt-4o-2024-08-06, Run details), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

Certainly! Here's a suggested approach for segmenting the cells in the provided image using the specified tools:

import numpy as np
from skimage.io import imread
import napari_segment_blobs_and_things_with_membranes as nsbatwm
import stackview
from skimage.measure import regionprops_table
import pandas as pd
from skimage.segmentation import expand_labels

# Load the image
image = imread('path_to_your_image/membranes.png')

# Segment cells
cells_labels = nsbatwm.voronoi_otsu_labeling(image, spot_sigma=3.5, outline_sigma=1)

# Smooth their contours
smoothed_labels = nsbatwm.mode_filter(cells_labels, radius=10)

# Measure their average size
properties = regionprops_table(smoothed_labels, properties=['label', 'area'])
df = pd.DataFrame(properties)
average_cell_size = df['area'].mean()

print(f"Average Cell Size: {average_cell_size}")

# Show results
stackview.switch([image, smoothed_labels])

This code will segment the cells from the image, smooth the contours, and calculate their average area size. Make sure to replace 'path_to_your_image/membranes.png' with the actual path to the image. Let me know if you need further assistance!

haesleinhuepf commented 1 week ago

Awesome, that looks good! Download the image and save it as "data/membranes.png". Also create a jupyter notebook in the "notebooks" directory with your suggested code. When loading the image, make sure you load it from the right relative path.

git-bob implement this