Issues of mask_circle in function squidpy.im.calculate_image_features
@michalk8 is already working on this.
Since Sep 17, 2023.
- Dominant language
- Python
- Stars
- 598
- Forks
- 121
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 3
Description
Description
Sometimes, even when we set mask_circle=True in function squidpy.im.calculate_image_features, the features of segmentation is still calculated by a square mask rather than a circle mask.
Minimal reproducible example
The simplest reproducible example is this tutorial:
https://squidpy.readthedocs.io/en/stable/notebooks/tutorials/tutorial_tangram.html
After using sq.im.calculate_image_features, if we check the distance between each spot center and the corresponding centroids, the maximum distance is larger than spot radius and less than sqrt(2)*spot radius. By using the following code, we can also easily tell that the mask is still square, not circle.
df = adata_st.obsm["image_features"]['segmentation_centroid']
spot_center = adata_st.obsm['spatial']
d_max = np.zeros(len(spot_center))
diff= []
for i in tqdm(range(len(spot_center))):
d = 0
for location in df[i]:
if len(location) > 0 and location[0] is not np.nan:
diff += [np.array(location)-spot_center[i]]
d = max(d, np.sqrt(np.sum((diff[-1])**2)))
d_max[i] = d
print(max(d_max)) # 52.3
diff = np.array(diff)
mpl.pyplot.scatter(diff[:, 0], diff[:, 1], s=1)
mpl.pyplot.axis('equal')
Another piece of evidence is the very last figure of this tutorial. If the mask is correct, then the centers of all dots should be in spots.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.