Esempio n. 1
0
 def __getColorMapping(self):
     # Structure name -> structure colour mapping
     # The mapping has to be assigned to the parser as well as to the indexer separately
     # This procedure should be simplified in the future.
     filename = os.path.join(self.inputDirectory, CONF_COLOR_MAPPING_FILE)
     mapping = getDictionaryFromFile(filename)
     return mapping
Esempio n. 2
0
 def __getColorMapping(self):
     # set structure name -> structure colour mapping
     # We need to set this mapping here because parser needs to know what
     # colors have to be assigned to paths
     colorMappingFile = os.path.join(self.inputDirectory, COLOR_MAPPING_FN)
     structureColours = getDictionaryFromFile(colorMappingFile, 0, 2)
     return structureColours
Esempio n. 3
0
    def __init__(self, inputDirectory, outputDirectory, **kwargs):
        # Extend passed properties and invoke uperclass constuctor
        kwargs.update(atlasparserProperties)
        bar.barBitmapParser.__init__(self, **kwargs)

        self.inputDirectory = inputDirectory
        self.outputDirectory = outputDirectory

        # Define source dataset location and initialize parser by loading
        # source dataset
        sourceFilename = 'atlas.nii'
        self._loadVolume(sourceFilename)

        # Some properties cannot be predefined, adding them now:
        self.setProperty('outputDirectory', outputDirectory)

        # structure name -> structure colour mapping
        fullnameMappingFile = os.path.join(self.inputDirectory,
                                           'fullnames.txt')
        structureColours = getDictionaryFromFile(fullnameMappingFile, 0, 2)
        self.setProperty('structureColours', structureColours)
        self.indexer.colorMapping = structureColours

        self._defineSlideRange(antPostAxis=3)
        self._pathNumber = 0

        # Set indexer properties
        self.indexer.updateProperties(indexerProperties)
Esempio n. 4
0
 def __getColorMapping(self):
     # set structure name -> structure colour mapping
     # We need to set this mapping here because parser needs to know what
     # colors have to be assigned to paths
     colorMappingFile = os.path.join(self.inputDirectory, COLOR_MAPPING_FN)
     structureColours = getDictionaryFromFile(colorMappingFile, 0, 2)
     return structureColours
Esempio n. 5
0
 def __init__(self, inputDirectory, outputDirectory, **kwargs):
     # Extend passed properties and invoke uperclass constuctor
     kwargs.update(atlasparserProperties)
     bar.barBitmapParser.__init__(self, **kwargs)
     
     self.inputDirectory = inputDirectory
     self.outputDirectory= outputDirectory
     
     # Define source dataset location and initialize parser by loading
     # source dataset
     sourceFilename = 'canon_labels_r.nii'
     volumetricFile = os.path.join(inputDirectory,sourceFilename)
     self._volumeSrc = nifti.NiftiImage(volumetricFile)
     self._volume = self._volumeSrc.data[0]
     
     #Some properties cannot be predefined, adding them now:
     self.setProperty('outputDirectory', outputDirectory)
     
     # set structure name -> structure colour mapping
     fullnameMappingFile = os.path.join(self.inputDirectory,'fullnames.txt')
     structureColours = getDictionaryFromFile(fullnameMappingFile, 0, 2)
     self.setProperty('structureColours', structureColours)
     self.indexer.colorMapping=structureColours
     
     self.slideRange = map(lambda x: 1023 - x, range(0,1024))
     self._pathNumber = 0
     
     # Set indexer properties        
     self.indexer.updateProperties(indexerProperties)
Esempio n. 6
0
 def __getLabelIndexToNameMapping(self):
     # Load pixelValue to structureName mapping:
     # This mapping is required to assign structure's name to the given label's index
     filename = os.path.join(self.inputDirectory, CONF_VOLUME_LABEL_MAPPING_FILE)
     mapping  = getDictionaryFromFile(filename)
     mapping  = dict(map(lambda (k,v): (int(k),v), mapping.iteritems()))
     return mapping
Esempio n. 7
0
 def __getColorMapping(self):
     # Structure name -> structure colour mapping
     # The mapping has to be assigned to the parser as well as to the indexer separately
     # This procedure should be simplified in the future.
     filename = os.path.join(self.inputDirectory, CONF_COLOR_MAPPING_FILE)
     mapping = getDictionaryFromFile(filename)
     return mapping
