复杂度
强度
特征类型特征解释
Gray Level(GLDM)灰度依赖矩阵 (GLDM) 特征(共14个)
sis
小依赖分布的度量,值越大表示依赖越小,纹理越不均匀
sis
大依赖分布的度量,值越大表示依赖越大,纹理越均匀
ty
灰度非均匀性 。测量图像中灰度级强度值的相似性
ity
衡量整个图像中依赖关系的相似性,值越低表示图像中依赖关系之间的同质性越高
依赖非均匀归一化 。衡量整个图像中依赖关系的相似性,值越低表示图像中依赖关系之间的同质性越高
灰度方差
依赖方差
依赖熵
测量低灰度值的分布,值越大表示图像中低灰度值的集中度越高
s
测量较高灰度值的分布,值越高表示图像中高灰度值的集中度越高
测量具有较低灰度值的小相关性的联合分布
测量具有较高灰度值的小相关性的联合分布
测量具有较低灰度值的大相关性的联合分布
测量具有较高灰度值的大相关性的联合分布
注意:除了形状特征类外,其他特征都可以在原始图像和滤波后的图像上进行计算
具体的指定方法:
可以直接使用:( )启用所有类型
也可以使用:Name(, =True)启用你想用的类型
例如:
# 设置一阶特征extractor.enableFeatureClassByName('firstorder')# 设置只提取一阶特征的'Mean'和'Skewness'extractor.enableFeaturesByName(firstorder=['Mean', 'Skewness'])
也可以直接通过特征类别来启用具体的特征,示例见:
图像归一化:
图像/mask重采样:
例如:
settings = {}settings['![binWidth](https://img-blog.csdnimg.cn/c9b0896a5eea4eaf8217d0ed7f23e92b.png)'] = 25settings['resampledPixelSpacing'] = [3,3,3]# [3,3,3] is an example for defining resampling (voxels with size 3x3x3mm)settings['interpolator'] = sitk.sitkBSpline
还有其他的一些设置,根据自己的需要修改即可 。
最后举一个完整的例子,我要处理的是CT数据,所以我参考了的源码中ct参数的设置,最后我的代码如下:
from __future__ import print_functionimport siximport os# needed navigate the system to get the input dataimport numpy as npimport radiomicsimport pandas as pdimport SimpleITK as sitkfrom radiomics import featureextractor# This module is used for interaction with pyradiomicsimport argparsedef catch_features(imagePath,maskPath):if imagePath is None or maskPath is None:# Something went wrong, in this case PyRadiomics will also log an errorraise Exception('Error getting testcase!')# Raise exception to prevent cells below from running in case of "run all"settings = {}settings['binWidth'] = 25# 5settings['sigma'] = [3, 5]settings['Interpolator'] = sitk.sitkBSplinesettings['resampledPixelSpacing'] = [1, 1, 1]# 3,3,3settings['voxelArrayShift'] = 1000# 300settings['normalize'] = Truesettings['normalizeScale'] = 100extractor = featureextractor.RadiomicsFeatureExtractor(**settings)#extractor = featureextractor.RadiomicsFeatureExtractor()print('Extraction parameters:\n\t', extractor.settings)extractor.enableImageTypeByName('LoG')extractor.enableImageTypeByName('Wavelet')extractor.enableAllFeatures()extractor.enableFeaturesByName(firstorder=['Energy', 'TotalEnergy', 'Entropy', 'Minimum', '10Percentile', '90Percentile', 'Maximum', 'Mean', 'Median', 'InterquartileRange', 'Range', 'MeanAbsoluteDeviation', 'RobustMeanAbsoluteDeviation', 'RootMeanSquared', 'StandardDeviation', 'Skewness', 'Kurtosis', 'Variance', 'Uniformity'])extractor.enableFeaturesByName(shape=['VoxelVolume', 'MeshVolume', 'SurfaceArea', 'SurfaceVolumeRatio', 'Compactness1', 'Compactness2', 'Sphericity', 'SphericalDisproportion','Maximum3DDiameter','Maximum2DDiameterSlice','Maximum2DDiameterColumn','Maximum2DDiameterRow', 'MajorAxisLength', 'MinorAxisLength', 'LeastAxisLength', 'Elongation', 'Flatness'])# 上边两句我将一阶特征和形状特征中的默认禁用的特征都手动启用,为了之后特征筛选print('Enabled filters:\n\t', extractor.enabledImagetypes)feature_cur = []feature_name = []result = extractor.execute(imagePath, maskPath, label=255)for key, value in six.iteritems(result):print('\t', key, ':', value)feature_name.append(key)feature_cur.append(value)print(len(feature_cur[37:]))name = feature_name[37:]name = np.array(name)'''flag=1if flag:name = np.array(feature_name)name_df = pd.DataFrame(name)writer = pd.ExcelWriter('key.xlsx')name_df.to_excel(writer)writer.save()flag = 0'''for i in range(len(feature_cur[37:])):#if type(feature_cur[i+22]) != type(feature_cur[30]):feature_cur[i+37] = float(feature_cur[i+37])return feature_cur[37:],nameimage_dir = r'D:\study\extract_radiomics_feature\linshi'mask_dir = r'D:\study\extract_radiomics_feature\linshi'patient_list = os.listdir(image_dir)save_file = np.empty(shape=[1,1051])id = []for patient in patient_list:print(patient)for file in os.listdir(os.path.join(image_dir,patient)):if file =='image.nii':imagePath = os.path.join(image_dir,patient,file)if file =='mask_gtv-1.nii':maskPath = os.path.join(mask_dir,patient,file)print(imagePath)print(maskPath)save_curdata,name = catch_features(imagePath,maskPath)save_curdata = http://www.kingceram.com/post/np.array(save_curdata)save_curdata = save_curdata.reshape([1, 1051])id.append(patient.split('.')[0])np.concatenate((patient,save_curdata),axis=1)save_file = np.append(save_file,save_curdata,axis=0)print(save_file.shape)save_file = np.delete(save_file,0,0)#save_file = save_file.transpose()#print(save_file.shape)id_num = len(id)id = np.array(id)name_df = pd.DataFrame(save_file)name_df.index = idname_df.columns = namewriter = pd.ExcelWriter('NSCLC-Radiomics-features.xlsx')name_df.to_excel(writer)writer.save()
- Ubuntu系统录屏软件SimpleScreenRecorder安装及使用教程
- 利用pyho爬取,怎么使用pyho爬取百度网的数据
- 初步使用电焊机技巧,直流电焊机的使用技巧
- 如何使用 Gelly?
- 关于pytorch中的distributedsampler函数使用
- 南京公积金提取条件
- 料事如神的诸葛亮一共使用了多少次锦囊妙计
- 普通用过通过sudo使用命令
- 揭秘宋朝名将岳飞:其最常使用的武器是什么
- 三 使用C++和Qt的涂鸦程序