Back to list of all tutorials | Back to course page | FS-FAST Tutorial Homepage | Previous (Preprocessing) | Next (Group Analysis)

1. First Level (Time Series) Analysis

This tutorial describes how to analyze the time series data by configuring analyses (design matrices) and contrasts. There are two distinct stages:

  1. Configuring analyses and contrasts
  2. Analyzing the data by fitting the time courses to the model and computing p-values for contrasts

Start the tutorial in the Project directory:

export SUBJECTS_DIR=$TUTORIAL_DATA/fsfast-tutorial.subjects
cd $TUTORIAL_DATA/fsfast-functional

2. Configure an Analysis

The first step in the first-level analysis is to configure analyses and contrasts. This step describes what preprocessing stages should have been run, as well as the parameters needed to construct a design matrix (no data are analyzed yet). This is done with mkanalysis-sess

mkanalysis-sess \
  -fsd bold -stc up  -surface fsaverage lh -fwhm 5  \
  -event-related  -paradigm workmem.par -nconditions 5 \
  -spmhrf 0 -TR 2 -refeventdur 16 -nskip 4 -polyfit 2 \
  -analysis my-workmem.sm05.lh  -per-run -force

To construct the design matrix, there are several pieces of information that are given in the above command:

This command finishes within seconds. It creates a folder called my-workmem.sm05.lh. See the contents with

ls my-workmem.sm05.lh

There will be a text file called 'analysis.info' with a list of all the parameters that you just specified. There is enough information here that the raw data and paradigm files can be found and the entire design matrix constructed. No data have been analyzed yet!

3. Configure Contrasts

Contrasts are embodiments of hypotheses that you want to test. They are linear combinations of conditions. In order to construct a contrast, you need to know the numeric ID associated with each condition; this is specified in the workmem.par paradigm file. For this design, the conditions are

  1. Encode
  2. Emotional Distractor
  3. Neutral Distractor
  4. Probe After Emotional Distractor
  5. Probe After Neutral Distractor

In a contrast, a weight must be assigned to each each condition. Often, the weights are 0, +1, or -1.

3.1. Encode vs Baseline Contrast

To find voxels that are activated by the Encode condition relative to baseline, one would assign a weight of 1 to Encode and 0 to everything else (ie, the contrast vector would be [1 0 0 0 0]). There is a value for each of the 5 conditions. The first value (for Encode) is 1, the rest are 0. To create this contrast matrix in FSFAST, run

mkcontrast-sess -analysis my-workmem.sm05.lh -contrast encode-v-base -a 1

This will finish in a few seconds (still no data have been analyzed!), creating a file called 'encode-v-base.mat' in my-workmem.sm05.lh

ls my-workmem.sm05.lh

This is a binary matlab file and cannot be viewed.

3.2. Emotional Distractor vs Neutral Distractor

The Emotional Distractor is the second condition, and the Neutral Distractor is the third condition. To find voxels that are activated by Emotional more than Neutral, one would need the following contrast vector [0 1 -1 0 0]. This is achieved with the command:

mkcontrast-sess -analysis my-workmem.sm05.lh -contrast emot.dist-v-neut.dist -a 2 -c 3

3.3. Distractor Average vs Baseline

One may be interested in voxels that respond to either Emotional or Neutral Distractor. This can be achieved by testing the average of the two distractors against baseline. One would need the following contrast vector [0 0.5 0.5 0 0]. This is achieved with the command:

mkcontrast-sess -analysis my-workmem.sm05.lh -contrast distractor.avg-v-base -a 2 -a 3

When there are multiple '-a' conditions, FSFAST automatically rescales the weights so that the positives sum to 1 (mutiple '-c' conditions will sum to -1).

3.4. Emotional Distractor vs Baseline Contrast

The Emotional Distractor is the second condition, so, to find voxels that are activated by it relative to baseline, one would need the following contrast vector [0 1 0 0 0]. This is achieved with the command:

mkcontrast-sess -analysis my-workmem.sm05.lh -contrast emot.dist-v-base -a 2

3.5. Probe Average vs Baseline

The Probes are conditions 4 and 5. If we are interested in the voxels activated by a probe, regardless of whether it follows an emotional or neutral distractor, then we can create a contrast in which we average their amplitudes: [0 0 0 0.5 0.5]. This is achieved with the command:

mkcontrast-sess -analysis my-workmem.sm05.lh -contrast probe.avg-v-base -a 4 -a 5

When more than one active conditions are specified, the weights are rescaled so that they sum to 1, so the weights for conditions 4 and 5 will be 0.5 instead of 1. If more than one control are given, the weights are scaled so that they sum to -1.

