Esempio n. 1
0
    def calculate_animation(self, dt):
        '''
		based on the assumption that dt goes from 0 to 1
		'''
        if dt > 1: raise
        if self.angle != 0:
            t1 = dt * self.angle
            t2 = self.angle - t1
            next = old_div(
                (sin(t2) * self.start_point + sin(t1) * self.end_point),
                self.sinangle)
        else:
            T = Transform()
            d = {"type": "spin"}
            d["omega"] = dt * 360
            d["n1"] = self.rot_vec[0]
            d["n2"] = self.rot_vec[1]
            d["n3"] = self.rot_vec[2]
            T.set_rotation(d)

            next = T * self.start_point

            #next = Vec3f(self.start_point[0],self.start_point[1],self.start_point[2])

        self.arc_points[self.stage].append(self.radius * next)
        self.target.arc_animation_update(self.arc_points)
Esempio n. 2
0
    def __establish_sphere_points(self, stage):
        self.start_point = self.transforms[stage].transpose() * self.z_point
        self.end_point = self.transforms[stage + 1].transpose() * self.z_point
        if self.start_point != self.end_point:
            self.angle = acos(self.start_point.dot(self.end_point))
            self.omega = 1
        else:
            self.angle = 0
            normal = Vec3f(-self.start_point[2], 0, -self.start_point[0])
            normal.normalize()

            T = Transform()
            d = {"type": "spin"}
            d["omega"] = self.omega
            d["n1"] = normal[0]
            d["n2"] = normal[1]
            d["n3"] = normal[2]
            T.set_rotation(d)
            self.rot_vec = self.start_point
            p = self.start_point
            self.start_point = T * self.rot_vec
            self.end_point = T * self.rot_vec
            self.omega += 1

        self.sinangle = sin(self.angle)
        self.arc_points.append([])
Esempio n. 3
0
    def calculate_animation(self, dt):
        """
		based on the assumption that dt goes from 0 to 1
		"""
        if dt > 1:
            raise
        if self.angle != 0:
            t1 = dt * self.angle
            t2 = self.angle - t1
            next = (sin(t2) * self.start_point + sin(t1) * self.end_point) / self.sinangle
        else:
            T = Transform()
            d = {"type": "spin"}
            d["omega"] = dt * 360
            d["n1"] = self.rot_vec[0]
            d["n2"] = self.rot_vec[1]
            d["n3"] = self.rot_vec[2]
            T.set_rotation(d)

            next = T * self.start_point

            # next = Vec3f(self.start_point[0],self.start_point[1],self.start_point[2])

        self.arc_points[self.stage].append(self.radius * next)
        self.target.arc_animation_update(self.arc_points)
Esempio n. 4
0
    def __establish_sphere_points(self, stage):
        self.start_point = self.transforms[stage].transpose() * self.z_point
        self.end_point = self.transforms[stage + 1].transpose() * self.z_point
        if self.start_point != self.end_point:
            self.angle = acos(self.start_point.dot(self.end_point))
            self.omega = 1
        else:
            self.angle = 0
            normal = Vec3f(-self.start_point[2], 0, -self.start_point[0])
            normal.normalize()

            T = Transform()
            d = {"type": "spin"}
            d["omega"] = self.omega
            d["n1"] = normal[0]
            d["n2"] = normal[1]
            d["n3"] = normal[2]
            T.set_rotation(d)
            self.rot_vec = self.start_point
            p = self.start_point
            self.start_point = T * self.rot_vec
            self.end_point = T * self.rot_vec
            self.omega += 1

        self.sinangle = sin(self.angle)
        self.arc_points.append([])
Esempio n. 5
0
def transform_com(com, ptcl):
    t = Transform()
    if len(com) == 3:
        t.set_rotation({'psi': meta.psi, 'phi': meta.phi, 'theta': meta.theta, 'type': 'spider'})
    else:
        t.set_rotation({'psi': meta.psi})
    shift = t.transform(com)
    # The change in the origin is the projection of the transformed difference vector on the new xy plane.
    return shift[0], shift[1]
Esempio n. 6
0
def subtract(particle,
             dens,
             sub_dens,
             recenter=None,
             no_frc=False,
             low_cutoff=0.0,
             high_cutoff=0.7071):
    """
    Perform projection subtraction on one particle image.
    :param particle: Tuple holding original (particle EMData, particle MetaData)
    :param dens: Whole density map
    :param sub_dens: Subtraction density map
    :param recenter: Vector between CoM before and after subtraction, or None to skip recenter operation (default None)
    :param no_frc: Skip FRC normalization (default False)
    :param low_cutoff: Low cutoff frequency in FRC normalization (default 0.0)
    :param high_cutoff: High cutoff frequency in FRC normalization (default 0.7071)
    :return: Result object
    """
    ptcl, meta = particle[0], particle[1]
    ctfproj = make_proj(dens, meta)
    ctfproj_sub = make_proj(sub_dens, meta)

    if no_frc:  # Direct subtraction only.
        ptcl_sub = ptcl - ctfproj_sub
    else:  # Per-particle FRC normalization.
        ptcl_sub = ptcl.process(
            "math.sub.optimal", {
                "ref": ctfproj,
                "actual": ctfproj_sub,
                "low_cutoff_frequency": low_cutoff,
                "high_cutoff_frequency": high_cutoff
            })

    ptcl_norm_sub = ptcl_sub.process("normalize")

    if recenter is not None:
        # Rotate the coordinate frame of the CoM difference vector by the Euler angles.
        t = Transform()
        t.set_rotation({
            'psi': meta.psi,
            'phi': meta.phi,
            'theta': meta.theta,
            'type': 'spider'
        })
        shift = t.transform(recenter)
        # The change in the origin is the projection of the transformed difference vector on the new xy plane.
        meta.x_origin += shift[0]
        meta.y_origin += shift[1]

    return Result(ptcl, meta, ctfproj, ctfproj_sub, ptcl_sub, ptcl_norm_sub)
Esempio n. 7
0
def make_proj(dens, meta):
    """
    Project and CTF filter density according to particle metadata.
    :param dens: EMData density
    :param meta: Particle metadata (Euler angles and CTF parameters)
    :return: CTF-filtered projection
    """
    t = Transform()
    t.set_rotation({'psi': meta.psi, 'phi': meta.phi, 'theta': meta.theta, 'type': 'spider'})
    t.set_trans(-meta.x_origin, -meta.y_origin)
    proj = dens.project("standard", t)
    ctf = generate_ctf(meta.ctf_params)
    ctf_proj = filt_ctf(proj, ctf)
    return ctf_proj