摘要
最近需要对WSI图像进行处理,以前没弄过,所以整理下方法。
环境:Ubuntu 18.04 LTS, Python 3.7, pyvips
数据: [TCGA-GBM (Survival Prediction)]
本文主要参考以下两个博客:
https://blog.csdn.net/weixin_41594007/article/details/81810231
https://blog.csdn.net/songyu0120/article/details/85087529
安装pyvips
- 用pip 或者conda安装
- Ubuntu下使用
sudo apt install libvips
安装c library依赖
读取svs文件
TCGA_path = 'test.svs'
img = pyvips.Image.new_from_file(TCGA_path, access='sequential')
img.dzsave('/output', tile_height=512, tile_width=512) # 在这里定义输出patch的大小,现在是512x512
剔除空patch
我这里用了最傻瓜的方法,就是判断图片的variance,然后用一个阈值给刷掉
image = cv2.read(image_path)
if image.var() < 500:
os.remove(image_path)