4. Configurations for Other Spaces

The commands above will configure the analysis and contrast only for raw data sampled to the left hemisphere of fsaverage. To do a full brain analysis, you will need to configure analyses for the right hemisphere and for the mni305 (for subcortical).

For the right hemisphere, use the same command as above with 'lh' changed to 'rh' in the '-surface' option and in the analysis name.

mkanalysis-sess \
  -fsd bold -stc up  -surface fsaverage rh -fwhm 5  \
  -event-related  -paradigm workmem.par -nconditions 5 \
  -spmhrf 0 -TR 2 -refeventdur 16 -nskip 4 -polyfit 2 \
  -analysis my-workmem.sm05.rh -force -per-run

You would also need to create contrasts for rh as above (but do not need to to finish the tutorial). For mni305, use the same command as above, replacing '-surface fsaverage lh' with '-mni305 2'. The '2' indicates 2mm sampling. The name is changed to reflect mni305.

mkanalysis-sess \
  -fsd bold -stc up  -mni305 2 -fwhm 5  \
  -event-related  -paradigm workmem.par -nconditions 5 \
  -spmhrf 0 -TR 2 -refeventdur 16 -nskip 4 -polyfit 2 \
  -analysis my-workmem.sm05.mni305 -force -per-run

You would also need to create contrasts for mni305 as above (but do not need to to finish the tutorial).

Note: This does not need to be repeated for each sessid.

5. Summary of Analysis and Contrast Configurations

6. First Level Analysis

The First Level analysis is the process of fitting the time series data to the model specified with mkanalysis-sess above, as well as computing contrasts. The command to do this in FSFAST is:

Don't run this command if you're at an organized course.

It can take a while and has already been done for you.

selxavg3-sess -s sess01 -analysis workmem.sm05.lh

selxavg3-sess will:

NOTE: Must run for each configuration (ie, workmem.sm05.{lh,rh,mni305}) - for the tutorial, this has already been done for you.

This creates a new directory in the FSD for this session:

ls $TUTORIAL_DATA/fsfast-functional/sess01/bold

You will see 'workmem.sm05.lh' (as well as 'workmem.sm05.rh' and 'workmem.sm05.mni305'). For the most part, it is not necessary to know what the actual contents of the output are, but knowing about the output can help to demystify the process. (More details about the outputs are included at the bottom of the page for this purpose.)

firstlevel.png

6.1. Visualize the First Level Output

Bring up the freeview visualization tool to to look at the contrasts for the analysis in the fsaverage left hemisphere space:

tksurfer-sess -s sess01 \
  -analysis workmem.sm05.lh \
  -c encode-v-base \
  -c emot.dist-v-base \
  -c probe.avg-v-base \
  -c emot.dist-v-neut.dist

encode.png

To view the different contrasts:

To view the right hemisphere, use the same command as above, just change 'lh' to 'rh' (note: the right hemisphere is analyzed with a separate selxavg3-sess command).

tksurfer-sess -s sess01 -analysis workmem.sm05.rh \
  -c encode-v-base \
  -c emot.dist-v-base \
  -c emot.dist-v-neut.dist \
  -c probe.avg-v-base

To view the volume-based analysis, the tool is tkmedit-sess, and the rest of the command line is similar (just replace 'lh' with 'mni305'). (note: the mni305 is analyzed with a separate selxavg3-sess command).

tkmedit-sess -s sess01 -analysis workmem.sm05.mni305 \
  -c encode-v-base \
  -c emot.dist-v-base \
  -c emot.dist-v-neut.dist \
  -c probe.avg-v-base

vol.encode.cor128.png vol.encode.cor091.png

6.2. First-Level Analysis Summary

7. Study Questions

8. First Level Output Details (Skip or Defer for FreeSurfer Course)

For the most part, it is not necessary to know what the actual contents of the output are, but knowing about the output can help to demystify the process. The output is going to go into the FSD of the given session.

cd sess01/bold
ls

You will see a folder called 'workmem.sm05.lh'. This is the output directory. View the contents of this directory:

cd workmem.sm05.lh
ls

There will be many files and folders. Some of the important ones are:

Check the dimensions of mask.nii.gz with mri_info to verify that they are '163842 1 1', indicating that this is a surface with one frame (the mask). All 'volumes' in this folder will be this size. Go into one of the contrast directories:

cd encode-v-base
ls

Again, there are many files here. Some of the more important ones are:

Back to list of all tutorials | Back to course page | Previous (Preprocessing) | Next (Group Analysis)

FsFastTutorialV6.0/FsFastFirstLevel (last edited 2017-03-08 17:20:25 by AndrewHoopes)