Esempio n. 8
0
 def __getImageToStructureMapping(self):
     # set source bitmap colour -> structure name
     imagToStructFn =\
             os.path.join(self.inputDirectory, IMAGE_TO_STRUCTURE_FN)
     imageToStructure = getDictionaryFromFile(imagToStructFn)
     imageToStructure = dict(
         ('#' + k.lower(), v) for k, v in imageToStructure.iteritems())
     return imageToStructure
Esempio n. 9
0
 def __getLabelIndexToNameMapping(self):
     # Load pixelValue to structureName mapping:
     # This mapping is required to assign structure's name to the given label's index
     filename = os.path.join(self.inputDirectory,
                             CONF_VOLUME_LABEL_MAPPING_FILE)
     mapping = getDictionaryFromFile(filename)
     mapping = dict(map(lambda (k, v): (int(k), v), mapping.iteritems()))
     return mapping
Esempio n. 10
0
    def __init__(self, inputDirectory, outputDirectory):
        props = {}
        props['filenameTemplates'] = filenameTempates
        props['slideRange'] = slideRange
        colorMapping = getDictionaryFromFile(colorMappingFilename)
        props['structureColours'] = colorMapping
        props['renderingProperties'] = renderingProperties
        props['tracingProperties'] = tracerSettings
        props['inputDirectory'] = inputDirectory
        props['outputDirectory'] = outputDirectory

        bar.barVectorParser.__init__(self, **props)

        self.indexer.updateProperties(indexerProps)
Esempio n. 11
0
 def __init__(self, inputDirectory, outputDirectory):
     props = {}
     props['filenameTemplates'] = filenameTempates
     props['slideRange'] = slideRange
     colorMapping = getDictionaryFromFile(colorMappingFilename)
     props['structureColours'] = colorMapping
     props['renderingProperties'] = renderingProperties
     props['tracingProperties'] = tracerSettings
     props['inputDirectory'] = inputDirectory
     props['outputDirectory'] = outputDirectory
     
     bar.barVectorParser.__init__(self, **props)
     
     self.indexer.updateProperties(indexerProps)
Esempio n. 12
0
    def __init__(self, inputDirectory, outputDirectory, **kwargs):
        # Extend passed properties and invoke uperclass constuctor
        kwargs.update(atlasparserProperties)
        bar.barBitmapParser.__init__(self, **kwargs)

        self.inputDirectory = inputDirectory
        self.outputDirectory= outputDirectory

        # Define source dataset location and initialize parser by loading
        # source dataset
        sourceFilename = 'segmentation_in_uct_space.nii.gz'
        volumetricFile = os.path.join(inputDirectory, sourceFilename)

        self._volumeSrc = nifti.NiftiImage(volumetricFile)
        self._volumeHeader = self._volumeSrc.header
        self._volume = self._volumeSrc.data

        #Some properties cannot be predefined, adding them now:
        self.setProperty('outputDirectory', outputDirectory)

        # Assign structure abbreviation --> structure colour mapping
        # Assign structure abbreviation --> structure fullname mapping
        fullnameMappingFile = os.path.join(self.inputDirectory,'fullnames.txt')
        structureColours = getDictionaryFromFile(fullnameMappingFile, 1, 2)
        imageToStructure = getDictionaryFromFile(fullnameMappingFile, 0, 1)
        imageToStructure = dict( ('#'+k.lower(), v) for k, v in  # small
                imageToStructure.iteritems())                    # correction

        self.setProperty('structureColours', structureColours)
        self.setProperty('imageToStructure', imageToStructure)
        self.indexer.colorMapping = structureColours

        self._defineSlideRange(antPostAxis=2)
        self._pathNumber = 0

        # Set indexer properties
        self.indexer.updateProperties(indexerProperties)
Esempio n. 13
0
 def reindex(self): 
     bar.barBitmapParser.reindex(self)
     
     #Load hierarchy from parents.txt
     hierarhySourceFilename = os.path.join(self.inputDirectory, 'parents.txt')
     self.indexer.setParentsFromFile(hierarhySourceFilename)
     
     # set structure name -> structure colour mapping
     fullnameMappingFile = os.path.join(self.inputDirectory,'fullnames.txt')
     structureColours = getDictionaryFromFile(fullnameMappingFile, 0, 2)
     self.setProperty('structureColours', structureColours)
     self.indexer.colorMapping=structureColours
     
     # Load and use fullname mapping
     fullnameMappingFile = os.path.join(self.inputDirectory,'fullnames.txt')
     self.indexer.setNameMappingFromFile(fullnameMappingFile, 0 , 1)
     
     self.writeIndex()
