本笔记来源于B站Up主: 有Li 的影像组学系列教学视频
本节(8)主要介绍: 使用代码批量提取特征
数据存放路径及格式如图:
import radiomics
from radiomics import featureextractor
import pandas as pd
dataDir = 'C:/Users/RONG/Desktop/PythonBasic/Images/'
folderList = ['001','002','003','004','005']
extractor = featureextractor.RadiomicsFeatureExtractor()
df = pd.DataFrame()
for folder in folderList:
imageName = dataDir + folder +'/lung_image.nrrd'
maskName = dataDir + folder + '/lung_label.nrrd'
featureVector = extractor.execute(imageName,maskName)
df_add = pd.DataFrame.from_dict(featureVector.values()).T
df_add.columns = featureVector.keys()
df = pd.concat([df,df_add])
df.to_excel(dataDir + 'results.xlsx')
提取到的excel表打开后是这样的:
注意,这里李博士只是演示批量提取的方法,具体的pyradiomics参数需要根据自己的研究目的来调整。