brainstat.stats.SLM.SLM

class brainstat.stats.SLM.SLM(model, contrast, surf=None, mask=None, *, correction=None, niter=1, thetalim=0.01, drlim=0.1, two_tailed=True, cluster_threshold=0.001)[source]

Bases: object

Core Class for running BrainStat linear models

__init__(model, contrast, surf=None, mask=None, *, correction=None, niter=1, thetalim=0.01, drlim=0.1, two_tailed=True, cluster_threshold=0.001)[source]

Constructor for the SLM class.

Parameters
  • model (brainstat.stats.terms.Term) – The linear model to be fitted of dimensions (observations, predictors).

  • contrast (array-like, brainstat.stats.terms.Term) – Vector of contrasts in the observations.

  • surf (dict, BSPolyData, optional) – A surface provided as either a dictionary with keys ‘tri’ for its faces (n-by-3 array) and ‘coord’ for its coordinates (3-by-n array), or as a BrainSpace BSPolyData object by default None.

  • mask (array-like, optional) – A mask containing True for vertices to include in the analysis, by default None.

  • correction (str, list, optional) – String or list of strings. If it contains “rft” a random field theory multiple comparisons correction will be run. If it contains “fdr” a false discovery rate multiple comparisons correction will be run. Both may be provided. By default None.

  • niter (int, optional) – Number of iterations of the Fisher scoring algorithm for fitting mixed effects models, by default 1.

  • thetalim (float, optional) – Lower limit on variance coefficients in standard deviations, by default 0.01.

  • drlim (float, optional) – Step of ratio of variance coefficients in standard deviations, by default 0.1.

  • two_tailed (bool, optional) – Determines whether to return two-tailed or one-tailed p-values. Note that multivariate analyses can only be two-tailed, by default True.

  • cluster_threshold (float, optional) – P-value threshold or statistic threshold for defining clusters in random field theory, by default 0.001.

Methods

__init__(model, contrast[, surf, mask, ...])

Constructor for the SLM class.

fdr()

Q-values for False Discovey Rate of resels.

fit(Y)

Fits the SLM model

linear_model(Y)

Fits linear mixed effects models to surface data and estimates resels.

multiple_comparison_corrections()

Performs multiple comparisons corrections.

random_field_theory()

Corrected P-values for vertices and clusters.

t_test()

T statistics for a contrast in a univariate or multivariate model.

fdr()

Q-values for False Discovey Rate of resels.

Parameters

self (brainstat.stats.SLM.SLM) – SLM object with computed t-values.

Returns

numpy.array – Q-values for false discovery rate of resels.

fit(Y)[source]

Fits the SLM model

Parameters

Y (numpy.array) – Input data (observation, vertex, variate)

Raises

ValueError – An error will be thrown when multivariate data is provided and a one-tailed test is requested.

linear_model(Y)

Fits linear mixed effects models to surface data and estimates resels.

Parameters
multiple_comparison_corrections()[source]

Performs multiple comparisons corrections.

random_field_theory()

Corrected P-values for vertices and clusters. :param self: SLM object with computed t-values. :type self: brainstat.stats.SLM.SLM

Returns

  • pval (a dictionary with keys ‘P’, ‘C’, ‘mask’.) –

    pval[‘P’]2D numpy array of shape (1,v).

    Corrected P-values for vertices.

    pval[‘C’]2D numpy array of shape (1,v).

    Corrected P-values for clusters.

  • peak (a dictionary with keys ‘t’, ‘vertid’, ‘clusid’, ‘P’.) –

    peak[‘t’]2D numpy array of shape (np,1).

    Peaks (local maxima).

    peak[‘vertid’]2D numpy array of shape (np,1).

    Vertex.

    peak[‘clusid’]2D numpy array of shape (np,1).

    Cluster id numbers.

    peak[‘P’]2D numpy array of shape (np,1).

    Corrected P-values for the peak.

  • clus (a dictionary with keys ‘clusid’, ‘nverts’, ‘resels’, ‘P.’) –

    clus[‘clusid’]2D numpy array of shape (nc,1).

    Cluster id numbers

    clus[‘nverts’]2D numpy array of shape (nc,1).

    Number of vertices in cluster.

    clus[‘resels’]2D numpy array of shape (nc,1).

    resels in the cluster.

    clus[‘P’]2D numpy array of shape (nc,1).

    Corrected P-values for the cluster.

  • clusid (2D numpy array of shape (1,v).) – Cluster id’s for each vertex.

  • Reference (Worsley, K.J., Andermann, M., Koulis, T., MacDonald, D.)

  • & Evans, A.C. (1999). Detecting changes in nonisotropic images.

  • Human Brain Mapping, 8 (98-101.)

t_test()

T statistics for a contrast in a univariate or multivariate model.

Parameters

self (brainstat.stats.SLM.SLM) – SLM object that has already run linear_model