コード例 #1
0
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")
IIO.save_png(TIVU.cub_img(v)['im'], "/tmp/v.png")

if True:
    # verify the correctness of SNR estimation
    vb_rep = TSRSC.do_reconstruction(vr, op, verbose=True)

    import scipy.stats as SS
    # calculate SNR
    vb_corr = SS.pearsonr(vb.flatten(), vb_rep.flatten())[0]
    vb_snr = 2 * vb_corr / (1 - vb_corr)
    print('SNR', 'parameter', op['model']['SNR'], 'estimated',
          vb_snr)  # fsc = ssnr / (2.0 + ssnr)
コード例 #2
0
def output_image(v, path):
    TIIO.save_png(TIVU.cub_img(v)['im'], path)