示例#1
0
def missing_particle(separation=0.0, radius=RADIUS, SNR=20):
    """ create a two particle state and compare it to featuring using a single particle guess """
    # create a base image of one particle
    s = init.create_two_particle_state(imsize=6 * radius + 4,
                                       axis='x',
                                       sigma=1.0 / SNR,
                                       delta=separation,
                                       radius=radius,
                                       stateargs={'varyn': True},
                                       psfargs={'error': 1e-6})
    s.obj.typ[1] = 0.
    s.reset()

    return s, s.obj.pos.copy()
示例#2
0
def fit_two_particle_separation(separation,
                                radius=5.0,
                                samples=100,
                                imsize=64,
                                sigma=0.05):
    terrors = []
    berrors = []
    crbs = []

    for sep in separation:
        print '=' * 79
        print 'sep =', sep

        s = init.create_two_particle_state(imsize,
                                           radius=radius,
                                           delta=sep,
                                           sigma=0.05,
                                           axis='z')
        p = s.state[s.b_pos].reshape(-1, 3).copy()

        bl = s.explode(s.b_pos)
        crbs.append(
            np.sqrt(np.diag(np.linalg.inv(
                s.fisher_information(blocks=bl)))).reshape(-1, 3))
        tmp_tp, tmp_bf = [], []
        for i in xrange(samples):
            print i
            bench.jiggle_particles(s, pos=p)
            t = bench.trackpy(s)
            b = bench.bamfpy_positions(s, sweeps=30)

            tmp_tp.append(bench.error(s, t))
            tmp_bf.append(bench.error(s, b))
        terrors.append(tmp_tp)
        berrors.append(tmp_bf)

    return np.array(crbs), np.array(terrors), np.array(berrors)
示例#3
0
# the final answers, crbs and stds
crbs = []
stds = []
hists = []

# options for the size distribution
deltas = np.logspace(-3, 0, 10)
deltas2 = np.logspace(-3, 0, 5)

for delta in deltas:
    print "Delta", delta

    # create a single particle state and get pos/rad blocks
    s = init.create_two_particle_state(imsize=64,
                                       radius=radius,
                                       delta=delta,
                                       sigma=sigma,
                                       psfargs=(3, 6),
                                       stateargs={"doprior": False})
    print s.obj.pos
    blocks = s.blocks_particle(0)

    crb = []
    for block in blocks:
        crb.append(s.fisher_information([block])[0, 0])
    crbs.append(crb)

for delta in deltas2:
    print "Delta", delta

    # create a single particle state and get pos/rad blocks
    s = init.create_two_particle_state(imsize=64,
示例#4
0
def fit_edge(separation,
             radius=5.0,
             samples=100,
             imsize=64,
             sigma=0.05,
             axis='z'):
    """
    axis is 'z' or 'xy'
    seps = np.linspace(0,2,20) 'z'
    seps = np.linspace(-2,2,20) 'xy'
    """
    terrors = []
    berrors = []
    crbs = []

    for sep in separation:
        print '=' * 79
        print 'sep =', sep,

        s = init.create_two_particle_state(imsize,
                                           radius=radius,
                                           delta=sep,
                                           sigma=0.05,
                                           axis='z',
                                           psfargs={
                                               'params': (2.0, 1.0, 4.0),
                                               'error': 1e-8
                                           },
                                           stateargs={
                                               'sigmapad': True,
                                               'pad': const.PAD
                                           })

        # move off of a pixel edge (cheating for trackpy)
        d = np.array([0, 0.5, 0.5])
        s.obj.pos -= d
        s.reset()

        # move the particles to the edge
        bl = s.blocks_particle(0)
        s.update(bl[0], np.array([s.pad + radius]))

        bl = s.blocks_particle(1)
        s.update(bl[0], np.array([s.pad - radius]))

        if axis == 'z':
            bl = s.blocks_particle(1)
            s.update(bl[0], s.state[bl[0]] - sep)
            s.model_to_true_image()

        if axis == 'xy':
            bl = s.blocks_particle(1)
            s.update(bl[2], s.state[bl[2]] + sep)
            s.model_to_true_image()

        # save where the particles were originally so we can jiggle
        p = s.state[s.b_pos].reshape(-1, 3).copy()

        print p[0], p[1]
        # calculate the CRB for this configuration
        bl = s.explode(s.b_pos)
        crbs.append(
            np.sqrt(np.diag(np.linalg.inv(
                s.fisher_information(blocks=bl)))).reshape(-1, 3))

        # calculate the featuring errors
        tmp_tp, tmp_bf = [], []
        for i in xrange(samples):
            print i
            bench.jiggle_particles(s, pos=p, sig=0.3, mask=np.array([1, 1, 1]))
            t = bench.trackpy(s)
            b = bench.bamfpy_positions(s, sweeps=15)

            tmp_tp.append(bench.error(s, t))
            tmp_bf.append(bench.error(s, b))
        terrors.append(tmp_tp)
        berrors.append(tmp_bf)

    return np.array(crbs), np.array(terrors), np.array(berrors)