Example #1
0
 def _aux(data, settings):
     mu, var = temporal_moments_3D(data, settings, axis=0).T
     pvals = _bivariate_student_orderability_from_moments(mu,
                                                          var,
                                                          len(data),
                                                          type="pval")
     return gmean(offdiag_1D(pvals))
Example #2
0
 def _aux(data2DLst, settings):
     # baselines = _get_baselines_non_uniform(data2DLst, settings)
     mu, var = temporal_moments_3D_non_uniform(data2DLst, settings,
                                               axis=0).T
     pvals = _bivariate_student_orderability_from_moments(mu,
                                                          var,
                                                          len(data2DLst),
                                                          type="pval")
     return gmean(offdiag_1D(pvals))
Example #3
0
def _bivariate_binary_orderability_from_moments(mu):
    '''
    For each pair of channels, decide which one is earlier by comparing their time courses, converted to CDF
    :param mu: 1D Array of temporal means for every channel
    :return: 2D array of shape [nCell, nCell],
    '''

    biasRowExtrude = np.tile(mu, (len(mu), 1))
    rez = biasRowExtrude - biasRowExtrude.T

    # Check that there are no off-diagonal differences that evaluated exactly to zero.
    assert np.sum(offdiag_1D(rez) == 0) == 0

    return rez > 0
Example #4
0
def cluster_values(M, clusters):
    '''
    :param M:          Distance matrix
    :param clusters:   Cluster labels
    :return:           Dictionary of metrics of cluster fidelity. Each metric computed for each cluster

    avgCorr - average in-cluster distance
    avgRelCorr - average in-cluster distance minus out-cluster distance
    '''

    rez = {'avgCorr': {}, 'avgRelCorr': {}}

    for iClust in sorted(set(clusters)):
        idxClust = clusters == iClust

        clustBlock = M[idxClust][:, idxClust]
        clustNonclustBlock = M[~idxClust][:, idxClust]

        muClust = np.mean(offdiag_1D(clustBlock))
        muNon = np.mean(clustNonclustBlock)
        rez['avgCorr'][iClust] = muClust
        rez['avgRelCorr'][iClust] = muClust - muNon
    return rez
Example #5
0
def avg_bivariate_binary_orderability_from_temporal_mean(temporalMeans2D):
    return np.nanmean(
        offdiag_1D(
            bivariate_orderability_from_temporal_mean(temporalMeans2D, {})))
Example #6
0
def avg_bivariate_binary_orderability_3D_non_uniform(data2DLst, settings):
    return np.nanmean(
        offdiag_1D(
            bivariate_binary_orderability_3D_non_uniform(data2DLst, settings)))
Example #7
0
def avg_bivariate_binary_orderability_3D(data, settings):
    return np.nanmean(
        offdiag_1D(bivariate_binary_orderability_3D(data, settings)))
Example #8
0
def avg_corr_3D_non_uniform(dataLst, settings):
    M = corr_3D_non_uniform(dataLst, settings)
    return np.nanmean(np.abs(offdiag_1D(M)))
Example #9
0
def avg_corr_3D(data, settings):
    M = corr_3D(data, settings)
    return np.nanmean(np.abs(offdiag_1D(M)))