Esempio n. 1
0
mod = np.array([[0, 1.8, 0, 0.95, 0, 1 / 6], [1.9, 0, 0, 0.95, 0, 1 / 6],
                [0, 1.8, 0, 0.95, 2 * np.pi / 3, 1 / 6],
                [1.9, 0, 0, 0.95, 2 * np.pi / 3, 1 / 6],
                [0, 1.8, 0, 0.95, 4 * np.pi / 3, 1 / 6],
                [1.9, 0, 0, 0.95, 4 * np.pi / 3, 1 / 6]])


def plot_traces(traces, theta, axis=0):
    plt.figure()
    for k in range(len(traces)):
        plt.plot(np.arange(len(traces[k])), traces[k][:, axis])
        plt.plot([len(traces[k])], [theta[k, axis]], 'o')


with Context(debugMode=False) as ctx:
    g = gaussian.Gaussian(ctx)

    roisize = 10
    sf_theta = [[roisize // 2, roisize // 2, 0, 10000, 5]]
    sf_theta = np.repeat(sf_theta, 20, 0)

    psf = g.CreatePSF_XYZIBg(roisize,
                             gaussian.Gauss3D_Calibration(),
                             cuda=True)

    spot_mod = mod.reshape(len(mod) * 6)[None].repeat(len(sf_theta), 0)

    s = SIMFLUX(ctx)
    sum_estim = s.CreateEstimator(psf, len(mod), False)
    sf_estim = s.CreateEstimator(psf, len(mod), True)
Esempio n. 2
0
s0_x = 1.3
gamma_x = -20
d_x = 20
A_x = 0  #2e-04

s0_y = 1.3
gamma_y = 20
d_y = 20
A_y = 0  #1e-05

calib = gaussian.Gauss3D_Calibration([s0_x, gamma_x, d_x, A_x],
                                     [s0_y, gamma_y, d_y, A_y])

with Context() as ctx:
    sigma = 1.5
    roisize = 12
    theta = [[roisize // 2, roisize // 2, 3, 1000, 5]]
    g_api = gaussian.Gaussian(ctx)
    psf = g_api.CreatePSF_XYZIBg(roisize, calib, True)

    imgs = psf.ExpectedValue(theta)
    plt.figure()
    plt.imshow(imgs[0])

    sample = np.random.poisson(imgs)

    # Run localization on the sample
    estimated, diag, traces = psf.Estimate(sample)

    print(f"Estimated position: {estimated[0]}")