影像组学学习之路 pyradiomics 使用示例

  • 测试用的图片:

    pyradiomics\data\brain1_image.nrrd 和 pyradiomics\data\brain1_label.nrrd’

  • 测试用的配置文件:

    pyradiomics\examples\exampleSettings\Params.yaml

  • 将上述图片和配置文件拷贝到同一个文件夹,并且在同一文件夹下新建Python File

代码:

  1. import radiomics
  2. import radiomics.featureextractor as FEE
  3. # 文件名
  4. main_path = '.'
  5. ori_name = r'\brain1_image.nrrd'
  6. lab_name = r'\brain1_label.nrrd'
  7. para_name = r'\Params.yaml'
  8. # 文件全部路径
  9. ori_path = main_path + ori_name
  10. lab_path = main_path + lab_name
  11. para_path = main_path + para_name
  12. print( "originl path: " + ori_path)
  13. print( "label path: " + lab_path)
  14. print( "parameter path: " + para_path)
  15. # 使用配置文件初始化特征抽取器
  16. extractor = FEE.RadiomicsFeaturesExtractor(para_path)
  17. print ( "Extraction parameters:\n\t", extractor.settings)
  18. print ( "Enabled filters:\n\t", extractor._enabledImagetypes)
  19. print ( "Enabled features:\n\t", extractor._enabledFeatures)
  20. # 运行
  21. result = extractor.execute(ori_path,lab_path) #抽取特征
  22. print ( "Result type:", type(result)) # result is returned in a Python ordered dictionary
  23. print ( "")
  24. print ( "Calculated features")
  25. for key, value in result.items(): #输出特征
  26. print ( "\t", key, ":", value)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

你可能感兴趣的:(python,影像组学)