def test_spot_crops_spot_scale(self, adata: AnnData, cont: ImageContainer, scale: float, spot_scale: float): diameter = adata.uns["spatial"][Key.uns.library_id( adata, "spatial")]["scalefactors"]["spot_diameter_fullres"] radius = int(round(diameter // 2) * spot_scale) size = int((2 * radius + 1) * scale), int((2 * radius + 1) * scale) for crop in cont.generate_spot_crops(adata, spot_scale=spot_scale, scale=scale): assert crop.shape == size
def test_spot_crops_mask_circle(self, adata: AnnData, cont: ImageContainer): for crop in cont.generate_spot_crops(adata, cval=np.nan, mask_circle=True, preserve_dtypes=False): assert crop.shape[0] == crop.shape[1] c = crop.shape[0] // 2 mask = (crop.data.x - c)**2 + (crop.data.y - c)**2 <= c**2 np.testing.assert_array_equal( crop["image"].values[..., 0][~mask.values], np.nan)