Differences between revisions 1 and 21 (spanning 20 versions)
Revision 1 as of 2011-03-29 19:05:00
Size: 10338
Editor: tanha
Comment:
Revision 21 as of 2011-12-08 21:00:13
Size: 15506
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

[[FreeSurferWiki|top]] | [[Tutorials|previous]] | [[FsFastTutorialV5.1|FSFAST Tutorial Top]]

First Level (Time Series) Analysis
[[FsFastTutorialV5.1|top]] | [[FsFastTutorialV5.1/FsFastPreProc|previous (Preprocessing)]]| [[FsFastTutorialV5.1/FsFastGroupLevel|Next (Group Analysis)]]
Line 9: Line 7:
= 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
 1. Analyzing the data by fitting the time courses to the model and computing p-values for contrasts

Start the tutorial in the Project directory:

{{{
setenv SUBJECTS_DIR $TUTORIAL_DATA/fsfast-tutorial.subjects
cd $TUTORIAL_DATA/fsfast-functional
}}}
Line 10: Line 20:

The first step in the first-level analysis is to configure analyses
and contrasts
. This is done with mkanalysis-sess
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
Line 19: Line 27:
  -analysis workmem.sm05.lh
}}}

* -fsd bold -stc up -surface fsaverage lh -fwhm 5 : preprocessing options (see preproc-sess above). There will be a separate analysis configuration for each space (ie, lh, rh, mni305)
  -analysis my-workmem.sm05.lh -force
}}}
 * -fsd bold -stc up -surface fsaverage lh -fwhm 5 : preprocessing options (see [[FsFastTutorialV5.1/FsFastPreProc|preproc-sess]]). There needs to be a separate analysis configuration for each space (ie, lh, rh, mni305)
Line 24: Line 31:
 * -paradigm workmem.par : name of paradigm file (see above)  * -paradigm workmem.par : name of [[FsFastTutorialV5.1/FsFastDirStruct|paradigm file]]
Line 31: Line 38:
 * -analysis workmem.sm05.lh : this is the name of the analysis configuration. Choose a descriptive name (and one that includes the space)

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!
 * -analysis my-workmem.sm05.lh : this is the name of the analysis configuration. Choose a descriptive name (and one that includes the space)
 * -force : overwrite any existing analysis

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

 * The stimulus timing (obtained from a file called
workmem.par in the Run directory)
 * The hemodynamic response model (SPM canonical shape (-spmhrf))
 * Nuisance regressors: 2nd order polynomial (-polyfit 2) and skipping first 4 time points (-nskip 4)

This command finishes w
ithin 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!
Line 44: Line 55:

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 des
ign, the conditions are (1) Encode, (2) Emotional Distractor,
(3) Pro
be 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.

== 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
}}}


* -analysis workmem.sm05.lh : analysis name from mkanalysis-sess above
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 [[WorkmemPar|workmem.par paradigm file]]. For this design, the conditions are

 1. Encode
 1. Emotional Distractor,
 1. Neutral Distractor
 1. Pro
be After Emotional Distractor
 1. Probe After Neutral Distractor.

In a contrast, a we
ight must be assigned to each each condition. Often, the weights are 0, +1, or -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
}}}
 * -analysis my-workmem.sm05.lh : analysis name from mkanalysis-sess above
Line 72: Line 76:
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.
This will finish in a few seconds (still no data have been analyzed!), creating a files called 'emot.dist.mat' in my-workmem.sm05.lh

{{{
ls my-workmem.sm05.lh
}}}
This is a binary matlab file and cannot be viewed.

== 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
}}}
 * -contrast emot.dist-v-neut.dist : name of the contrast.
 * -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
 * -c 3 : set the weight for condition 3 to be -1 (-c means 'control')
 * All other conditions given a weight of 0
 * Creates emot.dist-v-neut.dist in my-workmem.sm05.lh

== 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 0.5 0]. This is achieved with the command:

{{{
  mkcontrast-sess -analysis my-workmem.sm05.lh -contrast distractor.avg-v-base -a 2 -a 4
}}}
 * -contrast emot.dist-v-neut.dist : name of the contrast.
 * -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
 * -a 4 : set the weight for condition 4 to be +1 (-a means 'active')
 * All other conditions given a weight of 0
 * Creates emot.dist-v-neut.dist in my-workmem.sm05.lh

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).
Line 80: Line 110:

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
}}}
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
}}}
Line 93: Line 118:
 * Creates emot.dist.mat in workmem.sm05.lh

