Exemplo n.º 1
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)
Exemplo n.º 2
0
    def __init__(self, data, vox_dims=[.1,.1,.1], N=2**10, title='',
                 skip_n=1, rad_scale=1, threshold=0):
        self.data = data
        self.npx = np.array(self.data.shape[0:3])
        self.vox_dims = vox_dims # um
        self.N = N
        self.shape = np.array(data.shape[0:3])*np.array(vox_dims)

        self.xlabel = utilmpl.shape2xlabel(self.shape)
        self.title = title
        self.skip_n = skip_n
        self.rad_scale = rad_scale
        self.threshold = threshold

        # Calculate dimensions
        self.lmax, mm = utilsh.j2lm(self.data.shape[-1] - 1)
        self.J = utilsh.maxl2maxj(self.lmax)
Exemplo n.º 3
0
    def from_tiff(self, filename):
        log.info('Reading '+filename)
        with tifffile.TiffFile(filename) as tf:
            # Read data
            self.data = np.ascontiguousarray(np.moveaxis(tf.asarray(), [0, 1, 2, 3], [2, 3, 1, 0]))

            # Read vox_dims from metadata
            xx = tf.pages[0].tags['XResolution'].value
            self.vox_dims[0] = xx[1]/xx[0]
            yy = tf.pages[0].tags['YResolution'].value
            self.vox_dims[1] = yy[1]/yy[0]
            self.vox_dims[2] = tf.imagej_metadata['spacing']
            
        self.npx = np.array(self.data.shape[0:3])
        self.shape = np.array(self.npx)*np.array(self.vox_dims)
        self.xlabel = utilmpl.shape2xlabel(self.shape)
        self.lmax, mm = utilsh.j2lm(self.data.shape[-1] - 1)
        self.J = utilsh.maxl2maxj(self.lmax)
Exemplo n.º 4
0
    def __init__(self, data_xyz, data_J, shape=[10,10,4], N=2**12, title=''):
        self.data_xyz = np.array(data_xyz)
        self.data_J = np.array(data_J)
        self.M = self.data_xyz.shape[0] 
        self.N = N
        self.shape = shape # um

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

        # Calculate dimensions
        self.lmax, mm = utilsh.j2lm(self.data_J.shape[-1] - 1)
        self.J = utilsh.maxl2maxj(self.lmax)

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

        # Calc points for spherical plotting
        self.xyz = utilsh.fibonacci_sphere(N, xyz=True)
        self.B = utilsh.calcB(self.N, self.J)
Exemplo n.º 5
0
 def to_xyzj_list(self, N):
     J = utilsh.maxl2maxj(self.lmax)
     B = utilsh.calcB(N, self.J)
     data_j = np.einsum('ij,kj->ki', B, self.data_J)
     return xyzj_list(self.data_xyz, data_j, shape=self.shape,
                      title=self.title)
Exemplo n.º 6
0
 def precompute_tripling(self):
     Jout = utilsh.maxl2maxj(2 * self.lmax)
     self.G = utilsh.G_real_mult_tensor(Jout, self.J)