コード例 #1
0
def random_rotate(v):
    angle = GAL.random_rotation_angle_zyz()
    vr = GR.rotate(v, angle=angle, default_val=0.0)  # loc_r is none
    # print('angle:', angle)
    # print('loc_max:', loc_max)
    # print('loc_r:',type(loc_r),loc_r)
    return vr, angle
コード例 #2
0
        'pix_size': 1.0,
        'Dz': -5.0,
        'voltage': 300,
        'Cs': 2.0,
        'sigma': 0.4
    }
}

# generate a density map v that contains a toy structure
v = MU.generate_toy_model(dim_siz=64)  # generate a pseudo density map
print(v.shape)

# randomly rotate and translate v
loc_proportion = 0.1
loc_max = N.array(v.shape, dtype=float) * loc_proportion
angle = GAL.random_rotation_angle_zyz()
loc_r = (N.random.random(3) - 0.5) * loc_max
vr = GR.rotate(v, angle=angle, loc_r=loc_r, default_val=0.0)

# generate simulated subtomogram vb from v
vb = TSRSC.do_reconstruction(vr, op, verbose=True)
print('vb', 'mean', vb.mean(), 'std', vb.std(), 'var', vb.var())

# save v and vb as 3D grey scale images
TIF.put_mrc(vb, '/tmp/vb.mrc', overwrite=True)
TIF.put_mrc(v, '/tmp/v.mrc', overwrite=True)

# save images of the slices of the corresponding 3D iamges for visual inspection
import aitom.image.io as IIO
import aitom.tomominer.image.vol.util as TIVU
IIO.save_png(TIVU.cub_img(vb)['im'], "/tmp/vb.png")