本系列博客后续将更新于个人微信公众号,欢迎关注。
-
测试用的图片:
pyradiomics\data\brain1_image.nrrd 和 pyradiomics\data\brain1_label.nrrd’
-
测试用的配置文件:
pyradiomics\examples\exampleSettings\Params.yaml
- 测试文件也可从网盘下载:
- 将上述图片和配置文件拷贝到同一个文件夹,并且在同一文件夹下新建Python File
代码:
import radiomics
import radiomics.featureextractor as FEE
# 文件名
main_path = '.'
ori_name = r'\brain1_image.nrrd'
lab_name = r'\brain1_label.nrrd'
para_name = r'\Params.yaml'
# 文件全部路径
ori_path = main_path + ori_name
lab_path = main_path + lab_name
para_path = main_path + para_name
print("originl path: " + ori_path)
print("label path: " + lab_path)
print("parameter path: " + para_path)
# 使用配置文件初始化特征抽取器
extractor = FEE.RadiomicsFeaturesExtractor(para_path)
print ("Extraction parameters:\n\t", extractor.settings)
print ("Enabled filters:\n\t", extractor._enabledImagetypes)
print ("Enabled features:\n\t", extractor._enabledFeatures)
# 运行
result = extractor.execute(ori_path,lab_path) #抽取特征
print ("Result type:", type(result)) # result is returned in a Python ordered dictionary
print ("")
print ("Calculated features")
for key, value in result.items(): #输出特征
print ("\t", key, ":", value)