コード例 #1
0
ファイル: cfile.py プロジェクト: satra/connectomeviewer
    def process_surface(self, surface_node, nsprefix):
        """ Processing of the surface node
        
        Parameters
        ----------
        surface_node: the lxml node
            The XML node network-surface from the meta.xml file
        nsprefix: String
            The Name Space Prefix for clean iterating
        
        Returns
        -------
        tmpsurfacecontainer: `ISurfaceContainer` instance to add to the network
        
        """
        from surface_container import SurfaceContainer

        # create surface
        tmpsurfacecontainer = SurfaceContainer(name = surface_node.attrib['name'], \
                         src = surface_node.attrib['src'])

        tmpsurfacecontainer.set(_lxml_node = surface_node, _lxml_node_prefix = nsprefix, \
                                is_atlas = False)

        # adding label information to the surface container
        labelidentification = ''
        l_cnt = 0

        for tmplabels in surface_node.iterchildren():

            if tmplabels.tag == (nsprefix + 'surface-label'):
                l_cnt = l_cnt + 1

                if l_cnt > 2:
                    logger.error(
                        'There are multiple label for one surface container! Please check your meta.xml'
                    )
                    continue

                lattr = tmplabels.attrib
                if lattr.has_key('labelid'):
                    labelidentification = lattr['labelid']
                    if lattr.has_key('src'):
                        tmpsurfacecontainer._add_label(labelid = labelidentification,\
                                                    src = lattr['src'])

        return tmpsurfacecontainer
コード例 #2
0
ファイル: cfile.py プロジェクト: satra/connectomeviewer
    def process_atlas(self, surface_node, nsprefix):
        """ Processing of the surface node for atlases
        
        Parameters
        ----------
        surface_node: the lxml node
            The XML node network-surface from the meta.xml file
        nsprefix: String
            The Name Space Prefix for clean iterating
        
        Returns
        -------
        tmpsurfacecontainer: `ISurfaceContainer` instance to add to the network
        
        """
        from surface_container import SurfaceContainer

        if not cmp(surface_node.attrib['addatlas'], 'template_atlas_homo_sapiens_01'):
            logger.debug('Load the H**o sapiens Template Atlas 01 ...')
            
            from cviewer.resources.atlases.library import get_template_atlas, get_template_atlas_label
            atlaspathtofile = get_template_atlas(atlastype = 'homo_sapiens_01')
            if os.path.isfile(atlaspathtofile):
                logger.debug('Valid Freesurfer Atlas file. Add it as SurfaceContainer...')
                
                tmpsurfacecontaineratlas = SurfaceContainer(name = 'Freesurfer Atlas', \
                                                            src = atlaspathtofile)
                
                tmpsurfacecontaineratlas.set(_lxml_node = surface_node, _lxml_node_prefix = nsprefix, \
                                             is_atlas = True)
                
                # add the freesurfer label file
                labelidentification = ''
                nolabelid = False
                l_cnt = 0
                
                for tmplabels in surface_node.iterchildren():
                    
                    if tmplabels.tag == (nsprefix+'surface-label'):
                        l_cnt = l_cnt + 1
                        
                        if l_cnt > 2:
                            logger.error('There are multiple label for one surface container! Please check your meta.xml')
                            nolabelid = True
                            continue
                            
                        lattr = tmplabels.attrib
                        if lattr.has_key('labelid'):
                            labelidentification = lattr['labelid']
                            
                              
                if not nolabelid:
                    logger.debug('Using LabelID: %s' % labelidentification)
                    labelfile = get_template_atlas_label(atlastype = 'homo_sapiens_01')
                    
                    tmpsurfacecontaineratlas._add_label(labelid = labelidentification, \
                                                        src = labelfile)
                    
                    return tmpsurfacecontaineratlas
                
                else:
                    logger.error('No valid labelid is given in the meta.xml file')
            else:
                logger.debug('No valid file. Freesurfer Atlas not loaded.')