示例#1
0
    def img_to_tex_vert_coords(self, imgcoords):
        vertcoords = img_to_ras_coords(imgcoords, self.affine)

        if self.convention == 'LAS':
            vertcoords = ras_to_las_coords(vertcoords)

        texcoords = img_to_tex_coords(imgcoords, self.data.shape)

        vertcoords = vertcoords - self.centershift

        if self.post_mat is not None:
            vertcoords = vertcoords.T
            vertcoords1 = np.vstack((vertcoords, np.ones(vertcoords.shape[1])))
            vertcoords1 = np.dot(self.post_mat, vertcoords1)
            vertcoords = vertcoords1[:-1, :].T

        return texcoords, vertcoords
示例#2
0
文件: slicer.py 项目: Paolopost/fos
    def img_to_tex_vert_coords(self, imgcoords):
        vertcoords = img_to_ras_coords(imgcoords, self.affine)
        
        if self.convention == 'LAS':
            vertcoords = ras_to_las_coords(vertcoords)

        texcoords = img_to_tex_coords(imgcoords, self.data.shape)

        vertcoords = vertcoords - self.centershift

        if self.post_mat is not None:
            vertcoords = vertcoords.T
            vertcoords1 = np.vstack((vertcoords, 
                                    np.ones(vertcoords.shape[1])))
            vertcoords1 = np.dot(self.post_mat, vertcoords1)
            vertcoords = vertcoords1[:-1, :].T
    
        return texcoords, vertcoords
示例#3
0
文件: slicer.py 项目: Paolopost/fos
    def __init__(self, name, data, affine, convention='RAS', post_mat=None):
        """ Volume Slicer

        Parameters
        ----------
        name : str
        data : array, (X, Y, Z) or (X, Y, Z, 3) or (X, Y, Z, 4)
        affine : array, shape (4, 4)
        convention : str,
                'LAS' or 'RAS'
        post_mat : array, shape (4, 4)

        """

        self.name = name
        self.data = data
        self.affine = affine
        self.convention = convention
        self.post_mat = post_mat
        self.tex = Texture3D('Buzz', self.data, self.affine, interp='linear')
        self.vertices = self.tex.vertices
        self.visible = True
        self.I, self.J, self.K = self.data.shape[:3]
        self.i, self.j, self.k = self.I/2, self.J/2, self.K/2

        self.centershift = img_to_ras_coords(
                        np.array([[self.I/2., self.J/2., self.K/2.]]), 
                        affine)
        
        if self.convention == 'LAS':
            self.centershift = ras_to_las_coords(self.centershift)

        self.texcoords_i, self.vertcoords_i = self.slicecoords_i()
        self.texcoords_j, self.vertcoords_j = self.slicecoords_j()
        self.texcoords_k, self.vertcoords_k = self.slicecoords_k()
        self.show_i = True
        self.show_j = True
        self.show_k = True
示例#4
0
    def __init__(self, name, data, affine, convention='RAS', post_mat=None):
        """ Volume Slicer

        Parameters
        ----------
        name : str
        data : array, (X, Y, Z) or (X, Y, Z, 3) or (X, Y, Z, 4)
        affine : array, shape (4, 4)
        convention : str,
                'LAS' or 'RAS'
        post_mat : array, shape (4, 4)

        """

        self.name = name
        self.data = data
        self.affine = affine
        self.convention = convention
        self.post_mat = post_mat
        self.tex = Texture3D('Buzz', self.data, self.affine, interp='linear')
        self.vertices = self.tex.vertices
        self.visible = True
        self.I, self.J, self.K = self.data.shape[:3]
        self.i, self.j, self.k = self.I / 2, self.J / 2, self.K / 2

        self.centershift = img_to_ras_coords(
            np.array([[self.I / 2., self.J / 2., self.K / 2.]]), affine)

        if self.convention == 'LAS':
            self.centershift = ras_to_las_coords(self.centershift)

        self.texcoords_i, self.vertcoords_i = self.slicecoords_i()
        self.texcoords_j, self.vertcoords_j = self.slicecoords_j()
        self.texcoords_k, self.vertcoords_k = self.slicecoords_k()
        self.show_i = True
        self.show_j = True
        self.show_k = True