这里演示如何使用SPM的LST工具包来提取WMHV,并且用python(你也可以用其他语言)将一批人的结果整合到一个txt里面
1. 安装
把官网下载的包解压到spm文件下的toolbox里就可以了
unpack the zip-file
remove the old LST folder
copy or link the LST folder to the spm/toolbox directory
2. 分割算法
有LGA, lesion growth algorithm 和 LPA, lesion prediction algorithm两种分割方法
LGA需要T1WI,T2 FLAIR 和自己设置的阈值
LPA只需要T2,但是耗时比LGA长(一个人一分钟左右),但是不需要阈值,比较自动化
这里只说明LPA的用法
3. LPA
doc里面的说明
3.0 引用
短的版本
Lesions were segmented by the lesion prediction algorithm (Schmidt, 2017, Chapter 6.1) as implemented in the LST toolbox version 3.0.0 (www.statistical-modelling.de/lst.html) for SPM.
长的版本
Lesions were segmented by the lesion prediction algorithm (Schmidt, 2017, Chapter 6.1) as implemented in the LST toolbox version 3.0.0 (www.statistical-modelling.de/lst.html) for SPM. This algorithm consists of a binary classifier in the form of a logistic regression model trained on the data of 53 MS patients with severe lesion patterns. Data were obtained at the Department of Neurology, Technische Universität München, Munich, Germany. As covariates for this model a similar lesion belief map as for the lesion growth algorithm (Schmidt et al., 2012) was used as well as a spatial covariate that takes into account voxel specific changes in lesion probability. Parameters of this model fit are used to segment lesions in new images by providing an estimate for the lesion probability for each voxel.
3.1 运行
在toolbox里选择LST
在LST窗口里选择LPA
假设我在xxx/work文件夹下面放了俩T2
那么选择这个文件夹,选完之后点Done
然后在主界面点run就可以了
- 参考时间:i7CPU 一个人一分钟
3.2 结果
假设原始T2图叫做abc.nii
mabc.nii 偏差矫正后的FLAIR图像
ples_p;a_mabc.nii lesion 概率map
每个abc生成一个文件夹,里面有overlay
3.3 在report里面查看WMH体积
每个图像生成的特定文件夹和test目录下都可以找到report网页(有排版差别)
以test目录下的report为例
这里面包含需要的lesion volume和lesion数
剩下的工作就变成提取html的数据了,Java, Python都可以做
3.4 使用lxml提取WMH信息
lxml是一个便捷的包,使用方法可以参考
python HTML解析之 - lxml
爬虫解析库:XPath
python3解析库lxml
现在path里面有这么一系列report(简单起见,我把所有report网页单独复制到path里了)
from lxml import etree
import os
FILE_PATH = 'Your path' # Use your own file path here
for dirpath, dirnames, filenames in os.walk(FILE_PATH):
for htmlName in filenames:
serialNumber = htmlName[16:21] # SXXXX, modify it according to your data
html = etree.parse(FILE_PATH + htmlName, etree.HTMLParser())
selectRes = html.xpath('//div[@class="column-02"]//table[@style="width: 500px"]//text()')
lesionVolume = selectRes[10]
lesionNumber = selectRes[16]
print(serialNumber, " ", lesionVolume, " ", lesionNumber)
运行结果如下
后面的可以参照这篇文章,把结果导入到csv表格里