예제 #1
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]
예제 #2
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)