squidpy icon indicating copy to clipboard operation
squidpy copied to clipboard

cellpose: how to extract features after segmentation

Open WT215 opened this issue 2 years ago • 1 comments

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? ...

WT215 avatar May 25 '23 09:05 WT215

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

giovp avatar Jul 07 '24 14:07 giovp