brainstat.stats.SLM.SLM

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

Bases: object

Core Class for running BrainStat linear models

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

Constructor for the SLM class.

Parameters
  • model (brainstat.stats.terms.FixedEffect, brainstat.stats.terms.MixedEffect) – The linear model to be fitted of dimensions (observations, predictors). Note that, for volumetric input, BrainStat follows Fortran (MATLAB) convention for ordering voxels, i.e. the first dimension changes first.

  • contrast (array-like) – Vector of contrasts in the observations.

  • surf (str, dict, BSPolyData, Nifti1Image, 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, a string containing a template name accepted by fetch_template_surface, or a Nifti1Image wherein 0 denotes excluded voxels and any other value denotes included voxels, by default None.

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

  • correction (str, Sequence, optional) – String or sequence 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.

  • 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.

  • data_dir (str, pathlib.Path, optional) – Path to the location to store BrainStat data files, defaults to $HOME_DIR/brainstat_data.

Methods

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

Constructor for the SLM class.

fit(Y)

Fits the SLM model

multiple_comparison_corrections(student_t_test)

Performs multiple comparisons corrections.

qc([Y, feat, v, histo, qq])

Quality check of the data (author: @saratheriver) :param Y: Input data (observation, vertex, variate) :type Y: numpy.array :param feat: Dimension of variate to qc.

Attributes

lat

surf

tri

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.

multiple_comparison_corrections(student_t_test)[source]

Performs multiple comparisons corrections. If a (one-sided) student-t test was run, then make it two-tailed if requested.

qc(Y=None, feat=None, v=None, histo=True, qq=True)[source]

Quality check of the data (author: @saratheriver) :param Y: Input data (observation, vertex, variate) :type Y: numpy.array :param feat: Dimension of variate to qc. Default is 0 - assuming 2D matrix. :type feat: numpy.array, optional :param v: specify vertex or parcel number. Default to all. :type v: numpy.array, optional :param histo: Outputs histogram of the residuals. Default is True. :type histo: bool, optional :param qq: Outputs qq plot of the residuals. Default is True. :type qq: bool, optional

Returns

  • sk (ndarray) – Skewness of residuals distribution

  • ku (ndarray) – Kurtosis of residuals distribution