[wiki:FsTutorial top] | [wiki:FsTutorial previous] | [wiki:FsTutorial/Visualization next]

PAGE UNDER CONSTRUCTION! DO NOT USE THIS FOR GROUP ANALYSIS!

Please continue to use our old [wiki:FsTutorial/GroupAnalysis tutorial] while we develop this!

FreeSurfer Tutorial: Group Analysis with QDEC

In this tutorial, you will learn how to perform statistical analysis of group surface-based data, including:BR

Assuming that all surface reconstruction has been completed for all subjects in the study, FreeSurfer's QDEC utility can be used to perform inter-subject/group averaging and inference on the cortical surface. QDEC uses mri_glmfit to model the data as a linear combination of effects related to variables of interest, confounds and errors, and permits statistical inferences to be made about effects of interest in relation to error variance. It also allows for certain permutation testing and other means for correcting for mutliple comparisons. For group analysis, this technique fits a general linear model (GLM) at each surface vertex to explain the data from all subjects in the study. In this section, a brief overview of linear modeling is presented and can be skipped if this material is already familiar. Other software packages have similar types of programs (e.g., FSL's GFEAT).

Introduction

BR QDEC BR Qdec is a single-binary application included in the Freesurfer distribution. QDEC is an acronym for Query, Design, Estimate, Contrast. It is intended to aid researchers in performing inter-subject / group averaging and inference on the morphometry data (cortical surface and volume) produced by the Freesurfer processing stream. Qdec is a GUI front-end to a 'statistics engine' (the mri_glmfit binary, included in Freesurfer, currently fills this role) intended to:

  1. select the subjects meeting the criteria under study
  2. generate the necessary input to the stats engine, which, for mri_glmfit, includes:
    1. a Design matrix (called X in the GLM equation) containing the explanatory variables,

    2. a parameter Estimate matrix (called A in the GLM equation), and

    3. the Contrast vector(s)

  3. generate and optionally display the output data and/or images

BR Linear Modeling overview BR Linear modeling describes the observed data as a linear combination of explanatory factors plus noise, and determines how well that description explains the data being analyzed. In order to understand how to perform group analysis in FreeSurfer, you need to understand the general linear model (GLM) and how to construct a GLM in matrix notation. You can click [wiki:FsTutorial/GlmReview here] for a review of this material. The notation we use here is:y=X*beta, where y is the vector observed data (e.g., thicknesses for each subject at a vertex), X is the known design matrix (e.g., gender, age), and beta is the vector of unknown parameter estimates (PEs). The interpretation of the PEs will depend upon how X is constructed. For example, they could be interpeted as a slope indicating the change of thickness with age. The analysis/estimation is then the process of computing beta given the data y and the design matrix X. A Null Hypothesis (H0) is constructed with a contract matrix C. Inferences are drawn by testing whether the value gamma=Cb is zero.

Preprocess Group Data

BR set SUBJECTS_DIR BR If you are using the tutorial data you will need to set your SUBJECTS_DIR to the directory with the group analysis data in it. If you have installed your tutorial data to your $FREESURFER_HOME the command to set your SUBJECTS_DIR is:

setenv SUBJECTS_DIR $FREESURFER_HOME/subjects/buckner_data/tutorial_subjs/group_analysis_tutorial

If you have installed your tutorial data to a different location then you should replace $FREESURFER_HOME/subjects in the above command with the complete path to the location you installed the data. If you are not using tutorial data, but following along with your own data please set your SUBJECTS_DIR to the directory that contains all the subjects in your study, that have completed recons.

BR recon-all BR Prior to using the qdec application, your group subject data must be processed by the standard Freesurfer processing stream, via the recon-all script. [http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial A freesurfer tutorial is available.] This processing stream supplies the surfaces and morphometry data on each subject. The data in the tutorial set has been processed for you.

BR pre-smoothed fsaverage surfaces BR Qdec is happiest if each subject has a pre-computed smoothing data for the target surface for each measure (thickness, sulc and curv). You can create this data, via recon-all using the command:

recon-all -s <subjid> -qcache

The -qcache flag will run numerous back-to-back mris_preproc processes on your machine, so be prepared for it to run for about an hour. BR For the purposes of this tutorial, the -qcache command has been run for all of the subjects.

