def clusterQuality(self, cluster, fet=1):
    '\n        returns the L-ratio and Isolation Distance measures\n        calculated on the principal components of the energy in a spike matrix\n        '
    if (self.waveforms is None):
        return None
    (nSpikes, nElectrodes, _) = self.waveforms.shape
    wvs = self.waveforms.copy()
    E = np.sqrt(np.nansum((self.waveforms ** 2), axis=2))
    zeroIdx = (np.sum(E, 0) == [0, 0, 0, 0])
    E = E[:, (~ zeroIdx)]
    wvs = wvs[:, (~ zeroIdx), :]
    normdWaves = (wvs.T / E.T).T
    PCA_m = self.getParam(normdWaves, 'PCA', fet=fet)
    badIdx = (np.sum(PCA_m, axis=0) == 0)
    PCA_m = PCA_m[:, (~ badIdx)]
    idx = (self.spk_clusters == cluster)
    nClustSpikes = np.count_nonzero(idx)
    try:
        d = self._mahal(PCA_m, PCA_m[idx, :])
        M_noise = d[(~ idx)]
        df = np.prod((fet, nElectrodes))
        from scipy import stats
        L = np.sum((1 - stats.chi2.cdf(M_noise, df)))
        L_ratio = (L / nClustSpikes)
        if (nClustSpikes < (nSpikes / 2)):
            M_noise.sort()
            isolation_dist = M_noise[nClustSpikes]
        else:
            isolation_dist = np.nan
    except Exception:
        isolation_dist = L_ratio = np.nan
    return (L_ratio, isolation_dist)
returns the L-ratio and Isolation Distance measures
calculated on the principal components of the energy in a spike matrix
def clusterQuality(self, cluster, fet=1):
    '\n        returns the L-ratio and Isolation Distance measures\n        calculated on the principal components of the energy in a spike matrix\n        '
    if (self.waveforms is None):
        return None
    (nSpikes, nElectrodes, _) = self.waveforms.shape
    wvs = self.waveforms.copy()
    E = np.sqrt(np.nansum((self.waveforms ** 2), axis=2))
    zeroIdx = (np.sum(E, 0) == [0, 0, 0, 0])
    E = E[:, (~ zeroIdx)]
    wvs = wvs[:, (~ zeroIdx), :]
    normdWaves = (wvs.T / E.T).T
    PCA_m = self.getParam(normdWaves, 'PCA', fet=fet)
    badIdx = (np.sum(PCA_m, axis=0) == 0)
    PCA_m = PCA_m[:, (~ badIdx)]
    idx = (self.spk_clusters == cluster)
    nClustSpikes = np.count_nonzero(idx)
    try:
        d = self._mahal(PCA_m, PCA_m[idx, :])
        M_noise = d[(~ idx)]
        df = np.prod((fet, nElectrodes))
        from scipy import stats
        L = np.sum((1 - stats.chi2.cdf(M_noise, df)))
        L_ratio = (L / nClustSpikes)
        if (nClustSpikes < (nSpikes / 2)):
            M_noise.sort()
            isolation_dist = M_noise[nClustSpikes]
        else:
            isolation_dist = np.nan
    except Exception:
        isolation_dist = L_ratio = np.nan
    return (L_ratio, isolation_dist)