== 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
}}}

* -contrast emot.dist-v-neut.dist : name of the contrast.
 * -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
 * -c 4 : set the weight for condition 4 to be -1 (-c means 'control')
 * Creates emot.dist.mat in my-workmem.sm05.lh

== 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 my-workmem.sm05.lh -contrast probe.avg-v-base -a 3 -a 5
}}}
 * -contrast probe.avg-v-base : name of the contrast.
 * -a 3 : set the weight for condition 3 to be +1
 * -a 5 : set the weight for condition 5 to be +1
Line 110: Line 130:
 * Creates emot.dist-v-neut.dist in workmem.sm05.lh

== 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
}}}

 * -contrast emot.dist-v-neut.dist : name of the contrast.
 * -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
 * -c 4 : set the weight for condition 4 to be -1 (-c means 'control')
 * All other conditions given a weight of 0
 * Creates emot.dist-v-neut.dist in workmem.sm05.lh

== 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
}}}

 * -contrast probe.avg-v-base : name of the contrast.
 * -a 3 : set the weight for condition 2 to be +1
 * -a 5 : set the weight for condition 4 to be +1
 * All other conditions given a weight of 0

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.

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.
Line 151: Line 134:

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.
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.
Line 164: Line 143:
  -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.
  -analysis my-workmem.sm05.rh -force
}}}
You would 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.
Line 176: Line 154:
  -analysis workmem.sm05.mni305
}}}
  -analysis my-workmem.sm05.mni305 -force
}}}
You would need to create contrasts for mni305 as above (but do not need to to finish the tutorial).
Line 180: Line 159:
Line 184: Line 162:
 * Analysis done separately  * Actual analysis done separately
Line 187: Line 165:

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

 * Specify the session(s) and the analysis configuration
 * Automatically finds preprocessed data and paradigm files
 * Constructs design matrix
 * Constructs contrast matrices
 * Combines all runs in FSD
 * Computes regression coefficients (betas)
 * Computes contrasts ane their significances
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:

{{{
selxavg3-sess -s sess01 -analysis workmem.sm05.lh
}}}
 * -s sess01 : session to analyze (can use -sf SessIdFile)
 * -analysis workmem.sm05.lh : analysis configuration [Note: changed from my-workmem.sm05.lh]
 * May take minutes or hours to complete

selxavg3-sess will:

 * Automatically find preprocessed data and paradigm files
 * Construct design matrix
 * Construct contrast matrices
 * Combine all Runs found in the FSD
 * Compute regression coefficients (betas)
 * Compute contrasts ane their significances
Line 202: Line 185:
{{{
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.

{{{
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. To explore this output more, see the Examinefirstleveloutput below.

{{attachment:firstlevel.jpg|junk|width="700"}}
Line 212: Line 194:

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 \
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 \
Line 219: Line 201:
  -c emot.dist-v-neut.dist \
  -c probe.avg-v-base
}}}
  -c probe.avg-v-base \
  -c emot.dist-v-neut.dist
}}}
 * -s sess01 : session to view (cannot use -sf in this case)
 * -analysis workmem.sm05.lh : analysis to view
 * -c encode-v-base ... : load four contrasts in the give order

{{attachment:encode.jpg}}
Line 224: Line 211:
 * Red/Yellow are for positive contrasts
 * Blue/Cyan are for negative contrasts

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).
 * Red/Yellow are for positive contrasts (eg, Enocode > Baseline)
 * Blue/Cyan are for negative contrasts (eg, Enocode < Baseline)

To view the different contrasts:

 *
View->Configure->Overlay.
 *
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.
 * You will need to reduce the threshold to see activation in the Emotional vs Neutral Distractor contrast.

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).
Line 242: Line 230:

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).
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).
Line 253: Line 239:
This will show both cortical and subcortical voxels. The cortical
structures will be masked out when we do the group analysis.
{{attachment:vol.encode.cor128.jpg}} {{attachment:vol.encode.cor091.jpg}}

 * Left image (coronoal slice 128)
 * Right image: hippocampal activation (coronoal slice 91)
 * These images show both cortical and subcortical areas.
 * There is no activation in cortex because it has been masked out because it is analysed in cortical stream
