Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODEX #768

Open
matthew-lee1 opened this issue Oct 26, 2023 · 1 comment
Open

CODEX #768

matthew-lee1 opened this issue Oct 26, 2023 · 1 comment
Assignees

Comments

@matthew-lee1
Copy link

Hello, thanks for an awesome package! I am currently trying to extract image features within a segmentation mask and here is my set up so far:

mpif = tiff.imread('mpif_cropped.ome.tiff')
mask = tiff.imread('cellpose_mask_cropVFS-25489.ome.tif')
hae = tiff.imread('hae_cropped.ome.tiff')

image = sq.im.ImageContainer(mpif, layer='mpif')
image.add_img(mask, layer='mask')
image.add_img(hae, layer='hae')

adata = ad.AnnData(obs=pd.DataFrame(index=range(len(centroids))), obsm={"spatial": centroids})
adata.uns['spatial'] = {'images' : image}

sq.im.calculate_image_features( adata, img=image, layer='mpif', features='segmentation', n_jobs=16, features_kwargs={ 'segmentation': { 'props': ['area', 'centroid'], 'label_layer': 'mask' } } )

I'm thinking there's a problem with the way I'm registering adata.uns['spatial'], another option I've tried is:
spatial_key = "spatial"
library_id = "CHANGE"
adata.uns[spatial_key] = {library_id: {}}
adata.uns[spatial_key][library_id]["images"] = {}
adata.uns[spatial_key][library_id]["images"] = {"hires": np.transpose(mpif, (1,2,0))}
adata.uns[spatial_key][library_id]["scalefactors"] = { "tissue_hires_scalef": 1, "spot_diameter_fullres": 0.5, }

Which is closer to the documentation but still I am unable to get the feature extraction to work. It seems that it cannot find the segmentation mask. Is there a way around this? Thanks!

@matthew-lee1
Copy link
Author

I think part of the problem is that when you run calculate_image_features() it attempts to first do spot cropping. any way around that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants