Sq.im.calculate_image_features with 2 library IDs

@giovp
Hello
Sorry to ask so many questions, but I am struggling with sq.im.calculate_image_features
I have 2 data that I concatenated in adata (2 library ID: 132_N_FTB000170 and 133_F_FTB000170).
For each library I have an image from which I want to get the features.
Here I tried to get the features for 133_F_FTB000170 library (the corresponding image is imgF.
Very strangly the 2 libraries are populated desptite the library_id specification !!

Do you undertand what I did wrong ?
Thanks !!
Sophie

Here is how I performed the concatenation:

library_names = [“132_N_FTB000170”, “133_F_FTB000170”]
adata = adataN.concatenate(
adataF,
batch_key=“library_id”,
uns_merge=“unique”,
batch_categories=library_names
)

Hi @sophieRAIBAUD

From what I can see the problem comes from library_id = "133_F_FTB000170". In the library_id argument you can specify a column which contains your library id, not a category inside a column. In your case the column is named “library_id” as specified in your concatenation. So it should probably be library_id = "library_id" instead of library_id = "133_F_FTB000170".

In general sq.im.calculate_image_features calculates features for all observations in the anndata object and is only applied on one image container at once.

I would recommend to apply the function on the individual anndata object with a single image instead of the concatenated anndata.

I hope this helps, if there is still an issue, feel free to comment.