What This Homework Is Really Asking
1st Level
- One subject.
- One run.
- Voxelwise GLM.
- Compares measured BOLD to predicted BOLD.
- Produces
cope,varcope, andzstatimages.
2nd Level
- One subject.
- Multiple runs.
- Combines run 01 and run 02.
- Usually fixed effects.
- Produces one average subject-level effect per contrast.
3rd Level
- All subjects.
- Group model.
- Tests whether the average subject-level effect is reliable.
- Usually mixed effects.
- Produces group-level statistical maps.
Full Workflow
One sentence version
Use first-level FEAT outputs from each run, average the two runs within each subject at the second level, then test the group mean effect across subjects at the third level.
Step-by-step analysis map
- Copy course derivatives to your scratch folder.
- Set up the Alpine SLURM environment before opening FSL.
- Open FSL FEAT.
- Use already-created first-level FEAT folders as inputs.
- Run second-level FEAT to combine run 01 and run 02 within each subject.
- Run third-level FEAT to test the group effect across participants.
- Open the third-level FEAT report.
- Use the thresholded group output and cluster report to describe the result.
- Write the methods section using the acquisition, task design, preprocessing, first-level model, and group analysis details.
What you are defending in the homework
- You used a valid fMRI acquisition protocol.
- You modeled an event-related Flanker task.
- You preprocessed images before statistical modeling.
- You modeled BOLD responses with a GLM and HRF.
- You handled temporal autocorrelation with prewhitening.
- You combined runs before making group-level claims.
- You tested group consistency across participants.
- You used corrected whole-brain inference, if that is what your FEAT report used.
Paths and Files
Copy the course derivatives
cp -R /pl/active/courses/2026_summer/neuroclass2026/flanker/bids/derivatives /scratch/alpine/$USER/flanker/bids/
What this command does
cpmeans copy.-Rmeans copy the folder recursively.- The first path is the shared course derivative folder.
- The second path is your personal scratch folder.
$USERautomatically fills in your CU username.
Check that the data copied
cd /scratch/alpine/$USER/flanker/bids
ls
ls derivatives
find derivatives -maxdepth 3 -type d | head
find derivatives -name "*.feat" | head
find derivatives -name "cope*.nii.gz" | head
Example file structure
/scratch/alpine/$USER/flanker/bids/
derivatives/
sub-01/
run-01.feat/
run-02.feat/
sub-02/
run-01.feat/
run-02.feat/
sub-03/
run-01.feat/
run-02.feat/
find derivatives -name "*.feat" to locate the actual first-level folders.
Files that matter for the homework
| File or folder | What it means | Why it matters |
|---|---|---|
.feat folder |
One FEAT analysis output. | Contains the model, registration, and statistics. |
design.mat |
Design matrix. | Shows the predictors in the GLM. |
design.con |
Contrast file. | Shows which comparisons were tested. |
stats/cope*.nii.gz |
Contrast estimate image. | This is the estimated effect for a contrast. |
stats/varcope*.nii.gz |
Variance image. | Needed for higher-level modeling. |
stats/zstat*.nii.gz |
Z statistic image. | Shows statistical strength for the contrast. |
report.html |
FEAT report. | Use this to check settings, thresholds, and results. |
HPC and FSL Setup
Run these before opening FSL
module load slurm/alpine
export FSL_SLURM_UCB_ACCOUNT=ucb-general
export FSL_SLURM_PARTITION_NAME=amilan
export FSL_SLURM_QUEUE_NAME=normal
export FSL_SLURM_NUM_CPU=2
export FSL_SLURM_WALLTIME_MINUTES=1440
export FSL_SLURM_MB_RAM=16G
What each line means
module load slurm/alpine: loads the SLURM scheduler tools for Alpine.FSL_SLURM_UCB_ACCOUNT: tells FSL which CU account to use.FSL_SLURM_PARTITION_NAME: tells FSL which partition to submit jobs to.FSL_SLURM_QUEUE_NAME: tells FSL which queue to use.FSL_SLURM_NUM_CPU=2: requests 2 CPUs.FSL_SLURM_WALLTIME_MINUTES=1440: requests 24 hours.FSL_SLURM_MB_RAM=16G: requests 16 GB of RAM.
Open FSL
fsl &
Check jobs
squeue -u $USER
sacct -u $USER --format=JobID,JobName,State,Elapsed,MaxRSS
seff JOBID
1st Level Analysis
What the first level asks
- Does the measured BOLD signal match the predicted task response?
- Which voxels respond to congruent trials?
- Which voxels respond to incongruent trials?
- Which voxels respond more to incongruent than congruent trials?
Model idea
Measured BOLD =
beta for congruent predictor
+ beta for incongruent predictor
+ nuisance regressors
+ residual error
What the predictors mean
- Congruent event timing is turned into a predicted BOLD response.
- Incongruent event timing is turned into a predicted BOLD response.
- Each predicted response is convolved with the HRF.
- The GLM estimates how strongly each voxel follows each predicted response.
Core contrast examples
| Contrast | Plain-English question | Interpretation |
|---|---|---|
| Congruent | Where does BOLD increase during congruent trials? | Task response for easier trials. |
| Incongruent | Where does BOLD increase during incongruent trials? | Task response for conflict trials. |
| Incongruent greater than Congruent | Where is BOLD greater for conflict trials? | Regions more engaged by response conflict. |
| Congruent greater than Incongruent | Where is BOLD greater for easier trials? | Regions more active for congruent than incongruent trials. |
2nd Level Analysis
Why second level exists
- The dataset has two runs.
- Run 01 and run 02 are intended to measure the same task processes.
- Using only run 01 ignores half the task data.
- Combining runs improves the stability of each subject's estimate.
- The second level produces one subject-level effect for each contrast.
FSL FEAT settings
- Select Higher-level analysis.
- Use lower-level FEAT directories as inputs.
- Input run 01 and run 02 first-level FEAT folders.
- Use the same contrast number across runs.
- Use fixed effects for within-subject run averaging.
- Save an output such as
sub-01_2ndlevel.gfeat.
Command to find first-level FEAT folders
cd /scratch/alpine/$USER/flanker/bids/derivatives
find $PWD -name "*.feat" | sort -V
Conceptual model
Subject 01:
run 01 incongruent greater than congruent cope
+ run 02 incongruent greater than congruent cope
= subject 01 average incongruent greater than congruent cope
cope3 is Incongruent greater than Congruent in run 01, make sure cope3 is the same contrast in run 02 and for every subject.
3rd Level Analysis
What the third level asks
- Is the average group effect reliably different from zero?
- Do participants show a consistent BOLD response for the contrast?
- Are there clusters where incongruent trials reliably produce stronger BOLD signal than congruent trials?
FSL FEAT settings
- Select Higher-level analysis.
- Use 3D cope images from the second-level outputs.
- Input one subject-level cope per subject.
- Use a one-group mean model for a basic group effect.
- Use mixed effects if specified by the course, commonly FLAME 1.
- Use the correction settings from the course FEAT design.
Conceptual model
Group analysis:
sub-01 subject-level cope
sub-02 subject-level cope
sub-03 subject-level cope
...
sub-26 subject-level cope
Question:
Is the mean cope across subjects greater than zero?
Example path search
find /scratch/alpine/$USER/flanker/bids/derivatives -path "*cope3.feat/stats/cope*.nii.gz" | sort -V
Best one-sentence interpretation
The third-level model tests whether the subject-level contrast estimates are consistent enough across participants to support a group-level inference.
Outputs and Interpretation
Most important third-level files
| Output | Meaning | Use in homework? |
|---|---|---|
stats/cope1.nii.gz |
Group mean contrast estimate. | Yes, this is the group effect image. |
stats/zstat1.nii.gz |
Group z statistic image. | Yes, this shows statistical strength. |
thresh_zstat1.nii.gz |
Thresholded z statistic image. | Yes, this is the corrected result map. |
cluster_mask_zstat1.nii.gz |
Mask of significant clusters. | Yes, if describing clusters. |
rendered_thresh_zstat1.png |
Picture of thresholded results. | Useful for visual inspection. |
report.html |
FEAT report page. | Yes, use it to verify model and thresholds. |
How to explain a significant result
- The group showed stronger BOLD response for incongruent than congruent trials.
- The effect survived the correction method used in the FEAT output.
- The result suggests consistent conflict-related task response across participants.
- The exact anatomical label should come from your cluster table or atlas lookup.
How to explain a non-significant result
- The group model did not find reliable corrected clusters for that contrast.
- This does not mean there is no effect in any participant.
- It means the effect was not strong or consistent enough across subjects under the chosen threshold.
- You can still report the model, contrast, and thresholding approach.
Homework Answer Key
1. MRI Data Acquisition Methods
- Dataset: NYU Slow Flanker task, OpenNeuro ds000102.
- Scanner: Siemens Allegra 3.0 T scanner.
- Functional sequence: 2D echo planar imaging.
- Functional runs: two task runs.
- Volumes: 146 functional volumes per run.
- TR: 2000 ms.
- TE: 30 ms.
- Flip angle: 80 degrees.
- Slices: 40.
- Matrix: 64 by 64.
- Field of view: 192 mm.
- Voxel size: 3 by 3 by 4 mm.
- Structural sequence: high-resolution T1-weighted MPRAGE.
- Structural TR: 2500 ms.
- Structural TE: 3.93 ms.
- Structural TI: 900 ms.
- Structural flip angle: 8 degrees.
- Structural slices: 176.
- Structural FOV: 256 mm.
2. Experimental Design
- Task: Eriksen Flanker task.
- Design type: slow event-related design.
- Participants responded to the direction of the central arrow.
- Congruent condition: flankers pointed in the same direction as the central arrow.
- Incongruent condition: flankers pointed in the opposite direction from the central arrow.
- Runs: two five-minute functional runs.
- Trials per run: 12 congruent and 12 incongruent trials.
- Trial order: pseudorandom.
- Intertrial interval: 8 to 14 seconds.
- Mean intertrial interval: 12 seconds.
- Main contrast: Incongruent greater than Congruent.
3. Image Preprocessing Methods
- Software: FSL FEAT.
- Brain extraction.
- Motion correction.
- Slice timing correction, if enabled in the course FEAT setup.
- Spatial smoothing.
- Temporal high-pass filtering.
- Registration from functional to anatomical image.
- Registration from anatomical to standard space.
- Motion and registration outputs should be inspected for quality control.
- Any nuisance regressors included in the actual FEAT design should be reported.
4. Statistical Methods
- First-level model: voxelwise general linear model.
- Modeled separately for each subject and each run.
- Predictors: congruent and incongruent event timing regressors.
- Task timing was convolved with a hemodynamic response function.
- Beta values estimated the size of each condition response at each voxel.
- Contrasts tested condition effects and condition differences.
- Main contrast: Incongruent greater than Congruent.
- FILM prewhitening corrected for temporal autocorrelation.
- Temporal derivatives were included if specified in the FEAT design.
- Higher-level analyses used the cope and varcope images from lower-level models.
5. Group Analysis
- Second level: combined run 01 and run 02 within each subject.
- Second-level model: fixed effects, because runs are repeated measurements within the same subject.
- Third level: tested the group mean effect across subjects.
- Third-level model: one-sample group model.
- Input to third level: one subject-level cope image per subject.
- Primary analysis: whole-brain voxelwise analysis.
- Correction: use the cluster-correction threshold reported in your actual FEAT report.
- Result interpretation: significant clusters show where the group had reliable task-related BOLD differences for the contrast.
Methods Section Draft
MRI data acquisition
Functional MRI data were taken from the NYU Slow Flanker dataset. Functional images were acquired on a Siemens Allegra 3.0 T scanner using a 2D echo planar imaging sequence. Each task run included 146 whole-brain functional volumes with TR = 2000 ms, TE = 30 ms, flip angle = 80 degrees, 40 slices, matrix = 64 by 64, FOV = 192 mm, and voxel size = 3 by 3 by 4 mm. A high-resolution T1-weighted MPRAGE anatomical image was also acquired with TR = 2500 ms, TE = 3.93 ms, TI = 900 ms, flip angle = 8 degrees, 176 slices, and FOV = 256 mm.
Experimental design
Participants completed a slow event-related Eriksen Flanker task during fMRI. On each trial, participants indicated the direction of a central arrow while ignoring flanking arrows. Congruent trials had flankers pointing in the same direction as the central arrow. Incongruent trials had flankers pointing in the opposite direction, increasing response conflict. Participants completed two five-minute runs. Each run included 12 congruent and 12 incongruent trials presented in pseudorandom order. The intertrial interval varied from 8 to 14 seconds, with a mean of 12 seconds.
Image preprocessing
Functional data were preprocessed using FSL FEAT. Preprocessing included brain extraction, motion correction, spatial smoothing, temporal high-pass filtering, and registration of functional images to each participant's anatomical image and to standard space. Slice timing correction and nuisance regressors should be reported if they were included in the course FEAT design. Motion, brain extraction, and registration outputs were inspected as part of quality control.
First-level statistical analysis
First-level analyses were conducted separately for each participant and run using a voxelwise general linear model in FSL FEAT. Congruent and incongruent event timings were modeled as explanatory variables and convolved with a hemodynamic response function to create predicted BOLD regressors. The model estimated condition-specific beta coefficients at each voxel. Contrasts included Congruent, Incongruent, and Incongruent greater than Congruent. FILM prewhitening was used to account for temporal autocorrelation in the fMRI time series. Temporal derivatives were included if specified in the FEAT model.
Higher-level group analysis
Higher-level analyses were performed in FSL FEAT. At the second level, run 01 and run 02 contrast estimates were combined within each participant using a fixed effects model. This produced one subject-level estimate for each contrast. At the third level, subject-level contrast estimates were entered into a group model to test whether the average effect was reliably different from zero across participants. The primary group contrast was Incongruent greater than Congruent. Group results were evaluated using whole-brain voxelwise inference with the correction settings reported in the third-level FEAT output.
Short version for a tighter submission
Functional MRI data from the NYU Slow Flanker dataset were analyzed using FSL FEAT. Participants completed two five-minute runs of a slow event-related Eriksen Flanker task with congruent and incongruent trials. Functional images were acquired on a Siemens Allegra 3.0 T scanner using echo planar imaging with TR = 2000 ms, TE = 30 ms, flip angle = 80 degrees, 40 slices, matrix = 64 by 64, FOV = 192 mm, and voxel size = 3 by 3 by 4 mm. A high-resolution T1-weighted MPRAGE image was also acquired.
Functional images were preprocessed using FSL FEAT, including brain extraction, motion correction, spatial smoothing, temporal high-pass filtering, and registration to anatomical and standard space images. First-level analyses modeled each run separately using a voxelwise GLM. Congruent and incongruent event timings were convolved with an HRF to create predicted BOLD regressors. Contrasts included Congruent, Incongruent, and Incongruent greater than Congruent. FILM prewhitening was used to account for temporal autocorrelation. Second-level fixed effects models averaged run-specific contrast estimates within participants, and third-level group analyses tested whether subject-level contrast estimates were reliably different from zero across participants.
Final Checklist
Before writing
- Open your actual FEAT report.
- Confirm the contrast number for Incongruent greater than Congruent.
- Confirm whether slice timing correction was used.
- Confirm the smoothing kernel.
- Confirm the high-pass filter value.
- Confirm the group threshold.
Before submitting
- State that the design is event-related.
- Include both runs.
- Separate first, second, and third level clearly.
- Do not say group analysis was run on raw BOLD data.
- Do not say the contrast proves causation.
- Use the exact threshold from your FEAT output.
Key Terms
| Term | Plain meaning |
|---|---|
| BOLD | The fMRI signal that indirectly reflects changes in blood oxygenation related to neural activity. |
| HRF | The expected shape of the BOLD response after a brief event. |
| GLM | A regression model used to estimate how much each predictor explains the voxel time series. |
| Beta | The estimated size of a predictor's effect at a voxel. |
| Contrast | A statistical comparison between beta estimates. |
| COPE | Contrast of parameter estimates, the estimated effect image for a contrast. |
| VARCOPE | The estimated variance of the contrast image. |
| ZSTAT | The z statistic image for a contrast. |
| Fixed effects | A model used here to combine runs within a subject. |
| Mixed effects | A model used to support group inference across participants. |
| Cluster correction | A method for correcting whole-brain statistical maps for many voxelwise tests. |