Monday, 4 November 2013

Three group surface-based analysis

1. Create a directory for the group analysis

e.g.

mkdir FSGD

2. Create a simple text file (.fsgd) containing subject information and with the following headers

e.g.
      
        GroupDescriptorFile 1
        Title    MyGroups
        Class   Control
        Class   Patient
        Class   Recovered
        Input   Subject1      Control
        Input   Subject2      Patient
        Input   Subject3      Recovered

3. Create simple text files (.mtx) for each contrast and a group contrast.

e.g.

       Control-Patient.mtx
       1 -1 0

       Control-Recovered.mtx
       1 0 -1

       Patient-Recovered.mtx
       0 1 -1

       group.effect.mtx
       1 -1 0
       1 0 -1

4. Assemble the data (resample each subjects data into a common space, concatenate subjects into a single file (y.mgh), spatial smoothing).

For data that has already been cached (smoothed) use the following command:

   mris_preproc --fsgd mydata.fsgd \
   --cache-in thickness.fwhm10.fsaverage \
   --target fsaverage --hemi lh \
   --out lh.mydata.thickness.10.mgh

For data that has not previously had the -qcache command run on it:

    mris_preproc --fsgd mydata.fsgd \
    --target fsaverage -hemi lh \
    --meas thickness \
    --out lh.mydata.thickness.00.mgh


   mri_surf2surf --hemi lh \
   --s fsaverage \
   --sval lh.mydata.thickness.00.mgh \
   --fwhm 10 \
   --cortex \
   --tval lh.mydata.thickness.10B.mgh

5. GLM analysis: the following command will perform whole-brain cortical thickness analysis.

   mri_glmfit \
   --y lh.mydata.thickness.10.mgh \
   --fsgd mydata.fsgd dods\
   --C  Control-Patient.mtx \
   --C  Control-Recovered.mtx \
   --C  Patient-Recovered.mtx \
   --C  group.effect.mtx \
   --surf fsaverage lh \
   --cortex \
   --glmdir lh.mydata.glmdir

Notes
  • Thickness is the chosen measure in this example, but this can be substituted for any other measures e.g. area or volume.
  •  You can choose between DODS or DOSS depending on your experiment, see http://freesurfer.net/fswiki/DodsDoss)
  • All of the contrasts have been included in this example, as freesurfer uses these contrasts to measure the group effect.

6. View the uncorrected significance map with tksurfer. For this you will need to be in the FSGD directory but not in any of the contrast directories.

e.g.

      tksurfer fsaverage lh inflated \
      -annot aparc.annot -fthresh 2 \
      -overlay lh.mydata.gmldir/Control-Patient/sig.mgh


7. Clusterwise correction for multiple comparisons (Monte Carlo Null-Z  Simulation)

e.g.

       mri_glmfit-sim \
       --glmdir lh.mydata.glmdir \
       --sim mc-z 5 4 mc-z.negative \
       --sim-sign neg --cwpvalthresh 0.4 \
       --overwrite

Notes
  • 5 in the above example is the number of iterations. In this case 5 is used as an example to practice with, it is recommended to run this first before going to a higher number of iterations (up to 50,000). The more iterations run the more accurate the results will be.
  • 4 in the above example is the vertex-wise threshold which corresponds to the p-value (see below).
  • 0.4 in the above example is a request that all clusters that have a cluster-wise p-value threshold of <0.4 are kept. This can be altered, or set to 0.999 to see all of the clusters regardless of p-value.
  • By specifying negative/neg, the results will only display negative changes e.g. cortical thinning. This can be set to positive, to view positive results or absolute to view both.
Voxel-wise thresholds
 
1.3 = p < 0.05
2 = p < 0.01
2.3 = p < 0.005
3 = p < 0.001
3.3 = p < 0.0005
4 = p < 0.0001

8. View the corrected results in the terminal. You will need to be in the directory of the contrast that you wish to view results for.

e.g.

      cd Control-Patient
      less mc-z.negative.sig.cluster.summary

9. Load corrected results in tksurfer

e.g.

     tksurfer fsaverage lh inlfated \
     -annot lh.mydata.glmdir/Control-Patients/mc-z.negative.sig.ocn.annot \
     -fthresh 2 -curv -gray










QDEC Group Analysis

This post will take you through all of the steps needed to be able to run surface-based group analysis using the Query, Design, Execute, Contrast (QDEC) interface.

1. Create a qdec directory within the directory where all of your subject files are stored.

e.g.

% mkdir qdec

4. For display purposes you will need to have an average subject in your subjects_dir. There is an fsaverage already stored in freesurfer which has been made in MNI space.

e.g. cd $SUBJECTS_DIR
     if (! -e fsaverage) ln -s $FREESURFER_HOME/subjects/fsaverage

3. Create a text file containing all of the subject/demographic information that is required to carry out the analysis (e.g. subject ID, Group membership, age, gender etc). It is important to keep in mind that QDEC can normally handle two additional covariates, so try not to include unnecessary information in this text file.
It is likely that you will need to de-mean the ages, depending on whether you use DODS or DOSS.
You should name this file ending in .table.dat :

e.g.

% nedit mydata.table.dat

SubjectID  Group  Age  Gender
Subject1    HC       50     Female 
Subject2    Patient 48     Male
etc..

Remember:
  • Ensure that all subjects are named with the exact same ID as the original image folders.
  • There should be no empty lines between subjects.
  • keep the information stored in this file to a minimum/only include necessary information that will be used in the analysis.
  • If you have more than one table.dat file, containing different categorical information (e.g. controls and patients/ controls and recovered patients) be sure to change the categories in the Group.levels file when running qdec.

4. Any categorical factors (i.e. Group, Gender) will need a separate text file containing the different levels:

e.g.

% nedit Group.levels

HC
Patient

Continuous factors do not need a separate file to define them.

5. If the FreeSurfer environment has been set up properly (as described in previous blog post) you should be able to type in 'qdec' to the terminal and the qdec interface will start to load.

6. When the qdec interface opens up, you can select the table.data file that you have created.

e.g.

File- Load data table

You will also need to go into the 'Design' tab and give the design a name, this will create a directory within your qdec directory, containing all of the output from the analysis you are about to run.

See http://freesurfer.net/fswiki/FsTutorial/QdecGroupAnalysis_freeview for more qdec information.