Differences between revisions 7 and 8
 Deletions are marked like this. Additions are marked like this. Line 384: Line 384: In this example, we're demonstrating what the effect will be when adding control points at the very beginning of the stream - in the cross-sectionals. Find all the slices that have this problem and add control points carefully on the wm voxels. In this example, we're demonstrating what the effect will be when adding control points at the very beginning of the stream - in the cross-sectionals. Find all the slices that have this problem and add control points carefully on the wm voxels. Line 388: Line 388: Here is what we did. Left - OAS2_0121_MR1 (slice 90) and right - OAS2_0121_MR2 (slice 92). <
> {{attachment:cp_slice_90_before.jpg||height="500px",width="500px}} {{attachment:cp_slice_92_before.jpg||height="500px",width="500px}} You want to add control points at the stem of white matter strands where voxel values are below 110. You can also add control points along the strand. Here is an example of where we added control points in the same two slices mentioned above. Left - OAS2_0121_MR1 (slice 90) and right - OAS2_0121_MR2 (slice 92). <
> {{attachment:cp_slice_92_after.jpg||height="500px",width="500px}} {{attachment:cp_slice_92_before.jpg||height="500px",width="500px}} You want to add control points at the stem of white matter strands where voxel values are below 110. You can also add control points along the strand. Here is what we did. For cross sectional time point 1 (OAS2_0121_MR1), here is an example of coronal slice 90 before (left) and after (right) control points were added and the cross sectional was re-run.<
> {{attachment:cp_slice_90_before.jpg||height="500px",width="500px}} {{attachment:cp_slice_90_after.jpg||height="500px",width="500px}} For cross time point 2 (OAS2_0121_MR2), here is an example of coronal slice 92 before and after control points are added <
> {{attachment:cp_slice_92_before.jpg||height="500px",width="500px}} {{attachment:cp_slice_92_after.jpg||height="500px",width="500px}}

Longitudinal Processing - Tutorial

1. Preparations

If you are taking one of the formally organized courses, everything has been set up for you on the provided laptop. The only thing you will need to do is run the following commands in every new terminal window (aka shell) you open throughout this tutorial. Copy and paste the commands below to get started:

export SUBJECTS_DIR=\$TUTORIAL_DATA/long-tutorial
cd \$SUBJECTS_DIR

To copy: Highlight the command in the box above, right click and select copy (or use keyboard shortcut Ctrl+c), then use the middle button of your mouse to click inside the terminal window to paste the command (or use keyboard shortcut Ctrl+Shift+v). Press enter to run the command.

These two commands set the SUBJECTS_DIR variable to the directory where the data is stored and then navigates into this directory.

If you are NOT taking one of the formally organized courses, click here.

2. Longitudinal Image Processing

All data for this tutorial has already been processed for you since processing can take up to 24h. However, to continue you need to understand the three processing steps (cross, base, long) and associated directory names.

For example, assume you have a subject with two time points: OAS2_0001_MR1 and OAS2_0001_MR2.

1. [CROSS]: You would process these two images independently first (we call that cross as in crossectional analysis/processing) using the regular FreeSurfer processing stream (recon-all). You end up with two directories with the names OAS2_0001_MR1 and OAS2_0001_MR2

2. [BASE]: Then you would run the second step to create the within subject template (also called base) and end up with a new directory. There is only one base directory per subject. We decide to name the base: OAS2_0001. Inside this directory are the results for the average anatomy of your subject across time. You don't use this data in any analysis, and only look at it for quality checking or editing.

3. [LONG]: Finally you would create the two longitudinal runs (the ones you are actually interested in). You end up with two more directories (these names get automatically assigned): OAS2_0001_MR1.long.OAS2_0001 and OAS2_0001_MR2.long.OAS2_0001. They contain the final, most reliable and accurate processing results.

You can now continue with the next section (inspecting the data).

3. Inspecting Longitudinal Data

We use freeview (FreeviewGuide) as a viewer in this tutorial.

First let's check the base (subject template) of a single subject. Open the norm.mgz and surfaces with freeview. If you run the following command and freeview opens in another view, you can click on the Coronal button in order to see the data in the same view:

freeview -v OAS2_0001/mri/norm.mgz \
-f OAS2_0001/surf/lh.pial:edgecolor=red \
OAS2_0001/surf/rh.pial:edgecolor=red \
OAS2_0001/surf/lh.white:edgecolor=blue \
OAS2_0001/surf/rh.white:edgecolor=blue

This will show you the within-subject template (base), i.e., the average anatomy of this subject across time overlayed with the pial and white surface. If the across-time registration failed you would see a blurry image or ghosting. You should inspect the surfaces on this image. This will be important later as the surfaces are transferred into the longitudinal runs and therefore should be accurate in the base. Move back and forth to inspect all slices and see if the surfaces follow the white matter and gray matter boundaries.

Now it is time to look at the longitudinal results. Starting with FreeSurfer 5.1, the base and the long volumes are all in the same voxel space, meaning that volumes across time are anatomically aligned and can be directly compared if opened on top of each other ). Close any open freeview window to reduce memory usage and run the following command:

