THIS PAGE IS STILL UNDER CONSTRUCTION! Feel free to poke around, but do not start the lab as things might change!

Lab 5: Brain Atlases
and Brain Registration

Information, Preparation, Resources, Etc.

Assigned Readings / Videos:

The evolution of the arcuate fasiculus revealed with comparative DTI - Rilling et al., 2008

Subcortical connections to human amygdala and changes following destruction fo the visual cortex - Tamietto et al., 2012

Goals for this lab:

Observe variability in brain size and shape between individuals

Transform individual subject brains to MNI space with FSL Flirt and compare to a brain atlas.

Average individual subject transformed brains using Matlab.

Learn about statistical brain atlases, Talairach, and MNI (Montreal Neurological Institute) space.

Create anatomical region-of-interests with the FSL atlases.

Superimpose the ROI on the brains you transformed into MNI space.

Use FSL FIRST to segment and label subcortical brain regions such as hippocampus and amygdala

Examine a brain you labeled with FreeSurfer

Software introduced in this exercise:

AFNI image viewer

FSL's Flirt (FSL Linear Registration Tool) for image registration.

Learn to write a simple AFNI script in bash to average brains.

FSLeyes atlases

FSL/FIRST to label subcortical structures

FreeSurfer for individualized atlases.

Laboratory Report

Lab Report #5 is due on Feb XXth @ 1:10 pm. Throughout this (and all) lab exercise pages you will find instructions for your lab reports within these boxes.

Housekeeping

none

Data used in this lab

Reminder: The data that we will use throughout the semester is located in a directory on your Desktop; /Users/hnl/Desktop/input Do not write output to that directory or any of its sub-directories. Remember to use descriptive names when naming your output files. For the first part of this lab, you select three of the five brains available in ~/Desktop/input/mri/anat_highres.

Part 1: How do individual brains differ?

Many scientists and clinicians would like to compare the brains of different individuals and make comparisons and averages of quantitative measurements of different brain structures. For example, a clinical psychologist might be interested in whether a brain structure such as the hippocampus is different in size for depressed compared to non-depressed individuals. A genetics researcher might want to know if different alleles of the serotonin transporter gene are associated with different sized amygdala. A language researcher might want to know if there are hemispheric differences in temporal lobe anatomy in individuals who have right or left language dominance. These examples raise an important question - How different are the brains of individuals?

In the first part of this exercise, you will closely observe three brain regions in three or more brains that have been previously skull-stripped. You can select three of the five brains available in ~/Desktop/input/mri/anat_highres.

Open FSL

1. Open your Terminal app and change your directory to /Users/hnl/Desktop/input/mri/anat_highres

2. Open FSL

3. Open three instances of FSLeyes.

Each time you click the FSLeyes button, a new instance will open.

Remember, it will take a little bit for the app to open. If you repeatedly click the button impatiently you'll end up with way too many open instances.

4. Open a different skull-stripped brain in each instance. (Click here if you forgot how to load brains in FSLeyes.)

The skull-stripped brains end with _highres_skullstripped.nii.gz. The number code at the beginning of the filename represents the participant number.

5. Get your windows nicely organized and sized appropriately so each brain looks about the same.

This is right about the time in the semester you might start thimking “Hmmm, I sure am glad that Prof. Engell insisted that this lab have computers with big displays.”

Explore FSLeyes

Let's spend a few minutes familiarizing ourselves with a few features of FSLeyes.

1. You can learn a bit more about the brains you've loaded by clicking on the info button. A window will open with information, including the dimensions of the image (and therefore, voxel size).

2. You can change the arrangement of your three brain views (axial, coronal, and sagittal) within the window with these three buttons:

3. You can turn on/off your different brain views (axial, coronal, and sagittal) with these three buttons:

The next tips will be particularly helpful for you when writing lab reports!

4. By default, you see green crosshairs overalid on top of your brain indicating your current specific voxel location in the three views. But sometimes it's better to see the brains without these crosshairs. Use the button below to toggle then on/off.

5. You previously learned how to take screenshots using the macos. But FSLeyes has a builtin screenshot function that you'll find helpful when you don't want all the “extra” stuff (e.g., menu bars) in your screenshot.

Explore Differences and Similarities in Size and Shape