Line 257: Line 247:
Line 262: Line 251:
 * Visualize volume-b  * Visualize volume

= Study Questions =
 * Configure a contrast for Probe following Emotional Distractor vs Probe following Neutral Distractor. [[FsFastTutorialV5.1/StudyAnswers#FlaEPvsNP|Answer.]]
 * How would you configure an analysis with a paradigm file called wmfir.par? [[FsFastTutorialV5.1/StudyAnswers#FlaFir|Answer.]]
 * How many times will you need to run mkanalysis-sess? [[FsFastTutorialV5.1/StudyAnswers#FlaMkAnaReps|Answer.]]
 * How many times will you need to run selxavg3-sess? [[FsFastTutorialV5.1/StudyAnswers#FlaMkSxa3Reps|Answer.]]

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

 * analysis.info - copy from analysis configuration
 * mask.nii.gz - mask combined from all individual runs
 * beta.nii.gz - map of regression coefficients
 * rvar.nii.gz - map of residual variances
 * fsnr.nii.gz - map of the functional SNR
 * encode-v-base - contrast folder
 * emot.dist-v-base - contrast folder
 * emot.dist-v-neut.dist - contrast folder
 * probe.avg-v-base - contrast folder

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:

 * sig.nii.gz - voxel-wise significances as visualized above.
 * ces.nii.gz - contrast values (like CON in SPM or COPE in FSL)
 * cesvar.nii.gz - variance of contrast values (like VARCOPE in FSL)
 * cespct.nii.gz - contrast values, percent computed on a voxel-wise basis
 * cesvarpct.nii.gz - variance of percent contrast values
 * t.nii.gz - t-ratio used to compute the sig.nii.gz
 * pcc.nii.gz - partial correlation coefficient
 * The ces and cesvar files are passed up to the higher level analysis.

[[FsFastTutorialV5.1|top]] | [[FsFastTutorialV5.1/FsFastPreProc|previous (Preprocessing)]]| [[FsFastTutorialV5.1/FsFastGroupLevel|Next (Group Analysis)]]

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

setenv 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 -force
  • -fsd bold -stc up -surface fsaverage lh -fwhm 5 : preprocessing options (see preproc-sess). There needs to be a separate analysis configuration for each space (ie, lh, rh, mni305)

  • -even-related : for event-related and blocked designs
  • -paradigm workmem.par : name of paradigm file

  • -nconditions 5 : number of conditions to expect in paradigm file
  • -spmhrf 0 : use canonical SPM HRF with 0 derivatives
  • -TR 2 : expect raw data to have a 2 sec TR
  • -refeventdur 16 : scale amplitudes based on a 16 sec event duration
  • -nskip 4 : skip the first four time points (paradigm timing still ok)
  • -polyfit 2 : use 2nd order polynomial nuisance regressors
  • -analysis my-workmem.sm05.lh : this is the name of the analysis configuration. Choose a descriptive name (and one that includes the space)
  • -force : overwrite any existing analysis

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

  • The stimulus timing (obtained from a file called workmem.par in the Run directory)
  • The hemodynamic response model (SPM canonical shape (-spmhrf))
  • Nuisance regressors: 2nd order polynomial (-polyfit 2) and skipping first 4 time points (-nskip 4)

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
  • -analysis my-workmem.sm05.lh : analysis name from mkanalysis-sess above
  • -contrast encode-v-base : name of the contrast. Choose something descriptive
  • -a 1 : set the weight for condition 1 to be +1 (-a means 'active')
  • By default, all other conditions given a weight of 0

This will finish in a few seconds (still no data have been analyzed!), creating a files called 'emot.dist.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
  • -contrast emot.dist-v-neut.dist : name of the contrast.
  • -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
  • -c 3 : set the weight for condition 3 to be -1 (-c means 'control')
  • All other conditions given a weight of 0
  • Creates emot.dist-v-neut.dist in my-workmem.sm05.lh

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 0.5 0]. This is achieved with the command:

  mkcontrast-sess -analysis my-workmem.sm05.lh -contrast distractor.avg-v-base -a 2 -a 4
  • -contrast emot.dist-v-neut.dist : name of the contrast.
  • -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
  • -a 4 : set the weight for condition 4 to be +1 (-a means 'active')
  • All other conditions given a weight of 0
  • Creates emot.dist-v-neut.dist in my-workmem.sm05.lh

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
  • -contrast emot.dist : name of the contrast. Choose something descriptive
  • -a 2 : set the weight for condition 2 to be +1 (-a means 'active')
  • By default, all other conditions given a weight of 0
  • Creates emot.dist.mat in my-workmem.sm05.lh

3.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 my-workmem.sm05.lh -contrast probe.avg-v-base -a 3 -a 5
  • -contrast probe.avg-v-base : name of the contrast.
  • -a 3 : set the weight for condition 3 to be +1
  • -a 5 : set the weight for condition 5 to be +1
  • All other conditions given a weight of 0

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.

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

You would 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

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

5. Summary of Analysis and Contrast Configurations

  • Configure analyses and contrasts once regardless of number of subjects
  • Configure an analysis and contrasts separately for lh, rh, and mni305
  • Configurations only create files and folder in Project Directory
  • Actual analysis done separately

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:

selxavg3-sess -s sess01 -analysis workmem.sm05.lh
  • -s sess01 : session to analyze (can use -sf SessIdFile)

  • -analysis workmem.sm05.lh : analysis configuration [Note: changed from my-workmem.sm05.lh]
  • May take minutes or hours to complete

selxavg3-sess will:

  • Automatically find preprocessed data and paradigm files
  • Construct design matrix
  • Construct contrast matrices
  • Combine all Runs found in the FSD
  • Compute regression coefficients (betas)
  • Compute contrasts ane their significances
  • Must run for each configuration (ie, workmem.sm05.{lh,rh,mni305})

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

junk

6.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 probe.avg-v-base \
  -c emot.dist-v-neut.dist
  • -s sess01 : session to view (cannot use -sf in this case)
  • -analysis workmem.sm05.lh : analysis to view
  • -c encode-v-base ... : load four contrasts in the give order

encode.jpg

  • Shows 'signifiances', ie, -log10(p). So, for p=.01, sig=2.
  • Red/Yellow are for positive contrasts (eg, Enocode > Baseline)

  • Blue/Cyan are for negative contrasts (eg, Enocode < Baseline)

To view the different contrasts:

  • View->Configure->Overlay.

  • 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.
  • You will need to reduce the threshold to see activation in the Emotional vs Neutral Distractor contrast.

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.jpg vol.encode.cor091.jpg

  • Left image (coronoal slice 128)
  • Right image: hippocampal activation (coronoal slice 91)
  • These images show both cortical and subcortical areas.
  • There is no activation in cortex because it has been masked out because it is analysed in cortical stream

6.2. First-Level Analysis Summary

  • Configure Analysis and contrasts once regardless of number of sessions
  • Run selxavg3-sess for each space (lh, rh, mni305) for each session
  • selxavg3-sess creates design matrix, fits parameters, computes contrasts and significances.
  • Visualize surface-based analysis results with tksurfer-sess
  • Visualize volume

7. Study Questions

  • Configure a contrast for Probe following Emotional Distractor vs Probe following Neutral Distractor. Answer.

  • How would you configure an analysis with a paradigm file called wmfir.par? Answer.

  • How many times will you need to run mkanalysis-sess? Answer.

  • How many times will you need to run selxavg3-sess? Answer.

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:

  • analysis.info - copy from analysis configuration
  • mask.nii.gz - mask combined from all individual runs
  • beta.nii.gz - map of regression coefficients
  • rvar.nii.gz - map of residual variances
  • fsnr.nii.gz - map of the functional SNR
  • encode-v-base - contrast folder
  • emot.dist-v-base - contrast folder
  • emot.dist-v-neut.dist - contrast folder
  • probe.avg-v-base - contrast folder

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:

  • sig.nii.gz - voxel-wise significances as visualized above.
  • ces.nii.gz - contrast values (like CON in SPM or COPE in FSL)
  • cesvar.nii.gz - variance of contrast values (like VARCOPE in FSL)
  • cespct.nii.gz - contrast values, percent computed on a voxel-wise basis
  • cesvarpct.nii.gz - variance of percent contrast values
  • t.nii.gz - t-ratio used to compute the sig.nii.gz
  • pcc.nii.gz - partial correlation coefficient
  • The ces and cesvar files are passed up to the higher level analysis.

top | previous (Preprocessing)| Next (Group Analysis)

FsFastTutorialV5.1/FsFastFirstLevel (last edited 2016-09-01 17:57:00 by AllisonMoreau)