Wallace:fMRI: Difference between revisions
Sarah Baum (talk | contribs) (→AFNI) |
Sarah Baum (talk | contribs) (→Part 1) |
||
(24 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
|-valign="top" | |-valign="top" | ||
|width=650px style="padding: 5px; background-color: #ffffff; border: 3px solid #851e21;" | | |width=650px style="padding: 5px; background-color: #ffffff; border: 3px solid #851e21;" | | ||
== Before you Begin == | |||
Before you begin running fMRI studies you'll need to get access to CORES so that you can book time on the scanner. You may be able to be added to an existing project. Work with Walter to set up access with the appropriate people. | |||
== Experiment Design == | == Experiment Design == | ||
=== Types of fMRI design === | |||
There are 3 main types of scan series that you will use in an fMRI experiment. | |||
==== Rapid Event-Related ==== | |||
==== Block Design ==== | |||
==== Resting State ==== | |||
=== Creating Code === | === Creating Code === | ||
To run an fMRI experiment you'll need to write some code that will interface with the scanner and present stimuli in the right order at the right time. For the most part, creating new code will involve taking someone's old code and updating the stimulus array variable. It's a good idea to test things out at the mock scanner in case the scanner software was updated in a way that no longer works well with the code, or if an errant comma or semi-colon found its way into the the code. | |||
When creating a stimulus array for a rapid event-related fMRI experiment, you'll need to pseudo-randomize the stimulus order in a way that is compatible for deconvolution analysis. The best way to do this is a program called optseq2. | When creating a stimulus array for a rapid event-related fMRI experiment, you'll need to pseudo-randomize the stimulus order in a way that is compatible for deconvolution analysis. The best way to do this is a program called optseq2. | ||
== Software == | |||
=== XCode and Terminal === | |||
If you would like to analyze fMRI data with AFNI, you will need to set up XCode and terminal. The following instructions are for a Mac computer. In terminal, we first need to change the shell. Open a terminal window, then go to Terminal > Preferences on the menu bar. Under the Startup tab, go to Shells open with: section. Click Command and type: | |||
/bin/tcsh | |||
and then close the window. Terminal will now open with tcsh instead of bash. | |||
If you want you can also go to the Settings tab of the Preferences pane and change the colors of the terminal window. Some people find a dark background with white text more eye friendly. Click your desired color scheme then press default. | |||
It's a good idea to have a .cshrc file, which will help you set up your path every time you open terminal. If you don't already have one, you can create one with the following command | |||
touch ~/.cshrc | |||
If you've already created a .cshrc file, enter the following command into terminal: | |||
open -e ~/.cshrc | |||
The following path commands are good to have in your .cshrc file. Be sure to double check that these path locations are where each program is located on ''your'' computer, and make adjustments as needed. | |||
set path = ( $path /sw/bin /Applications/AFNI/ /Applications/MATLAB_R2011a.app/bin) | |||
setenv DYLD_FALLBACK_LIBRARY_PATH /Applications/afni | |||
If you have a different version of Matlab, be sure to change the MATLAB folder as appropriate. Any time you make changes to your .cshrc file, these changes will only apply to "new" terminal windows. If your problem isn't solved after you make .cshrc changes, be sure you're working in a new window. | |||
=== AFNI === | |||
[http://afni.nimh.nih.gov/afni/ AFNI] is a software package for processing, analyzing, and displaying fMRI data. It is freely available from the NIH. Other packages for fMRI data analysis exist, but Sarah can't help you with them. | |||
It's a good idea to get AFNI up and running before you begin data collection and analysis. You can download the latest version of AFNI at | |||
http://afni.nimh.nih.gov/afni/download/afni/releases/latest | |||
When the file finishes downloading, you will need to double click the file to un-zip the tar file. Drag the newly created folder to the Applications directory. To more easily access the folder, rename it "afni". | |||
Next you'll need to download XQuartz since X11 is no longer automatically included in new Mac operating systems. You can download it here | |||
http://xquartz.macosforge.org/landing/ | |||
You'll need to log out and then log back in to make XQuartz the default X11 app. When you log back in, open terminal and simply type the command 'afni'. This should launch AFNI. | |||
==== Updating AFNI ==== | |||
Many problems can occur if your afni verion is not up to date. To update, first type the following command into terminal: | |||
afni -version | |||
If your afni version is more than a month old, it's time to update. To update, type: | |||
@update.afni.binaries -defaults | |||
Finally, after you update you must enter the command | |||
rehash | |||
=== FreeSurfer === | |||
FreeSurfer is an open source software package that is used in conjunction with other neuroimaging programs to analyze MRI data. Our main use will be the program optseq (see below) and reconall (for cortical surface reconstruction). Their download page also includes a wiki that may help with troubleshooting if necessary. To download FreeSurfer, go here: | |||
https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall | |||
To set that, you next need to download FreeSurfer (from the original link, click on Download). Download the package appropriate for your operating system. It's a big file (a few GB's) so it might take a while. Go get a coffee. | |||
After you've finished installing it, you should see the freesurfer folder under Applications. Next, we need to make sure the computer can be directed to the location of freesurfer. | |||
You will need to add FreeSurfer to your .cshrc file. You can do so with the following commands: | |||
echo ‘setenv FREESURFER_HOME /Applications/freesurfer‘ >> ~/.cshrc | |||
echo ‘source $FREESURFER_HOME/SetUpFreeSurfer.csh' >> ~/.cshrc | |||
You'll note that there are multiple ways to add text to the .cshrc file, either directly through the terminal window or by manually opening the file. Both ways work, it just depends on what you're comfortable with. | |||
There will be other lines you'll need in your .cshrc file to direct to other programs, they should be listed in the section of this wiki about that program. | |||
You'll also need a license to run FreeSurfer. Happily, it's free. Go to the Registration tab under the download link listed above and fill out the form. You should receive an e-mail with text that you need to copy into the license file. This part is a little tricky. First, open a text file called .license: | |||
touch .license | |||
open -e .license | |||
Copy and paste the 3 lines from the FreeSurfer registration e-mail into this text file. Files that start with a . are a bit tricky because they are hidden if you tried to find them in the finder window. Next we need to move the .license file to the right folder (set by $FREESURFER_HOME). | |||
sudo cp .license $FREESURFER_HOME | |||
To test that everything is working correctly, type: | |||
which freesurfer | |||
and the response should be the location of the freesurfer folder. | |||
=== Optseq === | |||
==== Part 1 ==== | |||
Optseq is a FreeSurfer package for determining optimal randomization of events for rapid event related fMRI. This needs to be 'optimally random' because the HDR during RER fMRI significantly overlaps (HDR typically peaks 4-6 seconds after stimulus onset, and events are usually presented ~ every 2 seconds). Download the package as appropriate for your operating system. | |||
http://surfer.nmr.mgh.harvard.edu/optseq/ | |||
Here are the parameters you'll need to set: | |||
set tr = 2 #length of TR, typically 2 seconds | |||
set numev = 30 #number of trials per condition (remember to leave room for null trials! for example, if doing a run of 150 TR and 4 stimuli, you could have 30 stim per condition per run) | |||
set numtar = 20 #number of target trials, the remaining 10 will be control (null) trials | |||
set out = {insert file name here} | |||
It is important to have 5 NULL trials at the end to allow the HDR from the last trial to rise and fall. Therefore, if you would like the run to be 150 TRs, you may actually want to set -ntp to be 145 and then manually add 5 NULL's yourself. To run the program: | |||
/Applications/freesurfer/bin/optseq2 \ | |||
--tsearch 0.001 \ | |||
--psdwin 0 16 2 \ | |||
--nkeep 8 --o {$out} \ | |||
--ntp 150 --tr {$tr} \ | |||
--ev stimulus1 {$tr} $numev \ | |||
--ev stimulus2 {$tr} $numev \ | |||
--ev stimulus3 {$tr} $numev \ | |||
--ev stimulus4 {$tr} $numev \ | |||
--ev stimulus5 {$tr} $numev \ | |||
--ev target {$tr} $numtar \ | |||
You should see that there is a fair amount of customization available. For example, if you don't need target trials, you can delete this line (just be sure that the last line is not followed by a \, this tells terminal that there is still more code to come). Replace "stimulus1" etc. with the name of that category (ex: AVcongruent, McGurk, etc.). If you want, you can have a different number of trials per condition. The parameter tsearch indicates the number of hours you want to let the computer run. The parameter nkeep will keep the best X number of run orders. Do NOT change the psdwin parameters unless you absolutely know what you're doing. | |||
The output will be in your current folder. It is advisable to keep track in a text file the parameters you used to create the run order in case you need to refer to them later. If you open one of the .par file outputs, you will find the exact time the stimulus will be presented, stim type (in order given by your inputs), number of seconds for each trial, and the last column is the name of the stimulus. | |||
==== Part 2 ==== | |||
Part 2 involves transforming the .par output into a useable format. This can easily be done in Matlab. You may need to adjust given your intended stimulus presentation software for your experiment (E-Prime, Psychtoolbox, Presentation, etc.). | |||
== Data Analysis == | == Data Analysis == | ||
=== Getting raw data from the scanner === | === Getting raw data from the scanner === | ||
After a scan you will need to get the data from the scanner to our server. | After a scan you will need to get the data from the scanner to our server. First you will need to make sure you have a VUIIS account. You can request account access here: | ||
https://www.vuiis.vanderbilt.edu/forms/VUIISaccountRequest.php | |||
Be sure to not use the same password that you use for e-mail, etc., even though you are still going to use your VUnet ID. | |||
=== | === Creating a cortical surface model === | ||
It's easier to view fMRI data on a 3D cortical surface model instead in SUMA of slice by slice in the AFNI. The process takes a while to run (~8) and is best done overnight. To make sure your computer continues to run while you are away, you'll need to configure your energy settings. Go to System Preferences > Energy Saver and click "Prevent computer from sleeping automatically when the display is off". This allow your computer to continue to run even when the screen saver comes on. | |||
Latest revision as of 07:16, 27 May 2014
<html><style type='text/css'> .tabs {
width: 640px; font-family: arial; color:#ffffff;
}
.tabs strong{
color: #851e21;
} </style></html>
Wallace Lab
|
Before you BeginBefore you begin running fMRI studies you'll need to get access to CORES so that you can book time on the scanner. You may be able to be added to an existing project. Work with Walter to set up access with the appropriate people. Experiment DesignTypes of fMRI designThere are 3 main types of scan series that you will use in an fMRI experiment. Rapid Event-RelatedBlock DesignResting StateCreating CodeTo run an fMRI experiment you'll need to write some code that will interface with the scanner and present stimuli in the right order at the right time. For the most part, creating new code will involve taking someone's old code and updating the stimulus array variable. It's a good idea to test things out at the mock scanner in case the scanner software was updated in a way that no longer works well with the code, or if an errant comma or semi-colon found its way into the the code. When creating a stimulus array for a rapid event-related fMRI experiment, you'll need to pseudo-randomize the stimulus order in a way that is compatible for deconvolution analysis. The best way to do this is a program called optseq2. SoftwareXCode and TerminalIf you would like to analyze fMRI data with AFNI, you will need to set up XCode and terminal. The following instructions are for a Mac computer. In terminal, we first need to change the shell. Open a terminal window, then go to Terminal > Preferences on the menu bar. Under the Startup tab, go to Shells open with: section. Click Command and type: /bin/tcsh and then close the window. Terminal will now open with tcsh instead of bash. If you want you can also go to the Settings tab of the Preferences pane and change the colors of the terminal window. Some people find a dark background with white text more eye friendly. Click your desired color scheme then press default. It's a good idea to have a .cshrc file, which will help you set up your path every time you open terminal. If you don't already have one, you can create one with the following command touch ~/.cshrc If you've already created a .cshrc file, enter the following command into terminal: open -e ~/.cshrc The following path commands are good to have in your .cshrc file. Be sure to double check that these path locations are where each program is located on your computer, and make adjustments as needed. set path = ( $path /sw/bin /Applications/AFNI/ /Applications/MATLAB_R2011a.app/bin) setenv DYLD_FALLBACK_LIBRARY_PATH /Applications/afni If you have a different version of Matlab, be sure to change the MATLAB folder as appropriate. Any time you make changes to your .cshrc file, these changes will only apply to "new" terminal windows. If your problem isn't solved after you make .cshrc changes, be sure you're working in a new window. AFNIAFNI is a software package for processing, analyzing, and displaying fMRI data. It is freely available from the NIH. Other packages for fMRI data analysis exist, but Sarah can't help you with them. It's a good idea to get AFNI up and running before you begin data collection and analysis. You can download the latest version of AFNI at http://afni.nimh.nih.gov/afni/download/afni/releases/latest When the file finishes downloading, you will need to double click the file to un-zip the tar file. Drag the newly created folder to the Applications directory. To more easily access the folder, rename it "afni". Next you'll need to download XQuartz since X11 is no longer automatically included in new Mac operating systems. You can download it here http://xquartz.macosforge.org/landing/ You'll need to log out and then log back in to make XQuartz the default X11 app. When you log back in, open terminal and simply type the command 'afni'. This should launch AFNI.
Updating AFNIMany problems can occur if your afni verion is not up to date. To update, first type the following command into terminal: afni -version If your afni version is more than a month old, it's time to update. To update, type: @update.afni.binaries -defaults Finally, after you update you must enter the command rehash FreeSurferFreeSurfer is an open source software package that is used in conjunction with other neuroimaging programs to analyze MRI data. Our main use will be the program optseq (see below) and reconall (for cortical surface reconstruction). Their download page also includes a wiki that may help with troubleshooting if necessary. To download FreeSurfer, go here: https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall To set that, you next need to download FreeSurfer (from the original link, click on Download). Download the package appropriate for your operating system. It's a big file (a few GB's) so it might take a while. Go get a coffee. After you've finished installing it, you should see the freesurfer folder under Applications. Next, we need to make sure the computer can be directed to the location of freesurfer. You will need to add FreeSurfer to your .cshrc file. You can do so with the following commands: echo ‘setenv FREESURFER_HOME /Applications/freesurfer‘ >> ~/.cshrc echo ‘source $FREESURFER_HOME/SetUpFreeSurfer.csh' >> ~/.cshrc You'll note that there are multiple ways to add text to the .cshrc file, either directly through the terminal window or by manually opening the file. Both ways work, it just depends on what you're comfortable with. There will be other lines you'll need in your .cshrc file to direct to other programs, they should be listed in the section of this wiki about that program. You'll also need a license to run FreeSurfer. Happily, it's free. Go to the Registration tab under the download link listed above and fill out the form. You should receive an e-mail with text that you need to copy into the license file. This part is a little tricky. First, open a text file called .license: touch .license open -e .license Copy and paste the 3 lines from the FreeSurfer registration e-mail into this text file. Files that start with a . are a bit tricky because they are hidden if you tried to find them in the finder window. Next we need to move the .license file to the right folder (set by $FREESURFER_HOME). sudo cp .license $FREESURFER_HOME To test that everything is working correctly, type: which freesurfer and the response should be the location of the freesurfer folder. OptseqPart 1Optseq is a FreeSurfer package for determining optimal randomization of events for rapid event related fMRI. This needs to be 'optimally random' because the HDR during RER fMRI significantly overlaps (HDR typically peaks 4-6 seconds after stimulus onset, and events are usually presented ~ every 2 seconds). Download the package as appropriate for your operating system. http://surfer.nmr.mgh.harvard.edu/optseq/ Here are the parameters you'll need to set: set tr = 2 #length of TR, typically 2 seconds set numev = 30 #number of trials per condition (remember to leave room for null trials! for example, if doing a run of 150 TR and 4 stimuli, you could have 30 stim per condition per run) set numtar = 20 #number of target trials, the remaining 10 will be control (null) trials set out = {insert file name here} It is important to have 5 NULL trials at the end to allow the HDR from the last trial to rise and fall. Therefore, if you would like the run to be 150 TRs, you may actually want to set -ntp to be 145 and then manually add 5 NULL's yourself. To run the program: /Applications/freesurfer/bin/optseq2 \ --tsearch 0.001 \ --psdwin 0 16 2 \ --nkeep 8 --o {$out} \ --ntp 150 --tr {$tr} \ --ev stimulus1 {$tr} $numev \ --ev stimulus2 {$tr} $numev \ --ev stimulus3 {$tr} $numev \ --ev stimulus4 {$tr} $numev \ --ev stimulus5 {$tr} $numev \ --ev target {$tr} $numtar \ You should see that there is a fair amount of customization available. For example, if you don't need target trials, you can delete this line (just be sure that the last line is not followed by a \, this tells terminal that there is still more code to come). Replace "stimulus1" etc. with the name of that category (ex: AVcongruent, McGurk, etc.). If you want, you can have a different number of trials per condition. The parameter tsearch indicates the number of hours you want to let the computer run. The parameter nkeep will keep the best X number of run orders. Do NOT change the psdwin parameters unless you absolutely know what you're doing. The output will be in your current folder. It is advisable to keep track in a text file the parameters you used to create the run order in case you need to refer to them later. If you open one of the .par file outputs, you will find the exact time the stimulus will be presented, stim type (in order given by your inputs), number of seconds for each trial, and the last column is the name of the stimulus. Part 2Part 2 involves transforming the .par output into a useable format. This can easily be done in Matlab. You may need to adjust given your intended stimulus presentation software for your experiment (E-Prime, Psychtoolbox, Presentation, etc.). Data AnalysisGetting raw data from the scannerAfter a scan you will need to get the data from the scanner to our server. First you will need to make sure you have a VUIIS account. You can request account access here: https://www.vuiis.vanderbilt.edu/forms/VUIISaccountRequest.php Be sure to not use the same password that you use for e-mail, etc., even though you are still going to use your VUnet ID. Creating a cortical surface modelIt's easier to view fMRI data on a 3D cortical surface model instead in SUMA of slice by slice in the AFNI. The process takes a while to run (~8) and is best done overnight. To make sure your computer continues to run while you are away, you'll need to configure your energy settings. Go to System Preferences > Energy Saver and click "Prevent computer from sleeping automatically when the display is off". This allow your computer to continue to run even when the screen saver comes on. |