6. In one of the windows, click on a precise anatomical location of your choosing.

Copy the X,Y,Z voxel coordinates of that location (see the red boxes in the image below) into the 2D viewer of the other two brains.

When you are done, your crosshairs will be at the identical matrix position in all three windows of FSLview.

Are you at the same anatomical location when you are at the same coordinate?

There is considerable variability in brain morphology, and in the position of a brain within the imaging matrix, and so the raw coordinates will unlikely to be at the same brain locus.

7. To help focus your comparison, find a (relatively) similar slice. For example, in the image below I centered my crosshairs in the midline of the anterior commissure. You can use this, or any other, anatomical landmark to help you get similar slices in each of your three brains.

Spend a few moments exploring the the overall similarities and differences among the brains.

It might be helpful to position your cursor at the boundary between white and grey matter or between brain and CSF.

Alternative ways to compare your brains Overlay brains on top of each other in a single FSLView window, colorize the overlay, and adjust the Opacity using the slider bar at the the right of the screen. See here for a reminder of how to overlay and colorize brains. Toggle the overlaid brain 'off and on' by double clicking the eyeball icon to the left of the filename in the Overlay list. These methods, as well as the one you've been using thus far, will all give you a better picture of the similarities and differences across brains.

LAB REPORT Part 1

LAB REPORT Part 1 1) Create two figures demonstrating the differences in the brain. Each figure should contain a screenshot that compares the anatomy of all three brains side by side (see figure above for reference). For each of the two figures, briefly describe the differences you observe. Use Powerpoint (or any program you like) to add arrows or boxes to highlight the differences. 2) Create two screenshots to compare brain anatomy using overlays of all three brains in FSLeyes (see above tip box). For each of the two figures, briefly describe the differences you observe. Use Powerpoint (or any program you like) to add arrows or boxes to highlight the differences.

Part 2: Transforming brains into a common space using FLIRT

To automate measuring brain structures and differences in brain structures, it would be very helpful to have those structures at the same coordinates. Although not our problem for today, putting brain regions into the same coordinate system is essential for most functional MRI group statistical analyses. So, we are now going to do this.

We will transform at least two of the skull-stripped brains from the last exercise to a common coordinate system (the MNI coordinate system, named for the Montreal Neurological Institute). We will use the FSL module flirt (FSL Linear Registration Tool) to accomplish this. Flirt will create transformation matrices that can then be used to align the brains to the common space. We will then quickly repeat Part 1 comparing the two individual brains after registration.

1. If you closed FSL after the last exercise, reopen it by typing fsl & in your Terminal window.

2. Click on the FLIRT linear registration button.

3. Set the reference image to MNI152_T1_1mm_brain. By default it is set to MNI152_T1_2mm_brain, so you can just change the 2 to a 1.

This brain has T1 contrast and is in MNI space with 1 mm resolution. It has already been skull stripped.

4. For the Input image, specify one of your skull stripped brains from Part 1 (i.e., a brain from the ~/Desktop/input/mri/anat_highres collection)

You should already be in the correct directory from the last exercise. If not … I recommend Entering the path /Users/hnl/Desktop/input/mri/anat_highres and then Clicking the folder icon to select the specific file. See the picture below. You could also just click the folder icon and navigate manually to /Users/hnl/Desktop/input/…

5. Specify the output. Start with /Users/hnl/Desktop/output/lab05/ (this is the folder in which your output will go). You will also need to add your output file name to the end of this path (see tip box below).

Make sure that directory ~/Desktop/output/lab05 exists on your computer. If it does not, then create it before proceeding.

Note that in the screenshot I have set my output image to be the same name as my input image with _reg (for registered) added to the end. So my input is 34532_highres_skullstripped and my output is 34532_highres_skullstripped_reg. It might actually be better to use _reg6 because in this section we will be using 6 degrees of freedom, but in the the next section will have you re-running FLIRT with different DOFs and appending _reg6 to the name will keep clear the DOFs used on each file.

6. Change the Model/DOF (input to ref) option from Affine (12 parameter model) to Rigid Body (6 parameter model).

