How-Tos - Realignment
How do I...
- Do realignment in SPM?
- Do motion correction in AFNI?
- Do unwarping in SPM?
- Figure out how much my motion parameters correlate with my paradigm?
- Figure out if I should include my motion parameters in my design matrix?
- Include my motion parameters in my design matrix?
- Use a non-intensity-based algorithm for realignment (see Friere & Mangin in RealignmentPapers)?
Realignment works in two stages. First, the first files from each session are realigned to the the first file of the first session. Second, within each session, the second, third, etc... (2..n) images are realigned to the first image of the session. Thus, after realignment, all files are effectively realigned to the first file of the first session.
The process produces text files with the estimated realignment (or motion) parameters for each session. These are the rp_V001.txt (or realignment_params_V001.txt) stored in each session's directory. They contain 6 columns and one row for each V-file.
The columns are the estimated translations in mm ("right", "forward", "up") and the estimated rotations in rad ("pitch", "roll", "yaw") that are needed to shift each V-file.
These text files can be used later at the statistics stages to enter the estimated motion parameters as user-specified regressors in the design matrix. If you choose 'all images' in 'Create What?', realignment will create r*.img files. The process usually takes several hours, depending on the total number of V-files and the computer you're using.
Number of subjects: You'd most likely enter 1 here.
Num sessions for subject 1: Enter the number of sessions for the entire experiment.
Select SCAN1/V*.img , then click DONE.
scans for subj 1, sess2: Select SCAN2/V*.img, then click DONE.
Repeat the same until all sessions (and subjects) are done.
Select the default, coregister & reslice.
- Selecting coregister & reslice will both realign the selected files and produce new *.mat files. The files produced will depend on what is entered in response to the "Create what?" prompt below.
Select the default, Sinc Interpolation.
Select mean image only.
- Mean image only will produce only one new mean_V001.img file, without reslicing the selected V*.img files. If normalization will be performed next, there is no need to reslice the aV*.img files at this stage. The transformation parameters saved in the aV*.mat file to each image will be applied to the images during the normalization stages. This way, the images will be resliced only once. In general, unnecessary reslicing should be avoided, because the images lose some spatial resolution every time it's performed.
Adjust sampling errors? No. (See RealignmentFaq for why.)
Realignment will produce the following chart of the corrections made and save it to the spm99.ps file:
SPM: You'll include your motion parameters as user-specified regressors in your design matrix (see BasicStatisticalModelingFaq for more on user-specified regressors). In order to include them, you'll need to have already run realignment, and you'll need to know where your realignment parameters file are (rp_V001.txt, or realignment_parameters_V001.txt). Usually they can be located in each session's functional image directory - one parameter file for each session.
Begin setting up your design matrix as usual (see BasicStatisticalModelingHowTos for step-by-step instructions). When asked if your conditions are replicated between sessions, say "no."
You'll be asked about your onset vectors and parametric modulations for each condition. After you've entered in your conditions for the first session, you'll be asked how many user-specified regressors you want. Enter "6."
When you're prompted to enter the regressor, type spm_load. This will bring up a file menu. Choose the realignment parameters file for the first session.
You'll then be asked to enter the names for each regressor. You can leave them as default, but if you'd like to label them in the design matrix, you should enter, in order, "x," "y," "z," "pitch," "roll," and "yaw."
Repeat the same steps for each session in your experiment. Your design matrix should then contain the motion parameters as separate columns in your design matrix. You should leave them out of most contrasts, but you can make contrasts with them to see motion-related activity in your experiment.
If you want to enter some derivation of your motion parameters - like the sine or cosine, or temporal derivative of them - you can embed the spm_load command into a Matlab function, like sin or abs. In this case, instead of typing simply spm_load at the prompt, you'll enter sin(spm_load), for example. If the derivation you want isn't a simple Matlab function which operates on every element of a matrix, you'll need to construct it in the Matlab workspace before you start entering your model, and refer to it by variable name instead.