【影像组学pyradiomics教程】(二) 简单的使用-调用类方法

该系列是为了记录自己学习的过程

一、 立即开始

使用需要 img数据和mask数据
数据可以在官方代码的 /data 目录下获取

from radiomics import featureextractor

img = "./brain1_image.nrrd"
lab = "./brain1_label.nrrd"
# 实例化一个特征提取类
extractor = featureextractor.RadiomicsFeatureExtractor()
# 调用特征提取函数
featureVector = extractor.execute(img, lab)
# 返回值
for featureName in featureVector.keys():
    print("Computed %s: %s" % (featureName, featureVector[featureName]))

二、 对特征提取器进行自定义初始化设置

import SimpleITK as sitk
# 定义签名计算的设置
# 这些当前设置等于各自的默认值
settings = {}
settings['binWidth'] = 25
settings['resampledPixelSpacing'] = None  # [3,3,3] is an example for defining resampling (voxels with size 3x3x3mm)
settings['interpolator'] = sitk.sitkBSpline
# # 初始化特性提取器
extractor = featureextractor.RadiomicsFeatureExtractor(**settings)
# 其他流程同一

三、 对特征提取器进行自定义选择特征

# 默认情况下,只启用原始图像。可选启用一些图像类型:
# extractor.enableImageTypes(Original={}, LoG={}, Wavelet={})

# 禁用所有特征 默认全部开启
extractor.disableAllFeatures()

# 启用一阶(firstorder)特征  包含所有一阶特征
extractor.enableFeatureClassByName('firstorder')

# 在 一阶特征中 仅 mean 和 skewness 特征可用  与上面相同 
extractor.enableFeaturesByName(firstorder=['Mean', 'Skewness'])
# 其他流程同一

四 结果

# 在仅仅 mean 和 skewness 特征可用时的 输出包含一些其他属性(如版本,尺寸等)
Computed diagnostics_Versions_PyRadiomics: v3.0.1
Computed diagnostics_Versions_Numpy: 1.19.1
Computed diagnostics_Versions_SimpleITK: 2.0.2
Computed diagnostics_Versions_PyWavelet: 1.1.1
Computed diagnostics_Versions_Python: 3.7.6
Computed diagnostics_Configuration_Settings: {'minimumROIDimensions': 2, 'minimumROISize': None, 'normalize': False, 'normalizeScale': 1, 'removeOutliers': None, 'resampledPixelSpacing': None, 'interpolator': 'sitkBSpline', 'preCrop': False, 'padDistance': 5, 'distances': [1], 'force2D': False, 'force2Ddimension': 0, 'resegmentRange': None, 'label': 1, 'additionalInfo': True}
Computed diagnostics_Configuration_EnabledImageTypes: {'Original': {}}
Computed diagnostics_Image-original_Hash: 5c9ce3ca174f0f8324aa4d277e0fef82dc5ac566
Computed diagnostics_Image-original_Dimensionality: 3D
Computed diagnostics_Image-original_Spacing: (0.7812499999999999, 0.7812499999999999, 6.499999999999998)
Computed diagnostics_Image-original_Size: (256, 256, 25)
Computed diagnostics_Image-original_Mean: 385.6564080810547
Computed diagnostics_Image-original_Minimum: 0.0
Computed diagnostics_Image-original_Maximum: 3057.0
Computed diagnostics_Mask-original_Hash: 9dc2c3137b31fd872997d92c9a92d5178126d9d3
Computed diagnostics_Mask-original_Spacing: (0.7812499999999999, 0.7812499999999999, 6.499999999999998)
Computed diagnostics_Mask-original_Size: (256, 256, 25)
Computed diagnostics_Mask-original_BoundingBox: (162, 84, 11, 47, 70, 7)
Computed diagnostics_Mask-original_VoxelNum: 4137
Computed diagnostics_Mask-original_VolumeNum: 2
Computed diagnostics_Mask-original_CenterOfMassIndex: (186.98549673676578, 106.3562968334542, 14.38917089678511)
Computed diagnostics_Mask-original_CenterOfMass: (46.47304432559825, 16.518518098863908, 15.529610829103234)
Computed original_firstorder_Mean: 825.2354363065023
Computed original_firstorder_Skewness: 0.27565085908587594

你可能感兴趣的:(【影像组学pyradiomics教程】(二) 简单的使用-调用类方法)