Esempio n. 14
0
    def __init__(self, inputDirectory, outputDirectory):
        # Update the parser properties dictionary before invoking an instance
        # of vector atlas parser (this is the way it works).
        props = {}
        props['filenameTemplates'] = filenameTempates
        props['slideRange'] = slideRange

        colorMapping = getDictionaryFromFile(colorMappingFilename)
        props['structureColours'] = colorMapping
        props['renderingProperties'] = renderingProperties
        props['tracingProperties'] = tracerSettings
        props['inputDirectory'] = inputDirectory
        props['outputDirectory'] = outputDirectory

        bar.barVectorParser.__init__(self, **props)

        # Add slide tracing and rendering settings to the parser's data
        self._tracingConf = tracerSettings
        self._rendererConf = renderingProperties

        # And now update the parser's indexer configuration (phew...) as
        # previously we were updating only properties and configuration of the
        # parser itself.
        self.indexer.updateProperties(indexerProps)
Esempio n. 15
0
    def __init__(self, inputDirectory, outputDirectory):
        # Update the parser properties dictionary before invoking an instance
        # of vector atlas parser (this is the way it works).
        props = {}
        props['filenameTemplates'] = filenameTempates
        props['slideRange'] = slideRange

        colorMapping = getDictionaryFromFile(colorMappingFilename)
        props['structureColours'] = colorMapping
        props['renderingProperties'] = renderingProperties
        props['tracingProperties'] = tracerSettings
        props['inputDirectory'] = inputDirectory
        props['outputDirectory'] = outputDirectory

        bar.barVectorParser.__init__(self, **props)

        # Add slide tracing and rendering settings to the parser's data
        self._tracingConf = tracerSettings
        self._rendererConf = renderingProperties

        # And now update the parser's indexer configuration (phew...) as
        # previously we were updating only properties and configuration of the
        # parser itself.
        self.indexer.updateProperties(indexerProps)
Esempio n. 16
0
 def __getFullnameMapping(self):
     filename = os.path.join(self.inputDirectory, CONF_FULLNAME_MAPPING_FILE)
     mapping =  getDictionaryFromFile(filename)
     return mapping
Esempio n. 17
0
 def __getParentChildMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, HIERARCHY_FILANEME)
     mapping = getDictionaryFromFile(mappingFilename)
     return mapping
Esempio n. 18
0
 def __getParentChildMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, HIERARCHY_FILANEME)
     mapping = getDictionaryFromFile(mappingFilename)
     return mapping
Esempio n. 19
0
 def __getFullNameMapping(self):
     fullnameMappingFile = os.path.join(self.inputDirectory, FULLNAME_MAPPING_FN)
     return getDictionaryFromFile(fullnameMappingFile, 0, 1)
Esempio n. 20
0
 def __getImageToStructureMapping(self):
     # set source bitmap colour -> structure name
     imagToStructFn = os.path.join(self.inputDirectory, IMAGE_TO_STRUCTURE_FN)
     imageToStructure = getDictionaryFromFile(imagToStructFn)
     imageToStructure = dict(("#" + k.lower(), v) for k, v in imageToStructure.iteritems())
     return imageToStructure
Esempio n. 21
0
 def __getColorMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 0, 2)
     return mapping
Esempio n. 22
0
 def __getImageToAbbrevMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 4, 0)
     mapping = dict(map(lambda (k, v): (int(k), v), mapping.iteritems()))
     return mapping
Esempio n. 23
0
 def __getFullNameMapping(self):
     fullnameMappingFile =\
             os.path.join(self.inputDirectory, FULLNAME_MAPPING_FN)
     return getDictionaryFromFile(fullnameMappingFile, 0, 1)
Esempio n. 24
0
 def __getImageToAbbrevMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 4, 0)
     mapping = dict(map(lambda (k,v): (int(k),v), mapping.iteritems()))
     return mapping
Esempio n. 25
0
 def __getFullnameMapping(self):
     filename = os.path.join(self.inputDirectory,
                             CONF_FULLNAME_MAPPING_FILE)
     mapping = getDictionaryFromFile(filename)
     return mapping
Esempio n. 26
0
 def __getColorMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 0, 2)
     return mapping