Beispiel #1
0
    def compute_operator(self,interp_params,inds=None):
        if inds is None:
            Rs = n.array([[geom.rotmat3D_dir(d,t)[:,0:2] for t in self.thetas] for d in self.dirs])
            Rs = Rs.reshape((-1,3,2))        
        else:
            N_I = len(self.thetas)
            Rs = n.array([geom.rotmat3D_dir(self.dirs[i/N_I],self.thetas[n.mod(i,N_I)])[:,0:2] for i in inds])

        return cops.compute_projection_matrix(Rs,sym=self.sym,projdirtype='rots',**interp_params)
Beispiel #2
0
def compute_projection_matrix(projdirs,N,kern,kernsize,rad,projdirtype='dirs',sym=None, onlyRs=False, **kwargs):
    projdirs = n.asarray(projdirs,dtype=n.float32)
    if projdirtype == 'dirs':
        # Input is a set of projection directions
        dirhash = hash(projdirs.tostring())
        if onlyRs and dirhash in precomputed_Rs:
            Rs = precomputed_Rs[dirhash]
        else:
            Rs = n.vstack([geom.rotmat3D_dir(d)[:,0:2].reshape((1,3,2)) for d in projdirs])
            if onlyRs:
                precomputed_Rs[dirhash] = Rs
    elif projdirtype == 'rots':
        # Input is a set of rotation matrices mapping image space to protein space
        Rs = projdirs
    else:
        assert False, 'Unknown projdirtype, must be either dirs or rots'

    if sym is None:
        symRs = None
    else:
        symRs = n.vstack([ n.require(R,dtype=n.float32).reshape((1,3,3)) for R in sym.get_rotations()])

    if onlyRs:
        return Rs
    else:
        return sincint.compute_interpolation_matrix(Rs,N,N,rad,kern,kernsize,symRs)
    def compute_operator(self, interp_params, inds=None):
        if inds is None:
            Rs = n.array(
                [[geom.rotmat3D_dir(d, t)[:, 0:2] for t in self.thetas]
                 for d in self.dirs])
            Rs = Rs.reshape((-1, 3, 2))
        else:
            N_I = len(self.thetas)
            Rs = n.array([
                geom.rotmat3D_dir(self.dirs[i / N_I],
                                  self.thetas[n.mod(i, N_I)])[:, 0:2]
                for i in inds
            ])

        return cops.compute_projection_matrix(Rs,
                                              sym=self.sym,
                                              projdirtype='rots',
                                              **interp_params)
Beispiel #4
0
def compute_projection_matrix(projdirs,
                              N,
                              kern,
                              kernsize,
                              rad,
                              projdirtype='dirs',
                              sym=None,
                              onlyRs=False,
                              **kwargs):
    projdirs = n.asarray(projdirs, dtype=n.float32)
    if projdirtype == 'dirs':
        # Input is a set of projection directions
        dirhash = hash(projdirs.tostring())
        if onlyRs and dirhash in precomputed_Rs:
            Rs = precomputed_Rs[dirhash]
        else:
            Rs = n.vstack([
                geom.rotmat3D_dir(d)[:, 0:2].reshape((1, 3, 2))
                for d in projdirs
            ])
            if onlyRs:
                precomputed_Rs[dirhash] = Rs
    elif projdirtype == 'rots':
        # Input is a set of rotation matrices mapping image space to protein space
        Rs = projdirs
    else:
        assert False, 'Unknown projdirtype, must be either dirs or rots'

    if sym is None:
        symRs = None
    else:
        symRs = n.vstack([
            n.require(R, dtype=n.float32).reshape((1, 3, 3))
            for R in sym.get_rotations()
        ])

    if onlyRs:
        return Rs
    else:
        return sincint.compute_interpolation_matrix(Rs, N, N, rad, kern,
                                                    kernsize, symRs)