【pyradiomics学习】——安装pyradiomics以及简单示例

目录

数据集下载:

示例代码 

参考文献:

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)

运行结果:

 

 

 

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

有情怀的机械男

你的鼓励将是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值