示例#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
示例#2
0
文件: __init__.py 项目: niksart/3dbar
 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
示例#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)
示例#4
0
文件: __init__.py 项目: natir/3dbar
 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
示例#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)
示例#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
示例#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
示例#8
0
文件: __init__.py 项目: niksart/3dbar
 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
示例#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
示例#10
0
文件: __init__.py 项目: niksart/3dbar
    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)
示例#11
0
文件: __init__.py 项目: baishi/3dbar
 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)
示例#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)
示例#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()
示例#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)
示例#15
0
文件: __init__.py 项目: baishi/3dbar
    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)
示例#16
0
 def __getFullnameMapping(self):
     filename = os.path.join(self.inputDirectory, CONF_FULLNAME_MAPPING_FILE)
     mapping =  getDictionaryFromFile(filename)
     return mapping
示例#17
0
文件: __init__.py 项目: baishi/3dbar
 def __getParentChildMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, HIERARCHY_FILANEME)
     mapping = getDictionaryFromFile(mappingFilename)
     return mapping
示例#18
0
 def __getParentChildMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, HIERARCHY_FILANEME)
     mapping = getDictionaryFromFile(mappingFilename)
     return mapping
示例#19
0
文件: __init__.py 项目: natir/3dbar
 def __getFullNameMapping(self):
     fullnameMappingFile = os.path.join(self.inputDirectory, FULLNAME_MAPPING_FN)
     return getDictionaryFromFile(fullnameMappingFile, 0, 1)
示例#20
0
文件: __init__.py 项目: natir/3dbar
 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
示例#21
0
 def __getColorMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 0, 2)
     return mapping
示例#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
示例#23
0
文件: __init__.py 项目: niksart/3dbar
 def __getFullNameMapping(self):
     fullnameMappingFile =\
             os.path.join(self.inputDirectory, FULLNAME_MAPPING_FN)
     return getDictionaryFromFile(fullnameMappingFile, 0, 1)
示例#24
0
文件: __init__.py 项目: baishi/3dbar
 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
示例#25
0
 def __getFullnameMapping(self):
     filename = os.path.join(self.inputDirectory,
                             CONF_FULLNAME_MAPPING_FILE)
     mapping = getDictionaryFromFile(filename)
     return mapping
示例#26
0
文件: __init__.py 项目: baishi/3dbar
 def __getColorMapping(self):
     mappingFilename = os.path.join(self.inputDirectory, MAPPING_FILENAME)
     mapping = getDictionaryFromFile(mappingFilename, 0, 2)
     return mapping