metrics.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:xdesign 作者: tomography 项目源码 文件源码
def compute_PCC(A, B, masks=None):
    """Computes the Pearson product-moment correlation coefficients (PCC) for
    the two images.

    Parameters
    -------------
    A,B : ndarray
        The two images to be compared
    masks : list of ndarrays, optional
        If supplied, the data under each mask is computed separately.

    Returns
    ----------------
    covariances : array, list of arrays
    """
    covariances = []
    if masks is None:
        data = np.vstack((np.ravel(A), np.ravel(B)))
        return np.corrcoef(data)

    for m in masks:
        weights = m[m > 0]
        masked_B = B[m > 0]
        masked_A = A[m > 0]
        data = np.vstack((masked_A, masked_B))
        # covariances.append(np.cov(data,aweights=weights))
        covariances.append(np.corrcoef(data))

    return covariances
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号