What did I just do? We are going to apply a 6 degrees of freedom (DOF) model. When we say 6 DOF, we mean that there are 6 different things that we can change about our input image to get it to be like our reference image. The first 6 DOF represent translation (i.e., movement forward/backward, left/right, up/down) of our input to match our reference (the MNI standard brain). The next 6 DOF represent rotation (i.e., yaw, pitch, roll) of our input to match our reference.

7. Press Go when you are done.

8. Once this brain is complete, carry out the same operation on a second individual's brain, again using a 6 DOF model. Make sure to give this second one a unique output file name otherwise you will overwrite the first one that you ran.

Each Flirt could take up to 2-3 minutes. BE PATIENT!

LAB REPORT Part 2

LAB REPORT Part 2 There are no questions for this part of the lab.

Part 3: Comparing the shapes of individual's brains after transformation into MNI space

We are now going to see how well the transformations worked.

Open AFNI

In this section we will use yet another image viewer; AFNI. AFNI is my preferred software package for fMRI analysis, but it is ugly and relatively difficult to learn. However, the viewer has a nice feature that will allow us to “lock” the view of different brains.

1. Open your Terminal app and change your directory to your output directory ~/Desktop/output/lab05.

2. Copy your reference image into your current directory using the following command in your Terminal window (we have to do this because AFNI doesn't work well when using images located in different directories).

cp /Users/hnl/Desktop/input/mri/fsl_standard/MNI152_T1_1mm_brain.nii.gz .

2. Start AFNI by typing afni &

By default AFNI will

load the first available brain in the directory

open the AFNI control window

open two views of the brain in two separate windows; axial and sagittal

3. Change the brain to one of your transformed brains.

click Underlay

choose the file from the dropdown menu

click Set

4. Open a new viewer and load your second transformed brain.

to open a new viewer, click on the New button in the bottom left of the control window

in the new control window that opens, load a different skull-stripped brain (see #3 above)

the new control window does not automatically open any views of the brain. So you'll need to click on the Image button next to Axial and Sagittal

5. Open a third viewer and load the MNI152_T1_brain.

6. Get your windows nicely organized and sized appropriately so each brain looks about the same. Unlike FSLeyes, AFNI opens each brain view in a separate window. This can make window management a bit of a pain. But you should try to get your windows organized so that they look something like the image below. Note that the title of each window starts with [A], [B], and [C]. These correspond to the first, second, and third control windows you opened.

7. To evaluate how well the transformation worked, click on three or more structures in the MNI reference brain and see if the cross-hairs show up in those same structures in your 'flirted' brains.

Try the amygdala (one hemisphere only).

Try the head of the caudate.

Try the calcarine sulcus in the occipital lobe.

If you have trouble finding the anatomy, you can use a cool AFNI viewer feature. Right click on any of the brains and select Go to Atlas Location. Then select where you want to go (e.g., Right Amygdala) and voila! You are there.

LAB REPORT Part 3

LAB REPORT Part 3 1) Include a figure showing two of the examples above.

Do not close AFNI. You will use it in Part 4.

Part 4: Comparing the registration quality of different DOF models

1. Now that you are familiar with 6 DOF models, try experimenting with a different DOF model run on a single subject. Remember to have a different output filename for this output. I suggest appending _reg12.

In Part 3 of this lab you ran the 6 DOF model. Now FLIRT the same subject using the 12 DOF model.

Make sure to have your output go into the same directories you used for the 6 DOF, so that AFNI will have access to them.

Here's a reference for what each DOF means: 3 DOF = translation in X, Y, Z 6 DOF = 3 DOF + rotation in X, Y, Z 7 DOF = 6 DOF + global scaling (same scale factor to X, Y, Z) 9 DOF = 6 DOF + scaling in X, Y, Z 12 DOF = 9 DOF + shear in X, Y, Z

The examples above are all linear transformations. Meaning that all voxels are transformed in some linearly related manner to each other. However, we often use non-linear registration to get an even better match to the standard brain.

2. Open the files that were generated with different DOFs in 'locked' AFNI windows.

The three AFNI viewers should display

the MNI152 template brain

your 6 DOF FLIRTed brain

your 12 DOF FLIRTed brain

In Part 3, you compared the registration across two different participants and the MNI brain. In this part, you are comparing the quality of registration of one participant (using two different DOF models) to the MNI brain. So two of the three AFNI viewer should be showing results from the same participant. For example, MNI152 template brain xxxxxx_highres_skullstripped_reg6 xxxxxx_highres_skullstripped_reg12

LAB REPORT Part 4

LAB REPORT Part 4 Click around in the brain and compare how well/poorly each of the FLIRTed brains matches the MNI template brain. Was there a noticeable difference in the quality of the transformation for higher (12 DOF) than lower (6 DOF) DOF models? Include a figure that demonstrates this difference. What are your impressions of the effect of spatial registration on alignment to the template brain and alignment across individuals?

Once you've completed this section you can close all of your AFNI windows. tip box

Part 5 - Using the FSL Atlases

FSLeyes provides a nice set of probabilistic atlases that you can overlay on the standard brain to understand the name given to different anatomical locations.

The FSL atlases are typically derived from a sample of participants. Values at specific voxels reflect the probability that a particular person will have that atlas label. e.g., 50% of participants might all agree a voxel is the left Thalamus In contrast, in Part 6 of tonight's lab you will use FSL first and Freesurfer, which create atlases based on a semi-automated labeling of anatomical regions for individual participants.

Start FSLeyes

1. Open the MNI152 brain in FSLeyes

Start FSLeyes

Select File → Add Standard

Choose MNI152_T1_1mm_brain.nii.gz

Starting Atlas Tools

2. Click on Settings → Ortho View 1 → Atlas Panel

3. Now if you click around to different areas of the brain, information will be updated in the atlases tools box that tells you about the anatomical location at the cross-hair. For instance, in the crosshairs in the image below are on the Right Hippocampus according to the Harvard-Oxford Subcortical Structural Atlas.

You might notice percentages next to each label. Many of these anatomical labels were identified manually by experts on individual brains. Then these labeled brains were transformed to the standard brain And the label at each location in the brain was averaged across participants. So if it says 63% Left Cerebral White Matter, this implies that 63% of participants had the label white matter applied to this location in the brain.

Changing Atlases

You can add or remove atlases from the list.

1. To add or remove atlases, simply click on the checkbox to the left of the atlas name.

2. I recommend adding the 'Juelich Histological Atlas' and 'Talairach Daemon Labels' to start out (keep the current Harvard-Oxford atlases). It will take a few seconds for FSLeyes to update atlas tools with the new labels.

3. If you want to find out more about the different atlases, you can go to this site.

Visualize Regions and/or Create ROIs

You can visualize specific brain regions or create anatomical regions of interest (ROI) by:

1. Clicking on the 'Atlas Search' tab inside of the 'Atlases' window.

2. You can select your atlas by clicking on the checkbox to its left. Select 'Harvard-Oxford Cortical Structural Atlas'. You will see a colorful overly appear on your brain. Each color represents a different cortical region according to the atlas.

3. You can now jump to a specific structure. To find a structure you're interested in you can either scroll through the (long) list, or simply start typing a name into the Search box. Below I entered 'fusiform' in the Search box.

4. If you click the + sign to the left of the region name, you FSLeyes will center your cross hair to where the region resides in the standard brain. Very helpful! Try it now by clicking on 'Temporal Occipital Fusiform Cortex'. You should have jumped to that region as in the image below.

5. You can also overlay the probabilistic values for this region from the atlas. Click on the checkbox to the left of the + sign (to the left of 'Temporal Occipital Fusiform Cortex'). Do so now.

Your display will look like the one below. Each voxel is now shown with an associated probability that it is in the selected region. The more red the voxel, the more likely that it's in the 'Temporal Occipital Fusiform Cortex'.

To better see the probabilistic overlay, you might want to turn off the colorful cortical labels. To do so, click on the blue eye next to harvardoxford-cortical/label/all in the Overlay list.

6. Notice the Min and Max values at the top of the window. These values determine the threshold for what is displayed. The values have different meanings depending on what type of brain/image you're looking at.

If you highlight MNI152_T1_1mm in the Overlay list you'll see that values default to 0 and 8447.64, which are arbitrary intensity values associated with the greyscale brain.

If you highlight harvardoxford-cortical/prob/Temporal Occipital Fusiform Cortex, the values default to 0 and 95.95. This means you are displaying all voxels that have a probability between 0-95.95% of being in the region (the default max value tells us that there are no voxels with a higher probability than 95.95% in the brain).

Change the Min value to something higher, like 50. You'll see that you're region gets smaller, because now you're being more conservative and restricting the display to only show (i.e., color) voxels that have a 50% or higher probability of being in the region.

LAB REPORT Part 5

LAB REPORT Part 5 Using the two Harvard-Oxford atlases, create figures that display each of the regions listed below. Your figures should only display voxels that have at least 25% probability of being within the region. (Turn off the harvardoxford-cortical/label/all) Regions: Middle Frontal Gyrus Angular Gyrus Left Caudate Right Amygdala

Part 6: FSL First

The FSL Atlases overlaid a group derived anatomical brain mask upon your transformed brain. Is this as accurate as determining the brain structure from an individual, non-normalized brain? In other words, is it as accurate to say “we think this region is Prof. Engell's amygdala because it's the amygdala in 94.5% of individuals” as saying “we think this region is Prof. Engell's amygdala because we identified it in his brain image”? We can investigate this question by using FSL ''FIRST'' - a program that automatically segments and labels sub-cortical structures.

The FSL FIRST program can only be run from the command line in your Terminal app. You can specify your skull-stripped brain as input, or you can choose any of our sample brains. Note, that you can specify a brain that has NOT been skull stripped. In this case, the FIRST program will do the skull-stripping by calling the BET program. However, since we like to make sure our skull-stripping is of high quality, we will specify a brain for which we have supervised the skull stripping ourselves. However, you need to tell FIRST that the brain is skull stripped - you do that by specifying the -b option in the command line.

In the code below, I used the skull-stripped version of the 34353 brain located in the ~/Desktop/input/mri/anat_highres directory.

1. In this example, we will create short-cuts in bash to point to the input and output directories. Be careful not to put any spaces before or after the = or the space will become part of the name. By convention, we use capitals for such short-cuts, but it is not required.

INPUTDIR=~/Desktop/input/mri/anat_highres OUTPUTDIR=~/Desktop/output/lab05

We can then use these short-cuts in our command line. They will be “expanded” when the command line is executed to the paths to which we equated them.

To see what I mean by “expansion” enter the following code into your terminal. It tells the terminal to print out to the screen (echo) the expanded INPUTDIR variable. In other words, it'll show what the computer “sees” when you enter $INPUTDIR. echo $INPUTDIR

2. Notice, to let the bash shell know that we are specifying short-cuts, we prefix the short-cut with a $ when we use it.

run_first_all -v -b -i ${INPUTDIR}/34353_highres_skullstripped.nii.gz -o ${OUTPUTDIR}/34353_

The command line above executes the run_first_all FSL script. This script calls several programs that comprise FIRST. Note that there are four options on the command line:

-v for verbose output

-b to indicate that we are submitting a skull-stripped brain as input

-i specifies that the next item is the input file

-o specifies that the next item is the path and prefix of the output files. There will be several output files, and each will start with the specified prefix '34353_'. You can replace that prefix with anything you want.

Once FSL First is running (it should be printing a lot of stuff to your terminal window because we asked for “verbose ouptut”), go on to Part 7 below. It will take First ~25 minutes to complete. Return here when FIRST finishes.

3. Here is what you should do with the output:

Overlay the segmented output (e.g., 34353_all_fast_firstseg.nii.gz) from FIRST upon your original skull stripped brain using FSLeyes.

LAB REPORT Part 6

LAB REPORT Part 6 Include an image of your segmented brain. Observe how well, or how poorly, FSL FIRST automatically identified different anatomy. Find the borders of the caudate, the amygdala, the hippocampus, and the ventricles. Would you use FSL's First for a scientific study of hippocampal volumes? Think in terms of cost vs. benefit. If you had 100 subjects, do you think FIRST does a sufficiently good job of segmentation or do you think it would be necessary to identify the hippocampal borders in all 100 subjects by hand?

Part 7: Using a simple bash/AFNI script to average brains

So how did the MNI152 brain come about anyway? Somebody at the Montreal Neurological Institute co-registered 152 brains to a single brain, and then averaged across all the registered brain. Let's try this on the five brains for which we have good registrations, and we will create the Kenyon5 brain!

Running the Script

1. We will create an average brain by running the bash script below. This script will call the AFNI command 3dcalc.

3dcalc \ -prefix /Users/hnl/Desktop/output/lab05/kenyon5_brain.nii.gz \ -a /Users/hnl/Desktop/input/mri/anat_highres_trans/34353_12dof.nii.gz \ -b /Users/hnl/Desktop/input/mri/anat_highres_trans/34433_12dof.nii.gz \ -c /Users/hnl/Desktop/input/mri/anat_highres_trans/34532_12dof.nii.gz \ -d /Users/hnl/Desktop/input/mri/anat_highres_trans/34554_12dof.nii.gz \ -e /Users/hnl/Desktop/input/mri/anat_highres_trans/34569_12dof.nii.gz \ -expr '(a+b+c+d+e)/5'

You'll need to open a new terminal window because the FAST is still working away in your open window. Just click on the open window and then enter the keyboard shortcut command + n.

Script Details

The \ backslash at the end of each line tell bash that the command continues on the next line

-prefix tells 3dcalc what we want to name the output file

Each of the file names is assigned to a unique letter from a to e

-expr tells 3dcalc what we want done with the input files. In this case we calcualte a simple mean of the five datasets.

Examine your Results

3. Open the Kenyon5 brain and the MNI152 brain in locked AFNI windows. Refer back to Part 3 if you need a refresher on how to do this.

LAB REPORT Part 7

LAB REPORT Part 7 How does the Kenyon5 brain look? Is it as nice as the MNI152 brain?. Why (or why not)?

Don't forget to return to Part 6 and see if it's done running. If so, complete step #3 of that part.

Part 8: Examining a fully labeled FreeSurfer brain

FreeSurfer is a powerful segmentation and automatic labeling program that has some similarities to FSL FIRST. However, unlike FIRST, FreeSurfer labels the entire brain, and does quite a lot of other things, such as creating inflated brain surfaces. FreeSurfer can take ~30 hours to run one brain, so it doesn't make for a good in-lab exercise. However, exploring the output can be fun, as you will see below.

freesurfer needs environment variables set to point to the data. This must be done in the terminal.

1. Type the following codes to a terminal window.

# set the location of your subject's directory export SUBJECTS_DIR=~/Desktop/input/mri/freesurfer_test # export doublebufferflag=1 # set the subject ID export SUBJID=subj19_1A # Tell the viewer to display the pial view of the left hemisphere tksurferfv $SUBJID lh pial

The following image should pop up.

You can use the notes below with the accompanying image to get an idea of the different buttons for tksurfer.

These buttons allow you to change the type of surface. 'I' is the inflated surface so all the folds have been expanded out. 'W' shows only the outlines of the white matter 'P' shows the pial surface (i.e., the outlines of the grey matter) These buttons allow you to rotate the brain in different ways (note the 'deg' option below allowing you to specify the exact amount of rotation) These allow you to translate the brain in different directions (note the 'mm' option below) These allow you to zoom in or out (note the '%' option below) If you rotated or zoomed in too much and want to get back to normal, click this home button.

Through the TkSurfer Tools GUI window, you can click on different surface views (main, inflated, etc.)

You can view the curvature of the brain via a green-red colormap: Green indicates a gyrus, Red indicates a sulcus.

2. Through the GUI:

File → Curvature → Load Curvature… item to load a curvature file.

Choose lh.curv (it is likely the default option so you can click ok)

You can turn the curvature on/off by clicking on the curvature button on the GUI

Or use the following command from the terminal:

tksurfer $SUBJID lh pial -curv lh.curv

LAB REPORT Part 8 #1

LAB REPORT Part 8 - #1 Create a figure depicting the brain with the curvature on and showing the outlines of the white matter (see the info box above describing what each button does).

Next, load the annotation (label) to view the segmentation overlay on the cortical surface:

3. Through the GUI:

File → Label → Import Annotation…

Choose one of the .annot files for the hemisphere you are viewing. For example, you can try lh.aparc.annot.

Click on different areas and the label is displayed on the bottom right corner of the “TkSurfer Tools” window.

LAB REPORT Part 8 #2

LAB REPORT Part 8 - #2 Create a figure depicting the labeled brain showing the pial surface (see the info box above describing what each button does).

For reference, here is a labeled image of a sample freesurfer brain done by the freesurfer folks: