コード例 #1
0
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
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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
コード例 #7
0
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
コード例 #8
0
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
コード例 #9
0
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
コード例 #10
0
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
コード例 #11
0
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
コード例 #12
0
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
コード例 #13
0
 def test_peakdistribution(self):
     x = peakdistribution.peakdens3D(2,1)
     self.assertEqual(np.around(x,decimals=2),0.48)
コード例 #14
0
 def test_peakdistribution(self):
     x = peakdistribution.peakdens3D(2, 1)
     self.assertEqual(np.around(x, decimals=2), 0.48)