freeview -v OAS2_0001_MR1.long.OAS2_0001/mri/norm.mgz \
OAS2_0001_MR2.long.OAS2_0001/mri/norm.mgz \
-f OAS2_0001_MR1.long.OAS2_0001/surf/lh.pial:edgecolor=red \
OAS2_0001_MR1.long.OAS2_0001/surf/lh.white:edgecolor=blue \
OAS2_0001_MR2.long.OAS2_0001/surf/lh.pial:edgecolor=255,128,128 \
OAS2_0001_MR2.long.OAS2_0001/surf/lh.white:edgecolor=lightblue

This might take a while to load (check the progress bar). You will see the normalized skull stripped images (norm.mgz) of both time points on top of each other (the second time point is the top-most layer and so the only one visible at the moment). You also see the white and pial surface for each time point, drawn on top of each other (we only show the left hemisphere here to reduce memory usage for older computers). Time point 1 uses red and blue while time point 2 uses pink and light blue for the surface colors. The surfaces do not change much across time. You can also compare the images directly. For this, uncheck the 4 check boxes in front of all the surfaces, or press 'Ctrl-f'. Select the first (top) norm volume and use the opacity slider to blend between the two images. You can also switch back and forth between the two images by pressing 'Alt-c' or using the opacity slider. This way you can spot longitudinal deformations (atrophy) and also potential global alignment problems (not in this case). You will mainly notice that the ventricles are getting larger in the second time point. You can use the Up and Down arrow keys to scroll through the slices. Close freeview when done.

4. Post-Processing Longitudinal Data

4.1. Longitudinal QDEC Table

(Also: LongitudinalQdecTable)

To get the longitudinal data ready for the statistical analysis, you need to create a table (space separated as a text file) in the following format:

 fsid fsid-base years ... OAS2_0001_MR1 OAS2_0001 0 OAS2_0001_MR2 OAS2_0001 1.25 OAS2_0004_MR1 OAS2_0004 0 OAS2_0004_MR2 OAS2_0004 1.47 ...

where the first column is called fsid (containing each time point) and the second column is fsid-base containing the base name, to group time points within subject. You can have many more columns such as gender, age, group, drug, etc. Make sure there is a column containing an accurate time variable (optimally measured in years if you are interested in yearly change) such as age or the duration of the study (time from initial scan). Here we use years to measure the time from baseline scan (=tp1). You can see in the table that the two subjects OAS2_0001 and OAS2_0004 each have two time points (MR1,MR2) that are not equally spaced (approx 15 and 18 months apart). We have created this table for you in the qdec subdirectory for the tutorial data and can get started right away. You can look at the file by opening it in your favourite spreadsheet editor, e.g.:

libreoffice -calc qdec/long.qdec.table.dat

or, if that fails, a simple text editor:

gedit qdec/long.qdec.table.dat

NOTE: For Mac users, you can try Numbers, Excel or a simple text editor:

open qdec/long.qdec.table.dat -a Numbers

open qdec/long.qdec.table.dat -a "Microsoft Excel"

open -e qdec/long.qdec.table.dat

4.2. What kind of statistical analysis to perform?

FreeSurfer offers different ways to analyze longitudinal data (details: LongitudinalStatistics). The GLM and QDEC group analysis tutorials teach you how to run some simple statistical analyses on thickness maps (e.g. to find cortical regions with different thickness across groups). In this tutorial we will describe how to get your longitudinal data ready for statistical analysis, but not to do the actual model fitting.

The two most frequently used models are the simple two-stage model (LongitudinalTwoStageModel) and a fully flexible mixed effects model (LinearMixedEffectsModels) (LME), which is recommended for statistical analysis but requires Matlab knowledge. LME can, for example, deal with different time deltas and time points, missing data, and include subjects with only a single time point. The 2-stage model on the other hand, first performs a linear fit in each subject independently to reduce the repeated measures to a single number (slope, such as mm/year) and then performs a regular cross sectional analysis across subjects (e.g. to look for age or group effects).

Users who are interested in preparing data for the more powerful and complex mixed effects modeling can see how it is done by clicking here.

In this tutorial, we will prepare the data for a simple statistical model for longitudinal data, consisting of two stages:

1. We reduce repeated measures to a single number for each subject. For example, quantifying atrophy rates (as mm/year thinning or percent change).
2. This measure can then be compared across groups (e.g. with a standard QDEC or glm_fit analysis) to detect disease or treatment effects.

4.3. Preparing the Thickness Data - QCACHE

The following command can be used to prepare the data:

Don't run this command

It will take a while and has already been done for you.

long_mris_slopes --qdec ./qdec/long.qdec.table.dat --meas thickness --hemi lh --do-avg --do-rate --do-pc1 --do-spc --do-stack --do-label --time years --qcache fsaverage --sd \$SUBJECTS_DIR

This will:

