~~ODT~~
====== Lab 8: fMRI Part 3: Group Analysis with FSL ======
===== Readings to be completed prior to this lab: =====
* none
===== Readings to be completed prior to next week's lab: =====
* TBD
===== Housekeeping: =====
Some of the images used in tonight's lab are from earlier versions of FSL (and/or from FSL running on a Linux machine), so they might not always look identical to what you see when running the program. However, the display should be very similar. I have updated the images in all cases in which the display looks substantially different.
===== Goals for this lab exercise: =====
This lab will continue the analysis that you started in in the previous lab. Last time, you used FSL to analyze two (for the Motor task) or three (for the Face task) runs of data from a single subject. Tonight you will conduct //Second Level Analysis// that will combine the results across those runs. You will then perform a //Third Level analysis// (aka 'Group'), which will combine the data across several subjects.
===== Software introduced in this exercise: =====
* none
===== Laboratory Report =====
Your lab report is [[psyc410_s2x:syllabus#Lab Reports|due]] one week from tonight.
The lab report questions for tonight's lab are listed below (these will be shown again at the relevant sections throughout the lab). Tonight's lab has two parts. Usually, these would be two separate lab reports (LR 7 and LR 8). But I'd like you to submit them as a single MS Word document (with your last name in the filename).
Some general things to keep in mind while completing your lab report and preparing your figures:
* When you choose images to show a region or region of activation, you should make use of all three slice planes. For instance, if you are showing the amygdala in the axial view, then I also want to see it in the coronal and sagittal views.
* You should always report the MNI x,y,z coordinates with your brain figures (these can be in the figure or reported in the figure legend).
* You should always indicate which is the right, and which is the left hemisphere.
* You should always include a colorbar and indicate what range the colors represent
* To see the color bar, click on the settings wrench icon in the upper left. Select ''Show colour bar''.
===== Data used in this lab =====
* You will continue working on the same data that [[psyc410_s2x:fmri_part2#Data used for this lab|you started analyzing last week]].
* Therefore, all of your output from tonight's lab should continue to go into **''~/Desktop/output/lab07''**
===== Part 1: Second level analysis =====
As mentioned [[psyc410_s2x:fmri_part2#Part 2: Creating a statistical model for a First Level Analysis|in the last lab]], a second level analysis combines the results of two or more first level analyses, and thus provides summary statistics across the runs for an individual subject.
A ''run'' refers to a single continuous data acquisition period. There are several reasons you would divide your study up into separate chunks. One reasons is to give your subjects intermittent rest periods. So if you have an experiment that requires 40 minutes to complete, you might break that up into eight 5-minute ''runs''.
The inputs to a second level analysis are **not** raw image volumes, but rather consist of the first level statistics and variances. For that reason, second level analyses run much faster than first level analyses.
FSL uses a sophisticated approach to combining First Level Analyses into a Higher Order Analysis that is discussed [[http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FEAT/UserGuide#Group_Statistics|here]].
To save yourself a lot of traversing through file manager boxes to find the relevant files, launch ''fsl'' from a terminal in which you first change your current directory to a helpful place. For example, you might first cd ''/Users/hnl/Desktop/output/lab07'' and then start fsl ''fsl &''.
====Data Tab====
**1.** Initiate a second-level analysis in ''FEAT''
* Choose the ''Higher Level Analysis'' drop down button at the top of the ''FEAT'' GUI
* note, by default, this button is set to ''First Level Analysis'', so you have to click on it to choose the ''Higher Level Analysis''.
When you choose ''Higher Level Analysis'', the GUI box changes to a more simplified set of options than are available for ''First Level Analysis''. This is because the pre-processing steps carried out images volumes in First Level Analysis are not needed for Higher Level Analyses. Here is the GUI that you should see.
{{course:lab07:feat_level2_setup.png}}
**2.** Specify Input
For those of you analyzing the motor task, and thefore only have two runs of data for your subject, you'll need to do the following before you input your data:
* Go to the ''Stats'' tab
* Choose a ''Fixed effects'' model
* Return to the ''Data'' tab
If you are analyzing the motor task, and therefore only have 2 runs
You will be providing as your **input** to the second level analysis, the **output //directories//** created in your first level analyses.
* Thus, choose ''Inputs are lower-level FEAT directories'' as your input source.
* Set ''Number of inputs'' to however many first level analyses your ran (3 for faces, 2 for motor)
* Select ''Select FEAT directories''
* Specify the output //.feat// directory from each run of the first level analysis
* e.g., ''~/Desktop/output/lab07/run01.feat''
{{course:lab07:feat_level2_select_data.png}}
**3.** Specify output
* Enter ''/Users/hnl/Desktop/output/lab07/allruns'' in the ''Output Directory'' box.
====Stats Tab====
The stats tab is used to specify your statistical model.
* Choose a ''Fixed Effects'' model (see box below).
* There are two options for specifying your model. Because we have such a simple model, we can use the ''Model setup wizard'' and choose the default. Press ''Process'' when you are finished.
In brief, a **fixed-effects model** is appropriate when "averaging" across runs because we are not trying to generalize the results beyond our sample. The across-runs results *is* the effect for our participant.
However, this would //not// be appropriate when "averaging" across participants, because we will be using those results to generalize beyond our sample. So in that case we would use a **random-effects model**.
{{course:lab08:feat2_stats01.png?nolink&400}}
{{course:lab08:feat2_stats02.png}}
====Post-stats Tab====
The Post-stats tab will look the same as for the [[psyc410_s2x:fmri_part2#Part 3: Post-statistics significance testing|first level analysis]]. You must choose a method for correcting for multiple comparisons. The default is to use a cluster correction such that a single voxel is considered significant with a ''Z threshold'' of ''3.1'' (equal to p < .001). The cluster correction will then further restrict significant voxels to only those in clusters with a ''Cluster correction threshold'' of ''p < .05''.
For your lab, I want you to compare two different methods for correcting for multiple comparisons. We will compare the results of analyzing the data ''uncorrected'' with the results when we use ''cluster'' correction.
When ''FEAT'' runs additional analyses with the same output folder specified, it appends a ''+'' to the output folder name. This is convenient, in that you don't overwrite your prior output. So, __be sure to pay attention to what output folder you are examining__.
**1. ** Run the ''Uncorrected'' second-level analysis
* Set ''Thresholding'' to ''Uncorrected''
* Set the ''Uncorrected voxel p threshold'' to ''.01''.
* Press ''Go''
**2. ** When the Uncorrected analysis is finished (the HTML file will no longer read 'Still Running'), re-run the second-level analysis using a ''cluster'' correction.
* Set ''Thresholding'' to ''Cluster''
* Set the ''Z threshold'' to ''2.3'' (this is equivalent to the p < .01 voxel threshold we used above)
* Set the ''Cluster P threshold'' to ''.001''
* Press ''Go''
You will compare the output of these two analyses as part of the next section.
/*
Be aware that ''None'' is not the same thing as ''Uncorrected''. The former will not create a 2D activation map in your ''report.html'', whereas the latter will apply a voxel-wise threshold but not correct for multiple comparisons. Do not use ''None''.
*/
====Exploring your Second Level Analysis====
To get a quick overview of your results you can explore the HTML output file. If you click on ''Results'' you will see a list of the four contrasts you specified. You can click on any of these to see the results overlaid on a series of 2D "slices."
This is a convenient way to get a quick look, but that format is too rigid to explore your results. You also can't overlay different results on the same background image as the HTML output is not interactive. So in this section we will use ''FSLeyes'' to drill down into your data.
When FSL combines data from different sources (e.g., ''run01'' and ''run02''), it does not assume that the data were originally located in the same 'brain space' (even though, in this case, they were). It thus combines the data into a common space. In your second level analysis, the statistical overlays are (by default) in MNI152_2mm space. Thus, we will overlay your statistics on the ''MNI152_T1_2mm_brain''.
**1. ** Load the ''MNI152_T1_2mm_brain'' in ''FSLeyes''
If the brain looks super fuzzy, you probably loaded the ''MIN152lin'' brain by mistake.
You can now overlay one or more statistical results.
''FEAT'' creates **lots** of output files. I've highlighted some critical directories and files below. A full list and description of these files can be found [[http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FEAT/UserGuide#FEAT_Output|here]].
The statistical overlays are located in the output folder that you specified for you second level analysis. This folder will contain several sub-folders - for example, ''cope1.feat'', ''cope2.feat'', ''cope3.feat'', and ''cope4.feat''. **''COPE''** stands for __**c**__ontrasts __**o**__f __**p**__arameter __**e**__stimates.
Remember, the parameter estimates (aka beta values) are the estimated values that represent //how much// of a particular expected activation template exists in each voxel of the brain. That is, how much of the variance can be explained by our model.
We contrast differences in //how much// variance is explained by different experimental conditions. So, a COPE might tell us whether the //how much// of the estimated face activation template exists in a particular voxel statistically differs from the //how much// of the estimated scene activation template for that same voxel.
In our analysis of the face task:
* **COPE1** is the face main effect (or right hand) showing all voxels where the face regressor was significantly fit by the data
* **COPE2** is the scene main effect (or left hand) showing all voxels where the scene regressor was significantly fit by the data
* **COPE3** is the faces vs. scenes **//contrast//** and will only show voxels where faces activated the voxel significantly more than scenes
* **COPE4** is the scenes vs. faces **//contrast//** and will only show voxels where scenes activated the voxel significantly more than faces.
The file names within each of these COPE folders are identical, so it is essential that you take your time and be absolute sure that you are always in the directory you want to be in / think you're in.
At the top level of the folder is a file named ''thresh_zstat1.nii.gz''. This is the z statistic map for the specified contrast that has been corrected for multiple comparisons by whichever method you selected. It is a 3D volume, as the z statistic was calculated at all voxels. However, z scores that were above your threshold for significance (i.e., p > .05) have been eliminated. Thus, when you overlay this image on your background brain, __you will only see color where the differences met your significance criterion__.
===Effects of Cluster Correction===
Let's explore the effect of cluster correction by looking at the results from ''cope3'' (face > scene //or// right hand > left hand)
**2. ** Load **''uncorrected''** second-level analysis
* ''File'' => ''Add overlay from file'' => the ''thresh_zstat1.nii.gz'' from the ''cope3'' directory of your uncorrected second-level analysis
* If you followed the instructions above, this will be the ''allruns.gfeat'' directory
* Change the voxel colors from ''Greyscale'' to ''Blue-Lightblue''
**3. ** Load **''cluster corrected''** second-level analysis
* ''File'' => ''Add overlay from file'' => the ''thresh_zstat1.nii.gz'' from the ''cope3'' directory of your corrected second-level analysis
* If you followed the instructions above, this will be the ''allruns+.gfeat'' directory
* Change the voxel colors from ''Greyscale'' to ''Red-Yellow''
You can now compare the effect of multiple comparisons correction. The red voxels (corrected) are on top of the blue voxels (uncorrected). So anyplace you see a blue voxel is a location that is being reported as significant in the //uncorrected// analysis but **not** significant in the //cluster corrected// analysis.
Lab Report Part 1A
- We know that there are false positives (Type I error) in the //uncorrected// results. Include a figure that compares the //uncorrected// and //corrected// results showing an area that you believe to be a false positive in the former, that was cleaned up by the latter.
- Correcting for multiple comparisons can sometimes lead to voxels that are truly active being disregarded ("false negative", aka Type II error). Include a figure that compares the //uncorrected// and //corrected// results showing an area that you believe to be a "true" activation in the former, that was erroneously removed in the latter.
/*
FSL also stores the unthresholded z statistic volume in a subdirectory within your COPE folder called ''/stat''. The relevant file here is ''zstat1.nii.gz''. If you overlay this file, you will see what the z statistic was at every voxel in the brain. If you are adventurous, you can load this unthresholded z statistic image and use the contrast limits in ''FSLview'' to show only those voxels that are above a z score that you choose. For example, as discussed in a [[:psyc410_s2x:fmri_part1#Part 6: A preview of a problem - correction for multiple comparisons|prior lab]], you can choose a z score that is equivalent to a Bonferroni correction.
*/
Before proceeding, remove the //uncorrected// results from your **Overlay list** by highlighting the file and clicking the ''-'' button. If done correctly, all of the blue voxels will disappear.
**4. ** Click around in the brain and see if you can identify areas of particularly "strong" activation. If you have a very active participant, it might help to raise the ''Min'' value to something higher than ''0''. This number is the minimum z-score that a voxel must have in order to be shown. So the higher you make it, the fewer voxels you'll see. But those voxels that remain will be the most active (the highest z-scores).
Try changing the ''Min'' value from ''0'' to ''2''. You'll notice that the colors change a little because the color-bar has been rescaled to have ''2'' as the minimum. But importantly, you won't see any voxels disappear. Huh? I thought raising the minimum would get rid of voxels with z < 2. So why don't we observe a change.
Let me know if you figure it out.
** Where am I? **
To identify where in the brain a particular voxel is located, you can use the ''FSLeyes'' atlas tools. Press ''option'' + ''command'' + ''6'' to add the atlas pane to the bottom of the ''FSLeyes'' window (It might take the atlas a few seconds to load). Now, as you click around in the brain, ''FSLeyes'' will report where you are in the brain according the the Harvard-Oxford Atlas.
Lab Report Part 1B
- Find a cluster of activation on the right fusiform gyrus (for the face task) or the right motor cortex (for the motor task) and include this figure in your report.
//Tip: If you have a very active participant with big clusters, you'll want to raise the ''Min'' value until the clusters are small enough for you to localize them on the anatomy.//
**5. ** Load results of your scene > face (or left hand > right hand) contrast.
* ''File'' => ''Add overlay from file'' => the ''thresh_zstat1.nii.gz'' from the ''cope4'' directory of your cluster corrected second-level analysis
* Change the overlay color to "Blue-Lightblue".
Explore the results the same way you did in the last part (it might be helpful to hide those results).
Lab Report Part 1C
- Find a cluster of activation on the right parahippocampal gyrus (for the face task) or the left motor cortex (for the motor task) and include this figure in your report.
//Tip: If you have a very active participant with big clusters, you'll want to raise the ''Min'' value until the clusters are small enough for you to localize them on the anatomy.//
=====Part 2: Third Level Analysis=====
You should now have completed and explored a second level analysis of your subject's data. The next step is a **third level** analysis in which you combine the second level analyses from two or more subjects. We have fifteen subjects in each of our two tasks: //face// and //motor//. Your third level analysis will combine the data from all of them.
Normally, you would first have to conduct first and second level analyses for __each__ of these subjects before proceeding to the third level step. However, because you now have done this for one subject, there is nothing more to learn by running the additional subjects needed for your third level analysis except patience (and the value of scripting!). Therefore, these analyses have already been done for you and you can proceed directly to the third level analysis.
===Data for third level analysis===
The following fifteen participated in the **Motor** and **Face** tasks:
2545 2552 2553 2554 2585 2731 2766 2767 2814 3850 3855 5743 5744 5769 5770
**Note**: averaging our results across 16 subjects would improve our SNR by 4 times (square root of 16).
The second level analysis results for the **face study** are located in the following location for each participant:
~/Desktop/input/fmri/loc/analysis/fsl/SUBJ/face_allruns.gfeat
The second level analysis results for the **motor study** are located in the following location for each participant:
~/Desktop/input/fmri/loc/analysis/fsl/SUBJ/motor_allruns.gfeat
Within the ''TASK_allruns.gfeat'' directory there is
The input to third level analysis will be the relevant cope file, ''cope1.feat'' within the second level ''allruns.gfeat'' directory the results for each cope are in their own subdirectories:
* ''cope1.feat'' (Task B)
* ''cope2.feat'' (Task A)
* ''cope3.feat'' (Task B > Task A)
* ''cope4.feat'' (Task A > Task B)
The third level analysis combines the data for //each cope// across all subjects. So each time you run a third level analysis, you are focusing solely on just one of your first/second level contrasts. This means that **__you need to run four separate third level analyses__** for your experiment, one for each COPE.
==== Data Tab ====
**1.** Open FEAT if it is not open already and select ''Higher-level analysis'' (instead of ''First-level analysis'')
**2.** Set ''Number of inputs'' to ''15'' inputs (one per each of subjects who were run in your task of interest).
**3.** Click on ''Select FEAT directories''. This will open a window in which you need to specify the names of your COPE directories - one per subject.
Typing out the long path to each //cope.feat// directory would be laborious and error prone. Instead, I recommend you use the folder icon to manually select the first directory and then copy and paste that to the remaining 14 fields (see yellow tip box below for cut and paste instructions on this system). Of course, you'll then need to go in and change the subject number on each line, but this is still much easier than the alternative.
After you select the first file, and before you copy it to the other 14 fields, I recommend that you replace ''/Users/hnl'' with ''~''. This makes the path short enough that you can see the cope number. This will make your life easier because you'll need to change that number on each line each time you run third level analysis on a different cope.
//{{ :psyc410:images:feat_level3_select_input_data.png?nolink&500 }}//
**How to Cut and Paste**
''X11'' (aka ''XQuartz'') is a window system that allows us to use the graphical user interface of Unix-based programs like FSL. Unfortunately, the //cut and paste// function in X11 does not work exactly as you might expect.
//To copy text//:
You can copy text just as you would elsewhere in the operating system.
* Click on the ''X11'' icon in your dock (the black X in an orange circle)
* From the file menu select ''Edit'' => ''Copy''
* Alternatively, you can sue the keyboard shortcut ''Command''+''C''
//To paste text//:
Pasting is where things get weird (relative to what you're used to).
* If you are using a three-button mouse, you can place the cursor where you want to paste the text and simply click the third button (often this is the scroll-wheel button).
* If you are using a two-button mouse or a trackpad you need to first change a setting in the preferences (you'll only need to do this one time).
* In the Mac menu bar select ''X11'' => ''Preferences'' and then on the ''Emulate 3 button mouse''
* Now you should be able to paste text simply by holding down the ''option'' key and clicking where you want the text inserted.
**4.** Specify your ''Output directory'' for the ''COPE'' you are analyzing. For instance, ''/Users/hnl/Desktop/output/lab07/allsubs_cope1''
//{{ :psyc410:images:feat_level3_setup_data.png?nolink&400 }}//
==== Stats Tab ====
Go to the ''Stats'' tab and set up your third level model. Our model is simple, and so we can click on the ''Model setup wizard'' and choose ''single group average''. Note, when we ran our second level analysis we used a //Fixed effects// model. Here we are averaging across different participants, so we will use the default ''Mixed effects: FLAME 1'' model. We're using ''Mixed effects'' because our run level information is **fixed effects**, but our participant level information is **random effects**
{{:psyc410:images:feat3rdlevel_stats.png}}
{{:psyc410:images:feat3rdlevel_model.png}}
==== Post-stats Tab ====
As in our second level analysis, we now need to select the ''Post-stats'' tab and choose a ''Thresholding'' criterion. As I've mentioned, there is no 'one size fits all' multiple comparisons correction. So we will need to specify different methods depending on whether you're analyzing the ''face'' or ''motor'' task.
**For the Face / Scene task**
Voxels along the fusiform gyrus are known to be highly sensitive to faces. However, the activation can be fairly localized (i.e., not many voxels in the cluster). This can make cluster correction too conservative. So to ensure that we see fusiform gyrus activation in our sample, we will use an ''Uncorrected'' threshold of ''.0005''. So we're telling FSL to only show us voxels with //very// high z scores, but don't worry about whether there are a lot of them clustered together.
**For the Motor task**
Basic motor and perception tasks create huge (by fMRI standards) activations. So we're going to use an **//extremely//** stringent statistical threshold. We will use a ''Cluster'' correction with a **Z threshold** of ''4.27'' (that's equal to p = .00001!!) and a **Cluster P threshold** of ''.01''.
The uncorrected z-statistics image is always provided in addition to whatever thresholding criterion you choose.
**1. ** Run your third level analysis
* Press the **''Go''** button.
A browser window should open and you can follow your results in the same way that you followed your second level results.
* Rerun the analysis for each of the four copes.
* Don't forget to change input **and** output directories for each cope.
====Exploring your Third Level Analysis====
Your analyses should be complete and it is now time to examine your results. As discussed above for the second level analysis, the HTML output is too inflexible to explore your results. I suggest you use ''FSLeyes''.
As with the second level analysis, the statistical overlays are named ''thresh_zstat1.nii.gz'' and are located in a //subdirectory// (see warning box below) of each of the four output folders that you specified for your four third level analyses. One per COPE.
* ''allsubs_cope1.gfeat''
* ''allsubs_cope2.gfeat''
* ''allsubs_cope3.gfeat''
* ''allsubs_cope4.gfeat''
**This gets confusing!**
Each of your ''allsubs_copeX.gfeat'' directories has a ''cope1.feat'' subdirectory. This is where you will find the relevant results file, ''thresh_zstat1.nii.gz''.
The confusing part is that the subdirectory is named ''cope1.gfeat'' regardless of the cope number of the parent directory! This is because third-level analysis focused on a single cope (e.g., cope 4), so the output directory will always be cope ''1''.
So, if you want to load your results for cope 4, you will find the file in ''allsubs_cope4.gfeat/cope1.feat''.
The structure of ''FEAT'' results directories are like nested Russian dolls. Angry, bitter, unforgiving, Russian dolls. Be careful. **Always be absolutely certain you are in the correct directory!!**
Examine these results as you did before for the second level.
Remember from before,
* **COPE1** is the main effect of Task B (face or right-hand)
* **COPE2** is the main effect of Task A (scene or left-hand)
* **COPE3** is the Task B vs Task A **//contrast//** and will only show voxels where Task B activated the voxel significantly more than Task A
* **COPE4** is the Task A vs Task B **//contrast//** and will only show voxels where Task A activated the voxel significantly more than Task B
**1. ** Display your group results
* Load the results from all four COPES overlaid on the ''MNI152_2mm_brain''
* Load the results from COPE1 and change the colorscale to ''Pink''
* Load the results from COPE2 and change the colorscale to ''Coppper''
* Load the results from COPE3 and change the colorscale to ''Red-Yellow''
* Load the results from COPE4 and change the colorscale to ''Blue-lightblue''
Lab Report Part 2
- Include a figure that only displays the results of COPE1 and COPE2.
- Are there regions that are commonly activated by both?
- If yes, why?
- Include a figure that only displays the results of COPE3 and COPE4
- For each of the two contrasts, identify two regions that seem to be //selectively// activated by one condition or another.
As with the second level analyses, ''FSL'' also stores the unthresholded (i.e., "raw") z statistic volume in a subdirectory within your individual output folders called ''/stat''. The relevant file here is ''zstat1.nii.gz''. If you overlay this file, you will see what the z statistic was at every voxel in the brain. If you are still feeling adventurous, you can load this unthresholded z statistic image and use the contrast limits in ''FSLeyes'' to show only those voxels that are above a z score that you choose. For example, as discussed in a [[:psyc410_s2x:fmri_part1#Part 6: A preview of a problem - correction for multiple comparisons|prior lab]], you can choose a z score that is equivalent to a Bonferroni correction.