glm

Runs classical General Linear Model analysis for task-evoked fMRI activation and group-level inference.

89|5|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill glm-cuhk-aim-group
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: glm
Source: https://github.com/CUHK-AIM-Group/NeuroDiscovery/tree/main/skills/glm
Command: npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill glm-cuhk-aim-group

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires nilearn.

What problem does it solve? Researchers analyzing task-based fMRI need a rigorous statistical route to detect brain activation, but building design matrices, fitting first-level and second-level GLMs, and generating contrast maps requires coordinating multiple neuroimaging tools. This Skill provides model-level guidance for running classical GLM workflows on preprocessed task fMRI data. ## Core Features & Use Cases - First-Level GLM: Builds design matrices from events and confounds, fits subject/session-level models, and computes named contrasts such as task > baseline. - Second-Level GLM: Performs group-level inference across subjects using one-sample, two-sample, or covariate-adjusted design matrices, producing group z maps and statistical summaries. - Use Case: A neuroimaging researcher with preprocessed BOLD data and event timing files for 30 subjects uses this Skill to compute per-subject contrast maps, then runs a second-level analysis to identify group-level activation differences between conditions. ## Quick Start Ask the assistant to run a first-level GLM on your preprocessed task fMRI data with your events file and TR, producing contrast and z maps in the output directory.

Frequently Asked Questions about glm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a first-level GLM on task fMRI data?

Provide a preprocessed BOLD image, an events file with onset, duration, and trial type, and the repetition time. The workflow builds a design matrix, fits the GLM per subject or session, and exports contrast and z maps via nilearn.

How do I perform second-level group analysis in fMRI?

Collect first-level contrast maps from all subjects and supply a group design matrix for one-sample, two-sample, or covariate models. The second-level GLM fits across subjects and produces group z maps, thresholded figures, and statistical summaries.

When should I use GLM instead of deep learning for fMRI analysis?

Use GLM when the goal is statistical inference on task conditions or contrasts rather than phenotype prediction. It suits limited sample sizes, group-level inference, and studies requiring interpretable contrast maps or cluster-level reports.

What inputs are required for task fMRI GLM analysis?

Required inputs are a preprocessed task BOLD image, an events table with onset, duration, and condition labels, and the repetition time. Optional inputs include confounds tables, brain masks, and group design matrices for second-level analysis.

What are the limitations of GLM for fMRI analysis?

GLM is designed for task-fMRI, not resting-state phenotype modeling. Results are sensitive to event timing quality, motion confounds, and preprocessing choices, and group inference requires consistent first-level contrast definitions across subjects.