nilearn.glm: Generalized Linear Models#

Analysing fMRI data using GLMs.


Contrast(effect, variance[, dim, dof, ...])

The contrast class handles the estimation of statistical contrasts on a given model: student (t) or Fisher (F).

FContrastResults(effect, covariance, F, df_num)

Results from an F contrast of coefficients in a parametric model.

TContrastResults(t, sd, effect[, df_den])

Results from a t contrast of coefficients in a parametric model.

ARModel(design, rho)

A regression model with an AR(p) covariance structure.


A simple ordinary least squares model.

LikelihoodModelResults(theta, Y, model[, ...])

Class to contain results from likelihood models.

RegressionResults(theta, Y, model, ...[, ...])

Summarize the fit of a linear regression model.


Contain only information of the model fit necessary for contrast computation.


compute_contrast(labels, regression_result, ...)

Compute the specified contrast given an estimated glm.

compute_fixed_effects(contrast_imgs, ...[, ...])

Compute the fixed effects, given images of effects and variance.

expression_to_contrast_vector(expression, ...)

Convert a string describing a contrast to a contrast vector.

fdr_threshold(z_vals, alpha)

Return the Benjamini-Hochberg FDR threshold for the input z_vals.

cluster_level_inference(stat_img[, ...])

Report the proportion of active voxels for all clusters defined by the input threshold.

threshold_stats_img([stat_img, mask_img, ...])

Compute the required threshold level and return the thresholded map.



FirstLevelModel([t_r, slice_time_ref, ...])

Implement the General Linear Model for single run fMRI data.



Check that the provided DataFrame is indeed a valid design matrix descriptor, and returns a triplet of fields.

compute_regressor(exp_condition, hrf_model, ...)

Convolve regressors with HRF model.

first_level_from_bids(dataset_path, task_label)

Create FirstLevelModel objects and fit arguments from a BIDS dataset.

glover_dispersion_derivative(tr[, ...])

Implement the Glover dispersion derivative HRF model.

glover_hrf(tr[, oversampling, time_length, ...])

Implement the Glover HRF model.

glover_time_derivative(tr[, oversampling, ...])

Implement the Glover time derivative HRF (dhrf) model.


Generate a design matrix from the input parameters.

mean_scaling(Y[, axis])

Scaling of the data to have percent of baseline change along the specified axis.

run_glm(Y, X[, noise_model, bins, n_jobs, ...])

GLM fit for an fMRI data matrix.

spm_dispersion_derivative(tr[, ...])

Implement the SPM dispersion derivative HRF model.

spm_hrf(tr[, oversampling, time_length, onset])

Implement the SPM HRF model.

spm_time_derivative(tr[, oversampling, ...])

Implement the SPM time derivative HRF (dhrf) model.



SecondLevelModel([mask_img, target_affine, ...])

Implement the General Linear Model for multiple subject fMRI data.



Set up a second level design.


Generate p-values corresponding to the contrasts provided based on permutation testing.