https://github.com/Radiomics/pyradiomics
Revision 218954ddee91cc2279fb3b7ee7f7593052ed24c7 authored by Joost van Griethuysen on 20 March 2017, 16:40:48 UTC, committed by Joost van Griethuysen on 20 March 2017, 17:21:48 UTC
When building the wheel, parameter schema file was not included in the install. Move these files to a new subdirectory of pyradiomics and include them as "package_data".
1 parent d9dd283
Raw File
Tip revision: 218954ddee91cc2279fb3b7ee7f7593052ed24c7 authored by Joost van Griethuysen on 20 March 2017, 16:40:48 UTC
BUG: Data_files not included in wheel distribution
Tip revision: 218954d
GenerateInputCSV_Datasethierarchy.py
from __future__ import print_function

import csv
import os

from DatasetHierarchyReader import DatasetHierarchyReader


def main():
  DATA_ROOT_PATH = r''
  inputDirectory = DATA_ROOT_PATH + r''
  outputFile = DATA_ROOT_PATH + r'/FileList.csv'
  filetype = '.nrrd'

  keywordSettings = {}
  keywordSettings['image'] = ''
  keywordSettings['imageExclusion'] = 'label'
  keywordSettings['mask'] = 'label'
  keywordSettings['maskExclusion'] = ''

  print("Scanning files...")

  datasetReader = DatasetHierarchyReader(inputDirectory, filetype=filetype)
  datasetHierarchyDict = datasetReader.ReadDatasetHierarchy()

  print("Found %s patients, writing csv" % (str(len(datasetHierarchyDict.keys()))))

  try:
    with open(outputFile, 'wb') as outFile:
      cw = csv.writer(outFile, lineterminator='\n')

      for patientIndex, patientDirectory in enumerate(datasetHierarchyDict):
        patientID = os.path.basename(patientDirectory)

        for studyDirectory in datasetHierarchyDict[patientDirectory]:
          studyDate = os.path.basename(studyDirectory)

          imageFilepaths = datasetHierarchyDict[patientDirectory][studyDirectory]["reconstructions"]
          maskFilepaths = datasetHierarchyDict[patientDirectory][studyDirectory]["segmentations"]

          imageFilepath, maskFilepath = datasetReader.findImageAndLabelPair(imageFilepaths, maskFilepaths,
                                                                            keywordSettings)

          if (imageFilepath is not None) and (maskFilepath is not None):
            # ReaderName is not extracted using DatasetHierarchyReader, set it to 'N/A'
            cw.writerow([patientID, studyDate, 'N/A', imageFilepath, maskFilepath])

  except Exception as exc:
    print(exc)


if __name__ == '__main__':
  main()
back to top