Ejemplo n.º 1
0
    def build_actors(self):

        log.info('Plotting '+str(self.data_xyz.shape[0])+' ODFs.')
        
        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()
        
        # Add double arrows for single dipole
        if self.data_j.shape[1] == 3:
            for i in range(self.M):
                utilvtk.draw_double_arrow(self.ren, self.data_xyz[i], self.rad_scale*self.data_j[i])
        # Add spherical function for ensemble
        else:
            radii = self.data_j*self.rad_scale/np.max(self.data_j)
            utilvtk.draw_sphere_field(self.ren, self.data_xyz, radii)

        # Draw extras
        utilvtk.draw_origin_dot(self.ren)
        utilvtk.draw_outer_box(self.ren, *self.shape)
        utilvtk.draw_axes(self.ren, *self.shape)
        
        # Set cameras
        dist = 1.15*np.linalg.norm(self.shape)
        self.ren.GetActiveCamera().SetPosition(np.array([1,-1,1])*dist)
        self.ren.GetActiveCamera().SetViewUp([0,0,1])
Ejemplo n.º 2
0
    def build_actors(self):
        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()
        
        self.B = utilsh.calcB(self.N, self.J)
        
        thresh_mask = self.data[:,:,:,0] > self.threshold
        skip_mask = np.zeros_like(thresh_mask, dtype=np.bool)
        skip_mask[::self.skip_n,::self.skip_n,::self.skip_n] = 1
        
        ijk = np.array(np.nonzero(thresh_mask*skip_mask)).T
        J_list = self.data[ijk[:,0], ijk[:,1], ijk[:,2], :]
        
        log.info('Plotting '+str(ijk.shape[0])+' ODFs.')

        # Draw odfs
        centers = (ijk - 0.5*self.npx + 0.5)*self.vox_dims # ijk2xyz
        radii = np.einsum('ij,kj->ki', self.B, J_list)
        radii *= self.rad_scale*self.skip_n*np.min(self.vox_dims)/(np.max(radii))
        utilvtk.draw_sphere_field(self.ren, centers, radii)

        # Draw extras
        utilvtk.draw_origin_dot(self.ren)
        utilvtk.draw_outer_box(self.ren, *self.shape)
        utilvtk.draw_axes(self.ren, *self.shape)
        
        # Set cameras
        dist = 1.15*np.linalg.norm(self.shape)
        self.ren.GetActiveCamera().SetPosition(np.array([1,-1,1])*dist)
        self.ren.GetActiveCamera().SetViewUp([0,0,1])
Ejemplo n.º 3
0
    def __init__(self, data, xlabel='', title='', N=2**14, lmax=None):

        self.data = np.array(data)
        self.N = N  # points on the sphere

        # Plotting
        self.xlabel = xlabel
        self.title = title

        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()

        # Calculate dimensions
        if lmax is None:
            self.lmax, mm = utilsh.j2lm(len(self.data) - 1)
        else:
            self.lmax = lmax
        self.J = utilsh.maxl2maxj(self.lmax)

        # Fill the rest of the last l band with zeros
        if self.data.shape[-1] != self.J:
            temp = np.zeros(self.J)
            temp[:self.data.shape[-1]] = self.data
            self.data = temp
        else:
            self.data = data

        # Calc points for spherical plotting
        self.xyz = utilsh.fibonacci_sphere(N, xyz=True)
        self.B = utilsh.calcB(self.N, self.J)
        self.Binv = np.linalg.pinv(self.B, rcond=1e-15)
Ejemplo n.º 4
0
    def __init__(self, data_xyz, data_ijk, shape=[10,10,4], vmin=0, vmax=None, xlabel='', title='', invert=True,
                 rad_scale=1.0, skip_n=1):
        self.data_xyz = data_xyz
        self.data_ijk = data_ijk

        self.shape = shape
        
        self.xlabel = utilmpl.shape2xlabel(self.shape)
        self.title = title

        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()

        self.rad_scale = rad_scale*np.min(self.shape)/50
Ejemplo n.º 5
0
    def build_actors(self):
        log.info('Plotting '+str(self.data_xyz.shape[0])+' ODFs.')

        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()

        # Plots spheres
        radii = np.einsum('ij,kj->ki', self.B, self.data_J)
        radii /= np.max(radii)
        utilvtk.draw_sphere_field(self.ren, self.data_xyz, radii)
        
        # Draw extras
        utilvtk.draw_origin_dot(self.ren)
        utilvtk.draw_outer_box(self.ren, *self.shape)
        utilvtk.draw_axes(self.ren, *self.shape)
        
        # Set cameras
        dist = 1.15*np.linalg.norm(self.shape)
        self.ren.GetActiveCamera().SetPosition(np.array([1,-1,1])*dist)
        self.ren.GetActiveCamera().SetViewUp([0,0,1])
Ejemplo n.º 6
0
    def __init__(self,
                 data,
                 vox_dims=[1, 1, 1],
                 vmin=0,
                 vmax=None,
                 xlabel='',
                 title='',
                 invert=True):
        self.data = data

        self.shape = data.shape * np.array(vox_dims)
        self.vox_dims = np.array(vox_dims)
        self.invert = invert
        self.xlabel = utilmpl.shape2xlabel(self.shape)
        self.title = title
        self.vmin = vmin
        if vmax is None:
            self.vmax = np.max(data)
        else:
            self.vmax = vnmax

        # Setup renderer
        self.ren, self.renWin, self.iren = utilvtk.setup_render()