目录
数据集下载:
示例代码
参考文献:
bug修复
运行结果:
数据集下载:
- https://www.jianguoyun.com/p/DcEwQq0Q45bOBxj09JYC (访问密码: gd8dmv)
示例代码
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2022/1/10 20:27
# @Author : @linlianqin
# @Site :
# @File : main.py
# @Software: PyCharm
# @description:
'''
pyradiomics学习
'''
import radiomics
from radiomics import featureextractor as FEE# 文件名
ori_name = r'brain1_image.nrrd'
lab_name = r'brain1_label.nrrd'
para_name = r'Params.yaml'# 文件全部路径
ori_path =ori_name
lab_path = lab_name
para_path = para_name
print("originl path: " + ori_path)
print("label path: " + lab_path)
print("parameter path: " + para_path)# 使用配置文件初始化特征抽取器
# extractor = FEE.RadiomicsFeaturesExtractor(para_path)
extractor = FEE.RadiomicsFeatureExtractor(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)
参考文献:
【影像组学pyradiomics教程】 (二) pyradiomics 使用示例_JianJuly的博客-CSDN博客_pyradiomics的应用本系列博客后续将更新于个人微信公众号,欢迎关注。测试用的图片:pyradiomics\data\brain1_image.nrrd 和 pyradiomics\data\brain1_label.nrrd’测试用的配置文件:pyradiomics\examples\exampleSettings\Params.yaml测试文...https://blog.csdn.net/JianJuly/article/details/79017272
注:在以上文章中会出现以下几个问题,目前均已经解决,上述我写的代码没有问题
bug修复
1、报错AttributeError: module 'radiomics.featureextractor' has no attribute 'RadiomicsFeaturesExtractor'
将RadiomicsFeaturesExtractor库修改为RadiomicsFeatureExtractor
2、ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping in "D:/Params.yaml", line 34, column 3 found duplicate key "shape" with value "None" (original value: "None") in "D:/Params.yaml", line 37, column 3 To suppress this check see: Departure from previous API — Python YAML package documentation-keys Duplicate keys will become an error in future releases, and are errors by default when using the new API.
将yaml配置文件中的第37行注释掉即可
3、AttributeError: 'RadiomicsFeatureExtractor' object has no attribute '_enabledImagetypes'
将:
print("Enabled filters:\n\t", extractor._enabledImagetypes) print("Enabled features:\n\t", extractor._enabledFeatures)修改为:
print("Enabled filters:\n\t", extractor.enabledImagetypes) print("Enabled features:\n\t", extractor.enabledFeatures)
运行结果: