Esempio n. 1
0
    def load(self, directory, atlas_name):
        if not os.path.isdir(directory):
            print "Error: Atlas directory", directory, "does not exist or is not a directory."
            raise "<cluster.py> I/O error"
        
        fname_base = os.path.join(directory,atlas_name)
        fname_atlas = fname_base+'.p'
        fname_polydata = fname_base+'.vtp'
        
        if not os.path.exists(fname_atlas):
            print "Error: Atlas file", fname_atlas, "does not exist."
            raise "<cluster.py> I/O error"
        if not os.path.exists(fname_polydata):
            print "Error: Atlas file", fname_polydata, "does not exist."
            raise "<cluster.py> I/O error"

        atlas = pickle.load(open(fname_atlas,'rb'))
        atlas.nystrom_polydata = io.read_polydata(fname_polydata)
        print "<cluster.py> Atlas loaded. Nystrom polydata sample:", atlas.nystrom_polydata.GetNumberOfLines(), \
            "Atlas size:", atlas.pinv_A.shape, "number of eigenvectors:", atlas.number_of_eigenvectors

        atlas.polydata_filename = fname_polydata

        # check for any version issues
        if not hasattr(atlas, 'version'):    
            atlas.version = '0.0'
        # this is an atlas from pre 1.0 version code. Set to default values.
        if not hasattr(atlas, 'distance_method'):    
            atlas.distance_method = 'Hausdorff'
        if not hasattr(atlas, 'bilateral'):    
            atlas.bilateral = 'False'

        print "Loaded atlas", atlas_name, "from", directory
        #print atlas
        pprint (vars(atlas))

        return(atlas)
Esempio n. 2
0
 def load(self, directory, atlas_name):
     fname = os.path.join(directory,atlas_name)
     atlas = pickle.load(open(fname+'.p','rb'))
     atlas.nystrom_polydata = io.read_polydata(fname+'.vtp')
     return(atlas)