def altCDF(peaks, mu, sigma=None, exc=None, method="RFT"): """ Returns the CDF of the alternative peak distribution Parameters ---------- peaks : :obj:`numpy.ndarray` List of peak heights (z-values). mu : :obj:`float` Mean from fitted normal distribution. sigma : :obj:`float` Standard deviation from fitted normal distribution. exc : :obj:`float`, optional Z-threshold (excursion threshold) method : {'RFT', 'CS'}, optional Multiple comparisons correction method. Returns ------- Fa : :obj:`numpy.ndarray` Cumulative density of the peak heights under Ha. """ peaks = np.asarray(peaks) if method == 'RFT': ksi = (peaks - mu) / sigma alpha = (exc - mu) / sigma Fa = (norm.cdf(ksi) - norm.cdf(alpha)) / (1 - norm.cdf(alpha)) elif method == 'CS': Fa = np.array([ integrate.quad(lambda x: peakdistribution.peakdens3D(x, 1), -20, y)[0] for y in peaks - mu ]) else: raise ValueError('Argument `method` must be either "RFT" or "CS"') return Fa
def altPDF(peaks,mu,sigma=None,exc=None,method="RFT"): """ altPDF: Returns probability density using a truncated normal distribution that we define as the distribution of local maxima in a GRF under the alternative hypothesis of activation parameters ---------- peaks: float or list of floats list of peak heigths mu: sigma: returns ------- fa: float or list probability density of the peaks heights under Ha """ #Returns probability density of the alternative peak distribution peaks = np.asarray(peaks) if method == "RFT": # assert type(sigma) is in [float, int] # assert sigma is not None ksi = (peaks-mu)/sigma alpha = (exc-mu)/sigma num = 1/sigma * scipy.stats.norm.pdf(ksi) den = 1. - scipy.stats.norm.cdf(alpha) fa = num/den elif method == "CS": fa = [peakdistribution.peakdens3D(y-mu,1) for y in peaks] return fa
def nulPDF(peaks, exc=None, method='RFT'): """ Returns probability density of the null peak distribution. Parameters ---------- peaks : :obj:`numpy.ndarray` List of peak heights (z-values). exc : :obj:`float`, optional Z-threshold (excursion threshold) method : {'RFT', 'CS'}, optional Multiple comparisons correction method. Returns ------- f0 : :obj:`numpy.ndarray` Probability density of the peaks heights under H0. """ peaks = np.asarray(peaks) if method == 'RFT': f0 = exc * np.exp(-exc * (peaks - exc)) elif method == 'CS': f0 = np.array([peakdistribution.peakdens3D(x, 1) for x in peaks]) else: raise ValueError('Argument `method` must be either "RFT" or "CS"') return f0
def _nulCDF(peaks, exc=None, method='RFT'): """ Returns the CDF of the null peak distribution. Parameters ---------- peaks : :obj:`numpy.ndarray` List of peak heights (z-values). exc : :obj:`float`, optional Z-threshold (excursion threshold) method : {'RFT', 'CS'}, optional Multiple comparisons correction method. Returns ------- F0 : :obj:`numpy.ndarray` Cumulative density of the peak heights under H0. """ peaks = np.asarray(peaks) if method == "RFT": F0 = 1 - np.exp(-exc * (peaks - exc)) elif method == "CS": F0 = np.array([ integrate.quad(lambda x: peakdistribution.peakdens3D(x, 1), -20, y)[0] for y in peaks ]) else: raise ValueError('Argument `method` must be either "RFT" or "CS"') return F0
def altPDF(peaks, mu, sigma=None, exc=None, method="RFT"): """ altPDF: Returns probability density using a truncated normal distribution that we define as the distribution of local maxima in a GRF under the alternative hypothesis of activation parameters ---------- peaks: float or list of floats list of peak heigths mu: sigma: returns ------- fa: float or list probability density of the peaks heights under Ha """ #Returns probability density of the alternative peak distribution peaks = np.asarray(peaks) if method == "RFT": # assert type(sigma) is in [float, int] # assert sigma is not None ksi = (peaks - mu) / sigma alpha = (exc - mu) / sigma num = 1 / sigma * scipy.stats.norm.pdf(ksi) den = 1. - scipy.stats.norm.cdf(alpha) fa = num / den elif method == "CS": fa = [peakdistribution.peakdens3D(y - mu, 1) for y in peaks] return fa
def nulCDF(peaks,exc=None,method="RFT"): # Returns the CDF of the null peak distribution peaks = np.asarray(peaks) if method == "RFT": F0 = 1-np.exp(-exc*(peaks-exc)) elif method == "CS": F0 = [integrate.quad(lambda x:peakdistribution.peakdens3D(x,1),-20,y)[0] for y in peaks] return F0
def nulPDF(peaks,exc=None,method="RFT"): #Returns probability density of the null peak distribution peaks = np.asarray(peaks) if method == "RFT": f0 = exc*np.exp(-exc*(peaks-exc)) elif method == "CS": f0 = [peakdistribution.peakdens3D(x,1) for x in peaks] return f0
def nulPDF(peaks, exc=None, method="RFT"): #Returns probability density of the null peak distribution peaks = np.asarray(peaks) if method == "RFT": f0 = exc * np.exp(-exc * (peaks - exc)) elif method == "CS": f0 = [peakdistribution.peakdens3D(x, 1) for x in peaks] return f0
def altCDF(peaks,mu,sigma=None,exc=None,method="RFT"): # Returns the CDF of the alternative peak distribution peaks = np.asarray(peaks) if method == "RFT": ksi = (peaks-mu)/sigma alpha = (exc-mu)/sigma Fa = (scipy.stats.norm.cdf(ksi) - scipy.stats.norm.cdf(alpha))/(1-scipy.stats.norm.cdf(alpha)) elif method == "CS": Fa = [integrate.quad(lambda x:peakdistribution.peakdens3D(x,1),-20,y)[0] for y in peaks-mu] return Fa
def nulCDF(peaks, exc=None, method="RFT"): # Returns the CDF of the null peak distribution peaks = np.asarray(peaks) if method == "RFT": F0 = 1 - np.exp(-exc * (peaks - exc)) elif method == "CS": F0 = [ integrate.quad(lambda x: peakdistribution.peakdens3D(x, 1), -20, y)[0] for y in peaks ] return F0
def altCDF(peaks, mu, sigma=None, exc=None, method="RFT"): # Returns the CDF of the alternative peak distribution peaks = np.asarray(peaks) if method == "RFT": ksi = (peaks - mu) / sigma alpha = (exc - mu) / sigma Fa = (scipy.stats.norm.cdf(ksi) - scipy.stats.norm.cdf(alpha)) / (1 - scipy.stats.norm.cdf(alpha)) elif method == "CS": Fa = [ integrate.quad(lambda x: peakdistribution.peakdens3D(x, 1), -20, y)[0] for y in peaks - mu ] return Fa
def altPDF(peaks, mu, sigma=None, exc=None, method='RFT'): """ Returns probability density using a truncated normal distribution that we define as the distribution of local maxima in a GRF under the alternative hypothesis of activation. Parameters ---------- peaks : :obj:`numpy.ndarray` List of peak heights (z-values). mu : :obj:`float` Mean from fitted normal distribution. sigma : :obj:`float` Standard deviation from fitted normal distribution. exc : :obj:`float`, optional Z-threshold (excursion threshold) method : {'RFT', 'CS'}, optional Multiple comparisons correction method. Returns ------- fa : :obj:`numpy.ndarray` Probability density of the peaks heights under Ha. """ # Returns probability density of the alternative peak distribution peaks = np.asarray(peaks) if method == 'RFT': ksi = (peaks - mu) / sigma alpha = (exc - mu) / sigma num = 1. / sigma * norm.pdf(ksi) den = 1. - norm.cdf(alpha) fa = num / den elif method == 'CS': fa = np.array([peakdistribution.peakdens3D(y - mu, 1) for y in peaks]) else: raise ValueError('Argument `method` must be either "RFT" or "CS"') return fa
def test_peakdistribution(self): x = peakdistribution.peakdens3D(2,1) self.assertEqual(np.around(x,decimals=2),0.48)
def test_peakdistribution(self): x = peakdistribution.peakdens3D(2, 1) self.assertEqual(np.around(x, decimals=2), 0.48)