Radiomics:安装并调通第一个demo
import radiomics
import radiomics.featureextractor as FEE
# 文件名
main_path = './'
ori_name = 'brain1_image.nrrd'
lab_name = 'brain1_label.nrrd'
para_name = 'default.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.RadiomicsFeatureExtractor(para_path)
print("Extraction parameters:\n\t", extractor.settings)
print("Enabled filters:\n\t", extractor.enabledImagetypes)
print("Enabled filters:\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)
测试图像下载:https://pan.baidu.com/s/1KvPmJnk88kkdI_0IOCMRMQ 提取码: 4hp5, default.yaml内容如下:
# This is an example of a parameters file
# It is written according to the YAML-convention (www.yaml.org) and is checked by the code for consistency.
# Three types of parameters are possible and reflected in the structure of the document:
#
# Parameter category:
# Setting Name:
#
# The three parameter categories are:
# - setting: Setting to use for preprocessing and class specific settings. if no is specified, the value for
# this setting is set to None.
# - featureClass: Feature class to enable, is list of strings representing enabled features. If no is
# specified or is an empty list ('[]'), all features for this class are enabled.
# - imageType: image types to calculate features on. is custom kwarg settings (dictionary). if is an
# empty dictionary ('{}'), no custom settings are added for this input image.
#
# Some parameters have a limited list of possible values. Where this is the case, possible values are listed in the
# package documentation
# Settings to use, possible settings are listed in the documentation (section "Customizing the extraction").
setting:
binWidth: 25
label: 1
interpolator: 'sitkBSpline' # This is an enumerated value, here None is not allowed
resampledPixelSpacing: # This disables resampling, as it is interpreted as None, to enable it, specify spacing in x, y, z as [x, y , z]
weightingNorm: # If no value is specified, it is interpreted as None
force2D: true
force2Ddimension: 0 # axial slices, for coronal slices, use dimension 1 and for sagittal, dimension 2.
# Image types to use: "Original" for unfiltered image, for possible filters, see documentation.
imageType:
Original: {} # for dictionaries / mappings, None values are not allowed, '{}' is interpreted as an empty dictionary
# LoG:{'sigma': [1.0, 3.0]}
Wavelet:
binWidth: 10
# Featureclasses, from which features must be calculated. If a featureclass is not mentioned, no features are calculated
# for that class. Otherwise, the specified features are calculated, or, if none are specified, all are calculated (excluding redundant/deprecated features).
featureClass:
shape:
# redundant Compactness 1, Compactness 2 an Spherical Disproportion features are disabled by default, they can be
# enabled by specifying individual feature names (as is done for glcm) and including them in the list.
shape:
- SurfaceArea
firstorder: [] # specifying an empty list has the same effect as specifying nothing.
glcm: # Disable SumAverage by specifying all other GLCM features available
- 'Autocorrelation'
- 'JointAverage'
- 'ClusterProminence'
- 'ClusterShade'
- 'ClusterTendency'
- 'Contrast'
- 'DifferenceVariance'
- 'JointEnergy'
- 'JointEntropy'
glrlm: # for lists none values are allowed, in this case, all features are enabled
glszm:
gldm: # contains deprecated features, but as no individual features are specified, the deprecated features are not enabled
结果:(一大堆冗余数据,还需后续分析)