Inheritance diagram for nipy.modalities.fmri.glm:
This module presents an interface to use the glm implemented in nipy.algorithms.statistics.models.regression It contains the GLM and contrast classes that are meant to be the main objects of fMRI data analyses.
It is important to note that the GLM is meant as a one-session General Linear Model. But inference can be performed on multiple sessions by computing fixed effects on contrasts
>>> from nipy.modalities.fmri.glm import GeneralLinearModel
>>> import numpy as np
>>> n, p, q = 100, 80, 10
>>> X, Y = np.random.randn(p, q), np.random.randn(p, n)
>>> cval = np.hstack((1, np.zeros(9)))
>>> model = GeneralLinearModel(X)
>>> model.fit(Y)
>>> z_vals = model.contrast(cval).z_score() # z-transformed statistics
>>> # example of fixed effects statistics across two contrasts
>>> cval_ = cval.copy()
>>> np.random.shuffle(cval_)
>>> z_ffx = (model.contrast(cval) + model.contrast(cval_)).z_score()
Bases: object
The contrast class handles the estimation of statistical contrasts After application of the GLM. The important feature is that it supports addition, thus opening the possibility of fixed-effects models.
The current implementation is meant to be simple, and could be enhanced in the future on the computational side (high-dimensional F constrasts may lead to memory breakage)
Methods
p_value([baseline]) | Return a parametric estimate of the p-value associated |
stat([baseline]) | Return the decision statistic associated with the test of the |
z_score([baseline]) | Return a parametric estimation of the z-score associated |
Parameters : | effect: array of shape (contrast_dim, n_voxels) :
variance: array of shape (contrast_dim, contrast_dim, n_voxels) :
dof: scalar, the degrees of freedom : contrast_type: string to be chosen among ‘t’ and ‘F’ : |
---|
Return a parametric estimate of the p-value associated with the null hypothesis: (H0) ‘contrast equals baseline’
Parameters : | baseline: float, optional, : Baseline value for the test statistic : |
---|
Return the decision statistic associated with the test of the null hypothesis: (H0) ‘contrast equals baseline’
Parameters : | baseline: float, optional, :
|
---|
Return a parametric estimation of the z-score associated with the null hypothesis: (H0) ‘contrast equals baseline’
Parameters : | baseline: float, optional, :
|
---|
Bases: object
This class handles the so-called on General Linear Model
Most of what it does in the fit() and contrast() methods fit() performs the standard two-step (‘ols’ then ‘ar1’) GLM fitting contrast() returns a contrast instance, yileding statistics and p-values. The link between fit() and constrast is done vis the two class members: glm_results: dictionary of nipy.algorithms.statistics.models. regression.RegressionResults instances,
describing results of a GLM fit
Methods
contrast(con_val[, contrast_type]) | Specify and estimate a linear contrast |
fit(Y[, model, steps]) | GLM fitting of a dataset using ‘ols’ regression or the two-pass |
Parameters : | X: array of shape(n_time_points, n_regressors), :
|
---|
Specify and estimate a linear contrast
Parameters : | con_val: numpy.ndarray of shape (p) or (q, p), :
contrast_type: string, optional, either ‘t’ or ‘F’, :
|
---|---|
Returns : | con: Contrast instance : |
GLM fitting of a dataset using ‘ols’ regression or the two-pass
Parameters : | Y: array of shape(n_time_points, n_samples), the fMRI data : model: string, to be chosen in [‘ar1’, ‘ols’], optional, :
steps: int, optional, :
|
---|
Scaling of the data to have pourcent of baseline change columnwise
Parameters : | Y: array of shape(n_time_points, n_voxels) :
|
---|---|
Returns : | Y: array of shape(n_time_points, n_voxels), :
mean: array of shape(n_voxels), the data mean : |