Example #1
0
def compare_with_file(fname, dx, NA, lam, n):

    u1 = read3dTiff(fname)

    Nz, Ny, Nx = u1.shape
    u2 = psf((Nx, Ny, Nz), (dx, ) * 3, lam, NA, n0=n)

    u1 *= 1. / np.amax(u1)
    u2 *= 1. / np.amax(u2)

    x = dx * (np.arange(Nx) - Nx / 2)
    z = dx * (np.arange(Nz) - Nz / 2)

    pylab.clf()
    pylab.subplot(2, 1, 1)
    pylab.title("NA = %s n = %s" % (NA, n))
    pylab.plot(x, u1[Nz / 2, Ny / 2, :], label="file_x")
    pylab.plot(x, u2[Nz / 2, Ny / 2, :], label="u_x")
    pylab.plot(x, theory_x(x, lam, NA, n), color="k", label="theor_x")
    pylab.legend()

    pylab.subplot(2, 1, 2)

    pylab.plot(z, u1[:, Ny / 2, Nx / 2], label="file_z")
    pylab.plot(z, u2[:, Ny / 2, Nx / 2], label="u_z")
    pylab.plot(z, theory_z(z, lam, NA, n), color="k", label="theor_z")
    #pylab.plot(z,theory_debye_z(z,lam,NA,n),"o",color="r",label="debye_z")
    pylab.legend()
    pylab.show()
    return u1, u2
Example #2
0
def compare_with_file(fname,dx, NA,lam,n):

    u1 = read3dTiff(fname)

    Nz,Ny,Nx = u1.shape
    u2 = psf((Nx, Ny, Nz), (dx,) * 3, lam, NA, n0=n)

    u1 *= 1./np.amax(u1)
    u2 *= 1./np.amax(u2)

    x = dx*(np.arange(Nx)-Nx/2)
    z = dx*(np.arange(Nz)-Nz/2)

    pylab.clf()
    pylab.subplot(2,1,1)
    pylab.title("NA = %s n = %s"%(NA,n))
    pylab.plot(x,u1[Nz/2,Ny/2,:],label="file_x")
    pylab.plot(x,u2[Nz/2,Ny/2,:],label="u_x")
    pylab.plot(x,theory_x(x,lam,NA,n),color="k",label="theor_x")
    pylab.legend()

    pylab.subplot(2,1,2)

    pylab.plot(z,u1[:,Ny/2,Nx/2],label="file_z")
    pylab.plot(z,u2[:,Ny/2,Nx/2],label="u_z")
    pylab.plot(z,theory_z(z,lam,NA,n),color="k",label="theor_z")
    #pylab.plot(z,theory_debye_z(z,lam,NA,n),"o",color="r",label="debye_z")
    pylab.legend()
    pylab.show()
    return u1, u2
Example #3
0
    
    y = myconvolve(x,h)+s*np.amax(x)*np.random.uniform(0,1,x.shape)

    y2 = myconvolve(x,h2)+s*np.amax(x)*np.random.uniform(0,1,x.shape)

    # u = deconv_tv_al([y,y2],[h,h2])

    
    u = deconv_tv_al(y,h,10.,1.)

    u2 = deconv_wiener(y,h,0.1)
    
    #3d
    from spimagine import read3dTiff

    x = read3dTiff("data/usaf3d.tif")[100:228,100:228,100:228]
    h = psf(x.shape,(3.,3.,11))

    h2 = psf(x.shape,(11,3,3))
    h3 = psf(x.shape,(3,11,3))
    
    y = myconvolve(x,h)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)
    y2 = myconvolve(x,h2)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)
    y3 = myconvolve(x,h3)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)

    u = deconv_tv_al([y,y2,y3],[h,h2,h3],100.,1.)

    u2 = deconv_wiener([y,y2,y3],[h,h2,h3],0.01)


Example #4
0
    R = np.sqrt(Z**2 + Y**2 + X**2)

    noise = gputools.perlin3((N, ) * 3, scale=10)
    dn = .1 * noise * (R < .4) * (1 - 7.j)

    return dn


if __name__ == '__main__':
    import sys

    if len(sys.argv) > 1:
        if sys.argv[1].isdigit():
            dn = sphere_dn(int(sys.argv[1]))
        else:
            dn = read3dTiff(sys.argv[1])
    else:
        dn = sphere_dn(128)

    app = QtWidgets.QApplication(sys.argv)

    win = BeamGui(dn=dn, size=(100, ) * 3)
    # win = BeamGui(dn = dn, size = (50,50,25))

    win.show()

    win.raise_()

    win.propagate()

    #sys.exit(app.exec_())
Example #5
0
    noise = gputools.perlin3((N,)*3,scale= 10)
    dn = .1*noise*(R<.4)*(1-7.j)


    return dn


if __name__=='__main__':
    import sys

    if len(sys.argv)>1:
        if sys.argv[1].isdigit():
            dn = sphere_dn(int(sys.argv[1]))
        else:
            dn = read3dTiff(sys.argv[1])
    else:
        dn = sphere_dn(128)

    app = QtWidgets.QApplication(sys.argv)

    win = BeamGui(dn=dn, size=(100,)*3)
    # win = BeamGui(dn = dn, size = (50,50,25))


    win.show()

    win.raise_()

    win.propagate()
Example #6
0
def psf(dshape,sigmas = (2.,2.)):
    Xs = np.meshgrid(*[np.arange(-_s/2,_s/2) for _s in dshape], indexing="ij")

    h = np.exp(-np.sum([_X**2/2./_s**2 for _X,_s in zip(Xs,sigmas)],axis=0))

    h *= 1./np.sum(h)
    return np.fft.ifftshift(h)
    

        

if __name__ == '__main__':
    from matplotlib.pyplot import imread
    
    from spimagine import read3dTiff
    im = read3dTiff("data/usaf3d.tif")[200:328,200:328,200:328]
    # im = imread("data/usaf.png")[200:456,100:356]


    im *= 255

    np.random.seed(0)

    # im*= 10
    
    hx = (3.5,1.)
    hs = [psf(im.shape,np.roll(hx,i)) for i in range(im.ndim)]
    
    
    ys = [myconvolve(im ,h) for h in hs]
    
Example #7
0

[email protected]

"""

from biobeam import SimLSM_Cylinder
from spimagine import read3dTiff

if __name__ == '__main__':

    #dn = read3dTiff("/Users/mweigert/python/bpm_projects/forward_model/data/sample_elegans_512.tif")
    #dn = dn.transpose(0,2,1).copy()
    #signal = 1.*dn.real

    dn = read3dTiff("/Users/mweigert/python/bpm_projects/forward_model/data/sample2_512_dn.tif")[128:-128]
    signal = read3dTiff("/Users/mweigert/python/bpm_projects/forward_model/data/sample2_512_signal.tif")[128:-128]



    #some point sources
    max_sig = np.amax(np.abs(signal))
    np.random.seed(0)
    for _ in range(4000):
        k,j,i = np.random.randint(dn.shape[0]),np.random.randint(dn.shape[1]),np.random.randint(dn.shape[2])
        signal[k,j,i] = 100.*max_sig



    #signal[146,::10,:] = 40.*max_dn