top | previous | FSFAST Tutorial Top

First Level (Time Series) Analysis

1. Configure an Analysis

The first step in the first-level analysis is to configure analyses and contrasts. 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 workmem.sm05.lh 

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

ls 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!

2. 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 paradigm file (see above). For this design, the conditions are (1) Encode, (2) Emotional Distractor, (3) Probe After Emotional Distractor, (4) Neutral Distractor, and (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.

2.1. Enocde 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 workmem.sm05.lh -contrast encode-v-base -a 1

This will finish in a few seconds (still no data have been analyzed!), creating a files called 'emot.dist.mat' in workmem.sm05.lh

ls workmem.sm05.lh

This is a binary file and cannot be viewed.

2.2. 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 workmem.sm05.lh -contrast emot.dist-v-base -a 2

2.3. Distractor Average vs Baseline

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

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

2.4. Emotional Distractor vs Neutral Distractor

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

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

2.5. Probe Average vs Baseline

The Probes are conditions 3 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.5 0 0.5]. This is achieved with the command:

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

When more than one active condition are specified, the weights are rescaled so that they sum to 1, so the weights for conditions 3 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.

3. 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 workmem.sm05.rh 

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 workmem.sm05.mni305

4. Summary of Analysis and Contrast Configurations

5. First Level Analysis

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

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

ls $FSFTUTDIR/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. To explore this output more, see the Examinefirstleveloutput below.

5.1. Visualize the First Level Output

Bring up the tksurfer 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 emot.dist-v-neut.dist \
  -c probe.avg-v-base

To view the different contrasts, View->Overlay->Configure. The "Time Point" box will go from 0 to 3 corresponding to the four contrasts in the order entered on the command line. Adjust the Time Point number to see 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

This will show both cortical and subcortical voxels. The cortical structures will be masked out when we do the group analysis.

5.2. First-Level Analysis Summary

6. First Level Output Details

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 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: