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))
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))
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
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
def avg_bivariate_binary_orderability_from_temporal_mean(temporalMeans2D): return np.nanmean( offdiag_1D( bivariate_orderability_from_temporal_mean(temporalMeans2D, {})))
def avg_bivariate_binary_orderability_3D_non_uniform(data2DLst, settings): return np.nanmean( offdiag_1D( bivariate_binary_orderability_3D_non_uniform(data2DLst, settings)))
def avg_bivariate_binary_orderability_3D(data, settings): return np.nanmean( offdiag_1D(bivariate_binary_orderability_3D(data, settings)))
def avg_corr_3D_non_uniform(dataLst, settings): M = corr_3D_non_uniform(dataLst, settings) return np.nanmean(np.abs(offdiag_1D(M)))
def avg_corr_3D(data, settings): M = corr_3D(data, settings) return np.nanmean(np.abs(offdiag_1D(M)))