Example #1
0
def execute_query_fast(hs, qdat, qcxs, dcxs):
    '''Executes a query and assumes qdat has all precomputed information'''
    # Nearest neighbors
    neighbs = mf.nearest_neighbors(hs, qcxs, qdat)
    # Nearest neighbors weighting and scoring
    weights, filt2_meta = mf.weight_neighbors(hs, neighbs, qdat)
    # Thresholding and weighting
    nnfiltFILT = mf.filter_neighbors(hs, neighbs, weights, qdat)
    # Nearest neighbors to chip matches
    matchesFILT = mf.build_chipmatches(hs, neighbs, nnfiltFILT, qdat)
    # Spatial verification
    matchesSVER = mf.spatial_verification(hs, matchesFILT, qdat)
    # Query results format
    result_list = [
        mf.chipmatch_to_resdict(hs, matchesSVER, filt2_meta, qdat),
    ]
    return result_list
Example #2
0
def execute_query_fast(hs, qdat, qcxs, dcxs):
    '''Executes a query and assumes qdat has all precomputed information'''
    # Nearest neighbors
    neighbs = mf.nearest_neighbors(hs, qcxs, qdat)
    # Nearest neighbors weighting and scoring
    weights, filt2_meta = mf.weight_neighbors(hs, neighbs, qdat)
    # Thresholding and weighting
    nnfiltFILT = mf.filter_neighbors(hs, neighbs, weights, qdat)
    # Nearest neighbors to chip matches
    matchesFILT = mf.build_chipmatches(hs, neighbs, nnfiltFILT, qdat)
    # Spatial verification
    matchesSVER = mf.spatial_verification(hs, matchesFILT, qdat)
    # Query results format
    result_list = [
        mf.chipmatch_to_resdict(hs, matchesSVER, filt2_meta, qdat),
    ]
    return result_list
Example #3
0
def get_qfx2_gtkrank(hs, qcx, q_cfg): 
    '''Finds how deep possibily correct matches are in the ANN structures'''
    import matching_functions as mf
    dx2_cx   = q_cfg.data_index.ax2_cx
    gt_cxs   = hs.get_other_cxs(qcx)
    qcx2_nns = mf.nearest_neighbors(hs, [qcx], q_cfg)
    filt2_weights = mf.weight_neighbors(hs, qcx2_nns, q_cfg)
    K = q_cfg.nn_cfg.K
    (qfx2_dx, _) = qcx2_nns[qcx]
    qfx2_weights = filt2_weights['lnbnn'][qcx]
    qfx2_cx = dx2_cx[qfx2_dx[:, 0:K]]
    qfx2_gt = np.in1d(qfx2_cx.flatten(), gt_cxs)
    qfx2_gt.shape = qfx2_cx.shape
    qfx2_gtkrank = np.array([helpers.npfind(isgt) for isgt in qfx2_gt])
    qfx2_gtkweight = [0 if rank == -1 else weights[rank] 
                      for weights, rank in zip(qfx2_weights, qfx2_gtkrank)]
    qfx2_gtkweight = np.array(qfx2_gtkweight)
    return qfx2_gtkrank, qfx2_gtkweight