• (--qdec) read in the qdec table
• (--meas thickness) take the thickness measure of each time point
• (--hemi) specify which hemisphere to work on (here 'lh' specified)
• (--do-avg) compute the temporal average (thickness at midpoint of linear fit, here it is just the average)
• (--do-rate) compute the rate of change (thickening in mm/year)
• (--do-pc1) compute the percent change (with respect to time point 1)
• (--do-spc) compute a symmetrized percent change (with respect to the temporal average)
• (--do-stack) output a stacked thickness file for each subject (time series)
• (--do-label) intersect the cortex label to ensure we don't include non-cortex regions
• (--time) specify the column in the longqdec.table.dat that contains the time variable (here 'years' specified)
• (--qcache) and automatically smooth everything on different levels and map it to fsaverage (note how this is specified after the flag) for a potential group analysis using qdec
• (--sd) specify the subject directory (needs to be passed explicitly since FS 5.2)

We pass all these parameters as an example. Usually you will not compute the average, select rate, pc1 or spc (depending on what you are interested in) and not explicitly write out the stack which is used for debugging (so drop --do-avg and --do-stack and select from --do-rate, --do-pc1 or do-spc). You then need to run the same command for the right hemisphere (--hemi rh).

(Note, if you split your table up into smaller tables containing only information for a specific subject each, you can run this on a cluster in parallel for each subject to speed things up (you can use the commands below to split the table up into individual subjects inside the qdec directory).

cd qdec
long_qdec_table --qdec ./long.qdec.table.dat --split fsid-base
cd ..

Now before continuing, let's get an idea about what the above four measures mean in our setting (with only two time points):

1. The temporal average is simply the average thickness: avg = 0.5 * (thick1 + thick2), usually you don't want to analyse this, as you are mainly interested in change.

2. The rate of change is the difference per time unit, so rate = ( thick2 - thick1 ) / (time2 - time1), here thickening in mm/year. In aging or disease we expect it to be negative in most regions (because of noise not necessarily for a single subject, but on average). For more than two time points, this is the slope of the linear fit.

3. The percent change (pc1) is the rate with respect to the thickness at the first time point: pc1 = rate / thick1. We also expect it to be negative and it tells how much percent thinning we have at a given cortical location.

4. The symmetrized percent change (spc) is the rate with respect to the average thickness: spc = rate / avg. This is a more robust measure than pc1, because thickness at time point 1 is more noisy than the average. Also spc is symmetric: when reversing the order of tp1 and tp2 it switches sign. This is not true for pc1. Therefore, and for other reasons related to increased statistical power, we recommend to use spc.

So let's investigate (some of) the results, which can be found in each base surf directory. Call this to open up the pial surface (left hemi) of subject OAS2_0001:

freeview -f OAS2_0001/surf/lh.pial:overlay=OAS2_0001/surf/lh.long.thickness-avg.fwhm15.mgh:overlay_threshold=0,3.5:overlay=OAS2_0001/surf/lh.long.thickness-stack.mgh:annot=OAS2_0001/label/lh.aparc.annot:annot_outline=1 --timecourse --colorscale --viewport 3d

Click on the 3D view button if freeview opens in a different view from what is depicted in the screenshot below, then click somewhere on the cortex to see the time course data at that location.

You are looking at the smoothed average thickness (color overlay) with values between 1 (red) and >3 mm (yellow). If you click at any location on the surface you can see a plot of the two original (unsmoothed) thickness values at the two time points. We also opened the cortical parcellation (aparc, using the annot flag) in outline style, which can be switched on and off. It helps to find out what region you are inspecting when clicking on the surface. For a single subject values are often noisy even after smoothing and show local thinning and thickening. That is why for a group analysis one needs several subjects in each group. The yellow lines/curves in the main window on the surface show the intersection of the three planes with the cortex at the selected location, and can be ignored.

For users with only an older Freeview version (no support for time course), you can use tksurfer to achieve the same (no need to do it in the course):

tksurfer OAS2_0001 lh pial -overlay \$SUBJECTS_DIR/OAS2_0001/surf/lh.long.thickness-avg.fwhm15.mgh -timecourse \$SUBJECTS_DIR/OAS2_0001/surf/lh.long.thickness-stack.mgh -aparc

In a similar fashion, you can open, for example, the symmetrized percent change. Close any open freeview windows. This time we open the overlay on fsaverage, an average subject provided with FreeSurfer and often used as the common target to compare results across subjects. The --qcache flag of long_mris_slopes has conveniently registered and mapped all results to this average subject:

freeview -f fsaverage/surf/lh.pial:overlay=\$SUBJECTS_DIR/OAS2_0001/surf/lh.long.thickness-spc.fwhm15.fsaverage.mgh:overlay_threshold=2,5

note the 'fsaverage' in the filename. Because there is not much change on the surfaces, the SPC will be even more noisy than the average. You can use the above commands to investigate individual results, but this is rarely necessary.

Since FS5.2: Similar to the long_mris_slopes command above to compute thickness change, you can use long_stats_slopes to compute subject rates, percent changes, etc. for the ROI stats (aseg or aparc, i.e. subcortical and cortical ROI volumes and average thickness). Once you reduced the measures to a single number per subject, you can compare groups similar to a cross sectional analysis (e.g. using mri_glm_fit).

Close freeview when finished.

In order to run a QDEC group analysis (described in the QDEC tutorial), you need a qdec table. Since qdec cannot directly work with the longitudinal qdec table format, you have to shrink it into a cross sectional form. Use

long_qdec_table --qdec ./qdec/long.qdec.table.dat --cross --out ./qdec/cross.qdec.table.dat

to create a table with only a single line for each subject. For each subject, numerical values such as age or height will be averaged across time, other values will be copied from the first time point for each subject as ordered in the input table.

Also QDEC will not know about our new files (e.g. lh.long.thickness-spc...), that you created above with long_mris_slopes. We can tell it to look for them by creating a \$SUBJECTS_DIR/qdec/.Qdecrc file (it needs to be in the qdec directory) that contains the following lines:

MEASURE1 = long.thickness-avg
MEASURE2 = long.thickness-rate
MEASURE3 = long.thickness-pc1
MEASURE4 = long.thickness-spc

(This has already been created for the tutorial data. If you are running your own data, make sure you create this file in the \$SUBJECTS_DIR/qdec directory!)

You can then run qdec and do all kinds of analysis on any of those files and other variables from the qdec table:

qdec --table ./qdec/cross.qdec.table.dat

You will see in the Design tab, that you can now select e.g. long.thickness-rate under Measure as the dependent variable. Check out the QDEC tutorial to see how to run a qdec analysis.

5. Editing Longitudinal Data

Editing longitudinal data can be complicated, but in some cases you actually save time, as some edits are only necessary in the base. You should be familiar with Edits and might want to check also the page about LongitudinalEdits. To refresh how to perform edits using Freeview, navigate to the FreeviewGuide.

Here are some examples of some common errors you can encounter with your data. Notes: Because some of the recons take a while to run and it is not practical for you to run them during this short period of time, we ran the edits ahead of time. You will see that the edited and re-processed version have the postfix '_fixed'.

Before starting each section, remember to do the following to any new terminal you open:

export SUBJECTS_DIR=\$TUTORIAL_DATA/long-tutorial
cd \$SUBJECTS_DIR

5.1. Skullstrip Error

The most common type of skull strip failures you probably will see has to do with the cerebellum: Often, part of the cerebellum is stripped off (as you have seen in the skull strip tutorial in the troubleshooting portion earlier). Sometimes skull stripping will also leave too much dura behind. For either case, the best way to solve the problem is to adjust the watershed parameters.

Very rarely, you will see FreeSurfer fail completely in the skullstrip step (usually associated with many other errors) as is clearly the case in the following example. For the purpose of this tutorial, we will only focus on and fix the skull strip error in this case.

Please take a look at the base for subject OAS2_0004:

freeview -v OAS2_0004/mri/T1.mgz \
-f OAS2_0004/surf/lh.pial:edgecolor=red \
OAS2_0004/surf/rh.pial:edgecolor=red \
OAS2_0004/surf/lh.white:edgecolor=blue \
OAS2_0004/surf/rh.white:edgecolor=blue

This looks pretty bad. In order to find out what causes these problems, it is important to also check the cross-sectional runs for the same subject to see if the problem is present there.

You can open the cross subjects with the commands below. NOTE: We suggest only opening one freeview window at a time if you are using an old computer or one without much RAM. Freeview uses a large amount of memory, and may slow down your computer.

freeview -v OAS2_0004_MR1/mri/T1.mgz \
-f OAS2_0004_MR1/surf/lh.pial:edgecolor=red \
OAS2_0004_MR1/surf/rh.pial:edgecolor=red \
OAS2_0004_MR1/surf/lh.white:edgecolor=blue \
OAS2_0004_MR1/surf/rh.white:edgecolor=blue

freeview -v OAS2_0004_MR2/mri/T1.mgz \
-f OAS2_0004_MR2/surf/lh.pial:edgecolor=red \
OAS2_0004_MR2/surf/rh.pial:edgecolor=red \
OAS2_0004_MR2/surf/lh.white:edgecolor=blue \
OAS2_0004_MR2/surf/rh.white:edgecolor=blue

Usually, if the base and cross runs were OK, you would also open the long subjects, but that is not necessary here. For completeness, these would be the commands:

freeview -v OAS2_0004_MR1.long.OAS2_0004/mri/T1.mgz \
-f OAS2_0004_MR1.long.OAS2_0004/surf/lh.pial:edgecolor=red \
OAS2_0004_MR1.long.OAS2_0004/surf/rh.pial:edgecolor=red \
OAS2_0004_MR1.long.OAS2_0004/surf/lh.white:edgecolor=blue \
OAS2_0004_MR1.long.OAS2_0004/surf/rh.white:edgecolor=blue

freeview -v OAS2_0004_MR2.long.OAS2_0004/mri/T1.mgz \
-f OAS2_0004_MR2.long.OAS2_0004/surf/lh.pial:edgecolor=red \
OAS2_0004_MR2.long.OAS2_0004/surf/rh.pial:edgecolor=red \
OAS2_0004_MR2.long.OAS2_0004/surf/lh.white:edgecolor=blue \
OAS2_0004_MR2.long.OAS2_0004/surf/rh.white:edgecolor=blue

These commands will open the brainmask.mgz volume, the T1.mgz, and the surfaces for both hemispheres. You can check the brainmask.mgz volume and compare it to the T1.mgz volume (use Alt+v to toggle between them).

While looking at the base helps to see that this subject's processing has a problem, it is clear that the cross sectional processing already fails. You can see a description of how to fix it here along with the edited version.

Sometimes you will come across a case where you need to make edits to the brainmask.mgz to correct the pial surfaces. Open subject OAS2_0057 to see where and how this type of edit should be done.

First, open the base:

freeview -v OAS2_0057/mri/T1.mgz \
-f OAS2_0057/surf/lh.pial:edgecolor=red \
OAS2_0057/surf/rh.pial:edgecolor=red \
OAS2_0057/surf/lh.white:edgecolor=blue \
OAS2_0057/surf/rh.white:edgecolor=blue

This will open the brainmask.mgz volume, T1.mgz volume, and all surfaces. You can also check out the cross-sectionals and the longitudinals of this subject to check if the problem is present in all parts of the stream. NOTE: We suggest only opening one freeview window at a time if you are using an old computer or one without much RAM. Freeview uses a large amount of memory, and may slow down your computer.

freeview -v OAS2_0057_MR1/mri/T1.mgz \
-f OAS2_0057_MR1/surf/lh.pial:edgecolor=red \
OAS2_0057_MR1/surf/rh.pial:edgecolor=red \
OAS2_0057_MR1/surf/lh.white:edgecolor=blue \
OAS2_0057_MR1/surf/rh.white:edgecolor=blue

freeview -v OAS2_0057_MR2/mri/T1.mgz \
-f OAS2_0057_MR2/surf/lh.pial:edgecolor=red \
OAS2_0057_MR2/surf/rh.pial:edgecolor=red \
OAS2_0057_MR2/surf/lh.white:edgecolor=blue \
OAS2_0057_MR2/surf/rh.white:edgecolor=blue

freeview -v OAS2_0057_MR1.long.OAS2_0057/mri/T1.mgz \
-f OAS2_0057_MR1.long.OAS2_0057/surf/lh.pial:edgecolor=red \
OAS2_0057_MR1.long.OAS2_0057/surf/rh.pial:edgecolor=red \
OAS2_0057_MR1.long.OAS2_0057/surf/lh.white:edgecolor=blue \
OAS2_0057_MR1.long.OAS2_0057/surf/rh.white:edgecolor=blue

freeview -v OAS2_0057_MR2.long.OAS2_0057/mri/T1.mgz \
-f OAS2_0057_MR2.long.OAS2_0057/surf/lh.pial:edgecolor=red \
OAS2_0057_MR2.long.OAS2_0057/surf/rh.pial:edgecolor=red \
OAS2_0057_MR2.long.OAS2_0057/surf/lh.white:edgecolor=blue \
OAS2_0057_MR2.long.OAS2_0057/surf/rh.white:edgecolor=blue

See if you can find the slices where you will need to edit the braimask.mgz in order to correct the surfaces. You can click here for a detailed description on how and at which stage you can fix this problem.

5.3. Control Points Edits

Sometimes, there are areas in the white matter with intensity lower than 110 and where the wm is not included in the surfaces. The best way to fix this problem is to add control points.

Take a look at the next subject, OAS2_0121 in all cross, base, and long to see if you can find the places that need control points. NOTE: We suggest only opening one freeview window at a time if you are using an old computer or one without much RAM. Freeview uses a large amount of memory, and may slow down your computer.

freeview -v OAS2_0121_MR1/mri/T1.mgz \
-f OAS2_0121_MR1/surf/lh.pial:edgecolor=red \
OAS2_0121_MR1/surf/rh.pial:edgecolor=red \
OAS2_0121_MR1/surf/lh.white:edgecolor=blue \
OAS2_0121_MR1/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121_MR2/mri/T1.mgz \
-f OAS2_0121_MR2/surf/lh.pial:edgecolor=red \
OAS2_0121_MR2/surf/rh.pial:edgecolor=red \
OAS2_0121_MR2/surf/lh.white:edgecolor=blue \
OAS2_0121_MR2/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121/mri/T1.mgz \
-f OAS2_0121/surf/lh.pial:edgecolor=red \
OAS2_0121/surf/rh.pial:edgecolor=red \
OAS2_0121/surf/lh.white:edgecolor=blue \
OAS2_0121/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121_MR1.long.OAS2_0121/mri/T1.mgz \
-f OAS2_0121_MR1.long.OAS2_0121/surf/lh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121/surf/rh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121/surf/lh.white:edgecolor=blue \
OAS2_0121_MR1.long.OAS2_0121/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121_MR2.long.OAS2_0121/mri/T1.mgz \
-f OAS2_0121_MR2.long.OAS2_0121/surf/lh.pial:edgecolor=red \
OAS2_0121_MR2.long.OAS2_0121/surf/rh.pial:edgecolor=red \
OAS2_0121_MR2.long.OAS2_0121/surf/lh.white:edgecolor=blue \
OAS2_0121_MR2.long.OAS2_0121/surf/rh.white:edgecolor=blue

6. Using Control Points to Fix Intensity Normalization

Notice that the intensity for the area in the bottom corner of the right hemisphere around slice 90 is only around 90 something instead of 110, and the surfaces here do not include all of the gm and wm. Because this problem occurs in both cross-sectionals, the base and subsequently the longitudinals are also affected. In cases like this, it depends on which data you are planning to use, you can choose to edit either the cross, base, or long. Control points work in all three stages.

In this example, we're demonstrating what the effect will be when adding control points at the very beginning of the stream - in the cross-sectionals. Find all the slices that have this problem and add control points carefully on the wm voxels.

6.1. Fixing the cross

You want to add control points at the stem of white matter strands where voxel values are below 110. You can also add control points along the strand. Here is what we did. For cross sectional time point 1 (OAS2_0121_MR1), here is an example of coronal slice 90 before (left) and after (right) control points were added and the cross sectional was re-run.

For cross time point 2 (OAS2_0121_MR2), here is an example of coronal slice 92 before and after control points are added

Once you are satisfied with your control points placements, save it, and run the following commands to complete the fixed cross sectional runs:

It will take hours and has already been done for you.

recon-all -subjid OAS2_0121_MR1 -autorecon2 -autorecon3

recon-all -subjid OAS2_0121_MR2 -autorecon2 -autorecon3

After that is complete (or when the CA normalization step is complete - you can check in the recon-all-status.log), you can start rerunning the base (remember to delete or rename the base if it already existed, e.g. mv OAS2_0121 OAS2_0121_old). Or, if you prefer, you can wait until the recons are complete to check whether you are satisfied with the results before beginning the next step.

To inspect the fixed version of these two timepoints, run:

freeview -v OAS2_0121_MR1_fixed/mri/T1.mgz \
-f OAS2_0121_MR1_fixed/surf/lh.pial:edgecolor=red \
OAS2_0121_MR1_fixed/surf/rh.pial:edgecolor=red \
OAS2_0121_MR1_fixed/surf/lh.white:edgecolor=blue \
OAS2_0121_MR1_fixed/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121_MR2_fixed/mri/T1.mgz \
-f OAS2_0121_MR2_fixed/surf/lh.pial:edgecolor=red \
OAS2_0121_MR2_fixed/surf/rh.pial:edgecolor=red \
OAS2_0121_MR2_fixed/surf/lh.white:edgecolor=blue \
OAS2_0121_MR2_fixed/surf/rh.white:edgecolor=blue

6.2. Fixing/Rerunning the base

To rerun the base, you would run this command:

recon-all -base OAS2_0121 -tp OAS2_0121_MR1 -tp OAS2_0121_MR2 -all

Once you are done with the base, check to see whether the surfaces are now including all white matter (we ran the above command for you, results are in OAS2_0121_intermediate):

freeview -v OAS2_0121_intermediate/mri/T1.mgz \
-f OAS2_0121_intermediate/surf/lh.pial:edgecolor=red \
OAS2_0121_intermediate/surf/rh.pial:edgecolor=red \
OAS2_0121_intermediate/surf/lh.white:edgecolor=blue \
OAS2_0121_intermediate/surf/rh.white:edgecolor=blue

Notice that although the surfaces improved, it is not perfect. In this case, you can add more control points to the base and would rerun with the command below (you would re-run the edited base without the _intermediate suffix as that is just a intermediate copy that we created for you):

recon-all -base OAS2_0121 -autorecon2 -autorecon3

Now the base is much better. Compare these images at slice 106. These are taken from OAS2_0121_intermediate before more control points were added (below right) and OAS2_0121_fixed (below left). You can open these two volumes using Freeview, and also compare to the original base (OAS2_0121) before the cross sectionals were fixed if you want.

6.3. Rerunning the long

The last step is to rerun the longitudinals (also remove/rename existing longitudinal directories first), which would be done with these commands:

recon-all -long OAS2_0121_MR1 OAS2_0121 -all
recon-all -long OAS2_0121_MR2 OAS2_0121 -all

Compare the output below

freeview -v OAS2_0121_MR1.long.OAS2_0121/mri/T1.mgz \
-f OAS2_0121_MR1.long.OAS2_0121/surf/lh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121/surf/rh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121/surf/lh.white:edgecolor=blue \
OAS2_0121_MR1.long.OAS2_0121/surf/rh.white:edgecolor=blue

freeview -v OAS2_0121_MR1.long.OAS2_0121_fixed/mri/T1.mgz \
-f OAS2_0121_MR1.long.OAS2_0121_fixed/surf/lh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121_fixed/surf/rh.pial:edgecolor=red \
OAS2_0121_MR1.long.OAS2_0121_fixed/surf/lh.white:edgecolor=blue \
OAS2_0121_MR1.long.OAS2_0121_fixed/surf/rh.white:edgecolor=blue

For the longitudinals, control points were automatically copied over from the cross-sectionals, and the surfaces were initialized from the base, therefore making a great improvement on the surfaces at this end of the stream.

The before (left) and after (right) images from OAS2_0121_MR1.long.OAS2_0121 at slice 107.

6.4. White Matter Edits

White matter edits are possibly the most common type of edits you will come across in data. In many cases, even a difference of 1 wm voxel can cause a huge defect in the surfaces. Take a look at the following subject. For this one, we will open the brainmask.mgz volume and compare it to the wm.mgz volume instead of T1.mgz. If you're using tkmedit instead of Freeview, load wm.mgz as your "Aux Volume". NOTE: We suggest only opening one freeview window at a time if you are using an old computer or one without much RAM. Freeview uses a large amount of memory, and may slow down your computer.

freeview -v OAS2_0185/mri/wm.mgz \
-f OAS2_0185/surf/lh.pial:edgecolor=red \
OAS2_0185/surf/rh.pial:edgecolor=red \
OAS2_0185/surf/lh.white:edgecolor=blue \
OAS2_0185/surf/rh.white:edgecolor=blue

freeview -v OAS2_0185_MR1/mri/wm.mgz \
-f OAS2_0185_MR1/surf/lh.pial:edgecolor=red \
OAS2_0185_MR1/surf/rh.pial:edgecolor=red \
OAS2_0185_MR1/surf/lh.white:edgecolor=blue \
OAS2_0185_MR1/surf/rh.white:edgecolor=blue

freeview -v OAS2_0185_MR2/mri/wm.mgz \
-f OAS2_0185_MR2/surf/lh.pial:edgecolor=red \
OAS2_0185_MR2/surf/rh.pial:edgecolor=red \
OAS2_0185_MR2/surf/lh.white:edgecolor=blue \
OAS2_0185_MR2/surf/rh.white:edgecolor=blue

freeview -v OAS2_0185_MR1.long.OAS2_0185/mri/wm.mgz \
-f OAS2_0185_MR1.long.OAS2_0185/surf/lh.pial:edgecolor=red \
OAS2_0185_MR1.long.OAS2_0185/surf/rh.pial:edgecolor=red \
OAS2_0185_MR1.long.OAS2_0185/surf/lh.white:edgecolor=blue \
OAS2_0185_MR1.long.OAS2_0185/surf/rh.white:edgecolor=blue

freeview -v OAS2_0185_MR2.long.OAS2_0185/mri/wm.mgz \
-f OAS2_0185_MR2.long.OAS2_0185/surf/lh.pial:edgecolor=red \
OAS2_0185_MR2.long.OAS2_0185/surf/rh.pial:edgecolor=red \
OAS2_0185_MR2.long.OAS2_0185/surf/lh.white:edgecolor=blue \
OAS2_0185_MR2.long.OAS2_0185/surf/rh.white:edgecolor=blue

Toggle between the two volumes (use the opacity slider) and see if you can spot an area where a simple wm edit will make a huge difference to the surfaces.

7. Making white matter edits

For the longitudinal stream, it is recommended that you make wm.mgz edits to the base. This is because even though the long transfers manual wm edits from the cross, it still takes the surfaces from the base, and if the base surfaces did not improve, neither will the long. The only way to make corrections to the base surfaces themselves is to edit wm.mgz on the base. Therefore, making wm.mgz right on the base can save you a lot of time. Of course it is best to edit all stages (all cross time points and base), but often it is sufficient to edit only the base. Were you able to find the area that needs intervention? Here is what we found. You can see below on the brainmask.mgz (left) that the pial surface is cutting through the wm. If you toggle to the wm.mgz, you can see that there are a few wm voxels missing.

This happens at the tip of the lh temporal lobe within several slices. Below is an example of coronal slice 166.

Add wm voxels to connect the wm together in all the slices that need it. Here is an example of what we did in slice 168. Bright wm voxels in the temporal lobes have been manually added.

After you are satisfied with your edits, save the edited volume and rerun the base.

It will take hours and has already been done for you.

recon-all -base OAS2_0185 -autorecon2-wm -autorecon3

After that is done, check the surfaces on base using Freeview (or tkmedit for older version of Freeview).

freeview -v OAS2_0185_fixed/mri/wm.mgz \
-f OAS2_0185_fixed/surf/lh.pial:edgecolor=red \
OAS2_0185_fixed/surf/rh.pial:edgecolor=red \
OAS2_0185_fixed/surf/lh.white:edgecolor=blue \
OAS2_0185_fixed/surf/rh.white:edgecolor=blue

This is what it should look like now in slice 166.

When the surfaces are all corrected, you would recreate the long (make sure you remove the long directories before the rerun - or at the very least, remove the wm.mgz files in all the mri sub-directories of the long runs).

recon-all -long OAS2_0185_MR1 OAS2_0185 -all

recon-all -long OAS2_0185_MR2 OAS2_0185 -all

freeview -v OAS2_0185_MR1.long.OAS2_0185_fixed/mri/wm.mgz \
-f OAS2_0185_MR1.long.OAS2_0185_fixed/surf/lh.pial:edgecolor=red \
OAS2_0185_MR1.long.OAS2_0185_fixed/surf/rh.pial:edgecolor=red \
OAS2_0185_MR1.long.OAS2_0185_fixed/surf/lh.white:edgecolor=blue \
OAS2_0185_MR1.long.OAS2_0185_fixed/surf/rh.white:edgecolor=blue

freeview -v OAS2_0185_MR2.long.OAS2_0185_fixed/mri/wm.mgz \
-f OAS2_0185_MR2.long.OAS2_0185_fixed/surf/lh.pial:edgecolor=red \
OAS2_0185_MR2.long.OAS2_0185_fixed/surf/rh.pial:edgecolor=red \
OAS2_0185_MR2.long.OAS2_0185_fixed/surf/lh.white:edgecolor=blue \
OAS2_0185_MR2.long.OAS2_0185_fixed/surf/rh.white:edgecolor=blue

See here that the improved surfaces in the base also correct the surfaces in the long. Compare MR1.long slice 166 in the before (left) and after (right) images below.

The same improvement should have occurred with MR2.long.

7.1. Brain.finalsurfs.manedit.mgz Edits

The brain.finalsurfs.manedit.mgz volume will allow for the correction of a particular type of problem involving pial surface misplacement whereby parts of the pial surface have extended into the cerebellum in certain areas. It is only in this case where the pial surface extends into cerebellum where the brain.finalsurfs.manedit.mgz volume should be edited. In all other non-cerebellum pial surface problems, brainmask.mgz should be edited.

This cerebellum/pial surface problem can be fixed by removing those cerebellum voxels and other surrounding problematic voxels in the brain.finalsurfs.manedit.mgz volume such that upon running recon-all, the pial surface will be pulled in as desired, bordering only gray matter/ CSF boundary, and not jutting into the cerebellum. If only edits to this volume are made on a subject, it is sufficient to re-run recon-all from the point of these edits using the flag -autorecon3-pial.

For the following subject (OAS2_0002), it is seen that both cross sectional time points (OAS2_0002_MR1 and OAS2_0002_MR2) have some errors of this nature in several slices of the brain.finalsurfs.mgz volume. In the corresponding region in the base (OAS2_0002), similar problems show up, and therefore, the longitudinal data sets for time points 1 and 2 also have some errors in the corresponding areas of the brain.finalsurfs.mgz volume.

The tutorial below demonstrates how to manually fix the problem in the cross sectional time points and in the base, in order to automatically fix the problem in the long. Notice that edits will be made to a copy of the brain.finalsurfs.mgz file which will be named brain.finalsurfs.manedit.mgz. The tutorial walks you through editing cross-sectional time point 2 step by step, because the error in question is larger and better defined in this time point as compared to time point 1. However, the tutorial explains how to fix the problem in time point 1 as well.

In practice, you should check both cross-sectional time points for errors of this type, fix them and regenerate the cross-sectionals. Then, you should check the base, fix any errors, and regenerate the base. Then, regenerate both longitudinal runs using the fixed cross-sectional data sets and the fixed base.

1. Look at the brain.finalsurfs.mgz volumes within OAS2_0002_MR2 at the slices containing cerebellum in order to see the problem.

freeview -v OAS2_0002_MR2/mri/brain.finalsurfs.mgz \
OAS2_0002_MR2/mri/aseg.mgz:colormap=lut:opacity=0.25 \
-f OAS2_0002_MR2/surf/lh.pial:edgecolor=red \
OAS2_0002_MR2/surf/rh.pial:edgecolor=red \
OAS2_0002_MR2/surf/lh.white:edgecolor=blue \
OAS2_0002_MR2/surf/rh.white:edgecolor=blue

Reminder: once you start making edits to the brain.finalsurfs.mgz, save as brain.finalsurfs.manedit.mgz!

2. Editing the Base: Open the base for this subject

freeview -v OAS2_0002/mri/brain.finalsurfs.mgz \
OAS2_0002/mri/aseg.mgz:colormap=lut:opacity=0.25 \
-f OAS2_0002/surf/lh.pial:edgecolor=red \
OAS2_0002/surf/rh.pial:edgecolor=red \
OAS2_0002/surf/lh.white:edgecolor=blue \
OAS2_0002/surf/rh.white:edgecolor=blue

Reminder: once you start making edits to the brain.finalsurfs.mgz, save as brain.finalsurfs.manedit.mgz!

3. Once the cross-sectional time points 1 and 2 and the base are fixed, it is time to recreate long files for time points 1 and 2 (by renaming/removing the old and re-processing the -long from scratch). First, you can view the original long data for time point 2 (for example) below:

freeview -v OAS2_0002_MR2.long.OAS2_0002/mri/brain.finalsurfs.mgz \
OAS2_0002_MR2.long.OAS2_0002/mri/aseg.mgz:colormap=lut:opacity=0.25 \
-f OAS2_0002_MR2.long.OAS2_0002/surf/lh.pial:edgecolor=red \
OAS2_0002_MR2.long.OAS2_0002/surf/rh.pial:edgecolor=red \
OAS2_0002_MR2.long.OAS2_0002/surf/lh.white:edgecolor=blue \
OAS2_0002_MR2.long.OAS2_0002/surf/rh.white:edgecolor=blue

Click here to see the results of creating a new long file from the edited base and cross-sectional. You will do the same for MR1.

Reminder: once you start making edits to the brain.finalsurfs.mgz, save as brain.finalsurfs.manedit.mgz!

8. Study Questions

• What are the three processing steps and what do they mean? Answer

• What happens if the across time registration fails? Answer

• What is the best way to fix a skull strip error and where can this be edited? Answer