Esempio n. 1
0
def produce_projection_image(a=0, b=0, c=0, mrc_file='./zika_153.mrc'):
    """
    mrc_file: string of MRC file name
    a: rotation about x-axis (in degrees)
    b: rotation about y-axis (in degrees)
    c: rotation about z-axis (in degrees)
    """
    cos = math.cos
    sin = math.sin

    f = MRCFile(mrc_file)
    f.load_all_slices()
    # ar stands for degree in radian
    ar = a * math.pi / 180
    br = b * math.pi / 180
    cr = c * math.pi / 180

    Ra = [[1,        0,        0],
          [0,        cos(ar),  -sin(ar)],
          [0,        sin(ar),  cos(ar)]]

    Rb = [[cos(br),  0,        sin(br)],
          [0,        1,        0],
          [-sin(br), 0,        cos(br)]]

    Rc = [[cos(cr),  -sin(cr), 0],
          [sin(cr),  cos(cr),  0],
          [0,        0,        1]]

    R = np.dot(np.dot(Ra, Rb), Rc)
    I = project_fst(f.slices, R)
    return I, R
Esempio n. 2
0
def main():
    f = MRCFile('zika_153.mrc')
    f.load_all_slices()

    r = np.array([[0.25581, -0.77351, 0.57986], [-0.85333, -0.46255, -0.24057],
                  [0.45429, -0.43327, -0.77839]])

    molecule = f.slices[:, :, :]
    middle_slice = fft.ifftn(
        fft.ifftshift(fft.fftshift(fft.fftn(molecule))[:, :, 76]))
    # middle_slice = middle_slice.real
    # print(middle_slice)
    # plt.imshow(middle_slice)
    # plt.show()

    middle_back_proj = b(middle_slice)
    middle_back_proj = middle_back_proj.real[:, :, 76]
    plt.imshow(middle_back_proj)
    plt.show()
Esempio n. 3
0
def main():
    f = MRCFile('zika_153.mrc')
    f.load_all_slices()

    r = np.array([[0.25581,  -0.77351,   0.57986], 
     [-0.85333,  -0.46255,  -0.24057], 
     [0.45429,  -0.43327,  -0.77839]])


    molecule = f.slices[:, :, :]
    middle_slice = fft.ifftn(fft.ifftshift(fft.fftshift(fft.fftn(molecule))[:, :, 76]))
    # middle_slice = middle_slice.real
    # print(middle_slice)
    # plt.imshow(middle_slice)
    # plt.show()


    middle_back_proj = b(middle_slice)
    middle_back_proj = middle_back_proj.real[:, :, 76]
    plt.imshow(middle_back_proj)
    plt.show()
Esempio n. 4
0
from back_projection import back_project
from sim_image import project_fst
from MRCFile import MRCFile
from vanheel import random_rotation_matrix
import numpy as np
import sys

if len(sys.argv) != 3:
    print "please call with an mrc file as argument 1, and number of rotations as argument 2"
else:
    f = MRCFile(sys.argv[1])
    f.load_all_slices()
    images = []
    images_noisy = []
    Rs = [random_rotation_matrix() for i in xrange(int(sys.argv[2]))]
    # TODO here we can make many images later
    for R in Rs:
        image = project_fst(f.slices, R)
        images.append(image)
        noise = np.random.normal(0.0, 20 * np.mean(image), image.shape)
        images_noisy.append(image + noise)
    data = zip(images, Rs)
    noisy_data = zip(images_noisy, Rs)
    f.slices = back_project(data, use_filter=False)
    f.write_file("#nofilter.mrc", overwrite=True)
    f.slices = back_project(data)
    f.write_file("filter.mrc", overwrite=True)
    f.slices = back_project(noisy_data, use_filter=False)
    f.write_file("#nofilter_noise.mrc", overwrite=True)
    f.slices = back_project(noisy_data)
    f.write_file("filter_noise.mrc", overwrite=True)
Esempio n. 5
0
from MRCFile import MRCFile
from sim_image import project_fst
import matplotlib.pyplot as plt
from vanheel import random_rotation_matrix
zika_153 = MRCFile('zika_153.mrc')
zika_153.load_all_slices()
mol = zika_153.slices
# image = project_fst(mol, np.eye(3))
image = project_fst(mol, random_rotation_matrix())
plt.imshow(image)
plt.show()