目錄
數據集下載:
示例代碼?
參考文獻:
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)
運行結果:
?
?
?