hd 单细胞空间转录组学习路径 stardist
spatialdata
Tutorials — spatialdatahttps://spatialdata.scverse.org/en/latest/tutorials/notebooks/notebooks.html
先从10x segment教程学习
Nuclei Segmentation and Custom Binning of Visium HD Gene Expression Data - 10x Genomics
重要函数:
数组转换为图片 怎么把数字画成图
from stardist.data import test_image_nuclei_2d
from stardist.plot import render_label
from csbdeep.utils import normalize
import matplotlib.pyplot as pltimg = test_image_nuclei_2d()plt.imshow(img, cmap="gray")import matplotlib.pyplot as pltplt.imshow(arr) # RGB 数组即可显示
plt.axis('off')
plt.show()
import matplotlib.pyplot as plt
from skimage.color import label2rgb
overlay = label2rgb(labels, image=img, bg_label=0, alpha=0.3)
plt.imshow(overlay); plt.axis('off')
读取 png图片,
import numpy as np
import pandas as pd
from PIL import Image
from pathlib import Path
import matplotlib.pyplot as plt# 1. 读取图像与语义掩膜
img = np.array(Image.open("./images/img_001.png")) / 255.0
plt.imshow(img)
读取btf tiff文件
from tifffile import imread, imwrite
from csbdeep.utils import normalize
from stardist.models import StarDist2D
from shapely.geometry import Polygon, Point
from scipy import sparse
from matplotlib.colors import ListedColormap# 路径(示例)
dir_base = './binned_outputs/'
filename = 'Visium_HD_Mouse_Small_Intestine_tissue_image.btf' # 或你的高分辨率 H&E .tif
img = imread(os.path.join(dir_base, filename))