BR qdec.table.dat BR The primary input to qdec is a text file, named qdec.table.dat, containing the subject IDs, and discrete and continuous factors, in table format. This is essentially a table of demographics for your subject including all of the variables and factors that you wish to consider. Here is an example file:

fsid            gender  age diagnosis   Left-Cerebral-White-Matter
011121_vc8048   Female  70  Demented    202291
021121_62313-2  Female  71  Demented    210188
010607_vc7017   Female  73  Nondemented 170653
021121_vc10557  Male    75  Demented    142029
020718_62545    Male    76  Demented    186087
020322_vc8817   Male    77  Nondemented 149810

For each discrete factor, there must exist a file named <factor>.levels which lists all possible levels. For example, accompanying the example qdec.table.dat file must be a file named 'gender.levels' containing these lines:

Female
Male

and there must be a file named 'diagnosis.levels' containing these lines:

Demented
Nondemented

Of course you may have different discrete factor names and levels (or even no discrete factors, in which case all column data is assumed to be continous factors).

A qdec.table.dat has been made for you. Here is a sample of what that looks like:

fsid    gender  age
004     Male    72
008     Female  88
017     Male    25
021     Male    22
032     Male    79
039     Female  69

To accompany this file you will need to create a <factor>.levels text file to define the discrete factor names. You can do this using the text editor of your choice (emacs, vi, pico...) If you have trouble there is a sample file that has been created for you, called sample.levels simply copy this to gender.levels and you can continue with the tutorial.

cp sample.levels gender.levels

BR fsaverage BR For display purposes, you will need to have an average subject included in this subject group. Freesurfer's fsaverage will do fine:

cd $SUBJECTS_DIR
ln -s $FREESURFER_HOME/subjects/fsaverage

This will add a copy of fsaverage into your SUBJECTS_DIR.BR

If you wish to make your own average subject from your set you can do so using [wiki:make_5faverage_5fsubject make_average_subject]. If you use an average different than fsaverage you will need to be sure to compute smoothing data for each measure in this target space. You can use the command:

recon-all -s <subjid> -qcache -target <target>

Usage

To start qdec, from you $SUBJECTS_DIR, simply type qdec:

qdec &

The first thing you will need to do is to load your qdec.table.dat file. Click File -> Load Data Table, or you can use the attachment:qdec-load-data-table.png button, and traverse to your subjects directory and select your qdec.table.dat file that you created. When you click Open, it should load your file, the contents scrolling-by in the terminal window. If the data is loaded correctly, you should see in the terminal window a summary, like this example:

Number of subjects:   40
Number of factors:    2 (1 discrete, 1 continuous)
Number of classes:    2
Number of regressors: 4

Your discrete (gender) and continous (age) factors should appear when you click the Design tab of the qdec application. attachment:qdec-design.jpg

Analysis

You can select up to four factors in the Design tab to regress against, in this tutorial we only have two to choose from. For the tutorial data, you could select 'gender' and 'age', or just 'gender', or just 'age'. For simplicity in this example, choose only 'age' leaving the 'Smoothness', 'Measure' and 'Hemisphere' at their defaults (10mm, thickness, and lh). Now click the 'Analyze' button and the stats will begin processing, executing the mri_glmfit executable. Upon clicking 'Analyze', the terminal will display the output of this processing. Also, progress information is shown in the bottom bar of the qdec application.

Display

Once the analysis is complete (taking up to several minutes for a large subject set), the fsaverage inflated surface will appear in the display window. Now click on the 'Display' tab. You will see a list of questions summarizing the various analyses that were completed. attachment:qdec-display.jpg

You can click on one of these questions to load the results. If you click on questionHere is an example display:

attachment:qdec.jpg

Notice the green cross-hairs. You can display a plot of the data for a particular vertex by right-clicking on a point while holding-down the Ctrl key. Here is an example plot that corresponds to the shown selected vertex:

attachment:fsgdplot.jpg

Notice that thickness correlates with age at this vertex (thinning occurs).

To rotate the display, hold-down the left mouse button while moving. It takes quite a bit of practice to learn how to move the display. Holding-down the middle button while moving the mouse will move the display. Holding-down the right mouse button while moving will zoom the display.