scverse / squidpy

Spatial Single Cell Analysis in Python
https://squidpy.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
402 stars 72 forks source link

cellpose: how to extract features after segmentation #694

Open WT215 opened 1 year ago

WT215 commented 1 year ago

Hi,

I specified segmented_custom in the following code

    sq.im.segment(img=img2, layer="image_smooth", channel=None, method=cellpose_he, channel_cellpose=0, flow_threshold=1)

    #FINAL COUNTING

    sq.im.calculate_image_features(
        adata,
        img2,
        #layer="image",
        layer=seg_layer,
        #layer='segmented_watershed',
        features="segmentation",
        key_added="segmentation_features",
        #https://scikit-image.org/docs/stable/api/skimage.measure.html#skimage.measure.regionprops
        features_kwargs={
            "segmentation": {
                "label_layer":    "segmented_custom"  ,
                "props": ["label", "area",'bbox_area','convex_area','filled_area', "mean_intensity"],
                "channels": [0],
            }
        },
        mask_circle=True,
        show_progress_bar=False,
        n_jobs=8
    )

to extract features, but most of the number of nuclei is zero, and contain missing values in other features. I wonder if the value in segmented_custom layer need to be modified in advance? ...

giovp commented 2 weeks ago

hi @WT215 I would check the output of the segmentation layer first, in order to see how many segmentations masks you have obtained, and whether they are of high quality