User Tools

Site Tools


psyc410_s2x:brain_registration_atlases

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
psyc410_s2x:brain_registration_atlases [2025/02/10 10:26] – [Explore Differences and Similarities in Size and Shape] adminpsyc410_s2x:brain_registration_atlases [2025/02/10 11:01] (current) – removed admin
Line 1: Line 1:
-<WRAP center round todo 60%> 
-<WRAP centeralign> 
-<typo fs:36px; fc:red; fw: bold; fv:small-caps; ls:1px; lh:1.1>**THIS PAGE IS STILL UNDER CONSTRUCTION!**</typo> 
- 
-<typo fs:20px; fc:black; fw: bold>Feel free to poke around, but do not start the lab as things might change! </typo> 
-</WRAP> 
-</WRAP> 
- 
- 
-<WRAP centeralign> 
-<typo ff:'Georgia'; fs:36px; fc:purple; fw: bold; fv:small-caps; ls:1px; lh:1.1> 
-Lab 5: Brain Atlases \\ 
-and Brain Registration </typo> 
-</WRAP> 
- 
-====== Information, Preparation, Resources, Etc. ====== 
- 
- 
-===== Assigned Readings / Videos: ===== 
- 
-  * {{psyc410:documents:Rilling 2008 Nat Neurosci.pdf|The evolution of the arcuate fasiculus revealed with comparative DTI - Rilling et al., 2008}} 
-  * {{psyc410:documents:tamietto_2012.pdf|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 (**__F__**SL **__Li__**near **__R__**egistration **__T__**ool) 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 ===== 
-<WRAP center round important 100%> 
-<WRAP centeralign><wrap em>Lab Report #5 is due on Feb XX<sup>th</sup> @ 1:10 pm. </wrap></WRAP> 
-  * Throughout this (and all) lab exercise pages you will find instructions for your lab reports within these boxes. 
-</WRAP> 
- 
- 
-===== Housekeeping ===== 
-  * none 
- 
-/* 
-**1.** Initialize freesurfer by running the following code in your ''Terminal'' 
-<code> 
-export FREESURFER_HOME=/Applications/freesurfer/7.4.1 
-source $FREESURFER_HOME/SetUpFreeSurfer.sh 
-</code> 
- 
- 
-<code> 
-cat <<EOT >> ~/.bashrc 
-### AFNI STUFF ### 
-export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace 
-EOT 
-</code> 
-*/ 
- 
-===== Data used in this lab ===== 
- 
-<WRAP center round tip 100%> 
-  * Reminder: The data that we will use throughout the semester is located in a directory on your Desktop; ''/Users/hnl/Desktop/input'' 
-  * <wrap em>Do not write output to that directory </wrap>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''. 
- 
-</WRAP> 
- 
- 
-====== 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 - <wrap hi>//How different are the brains of individuals?//</wrap> 
- 
-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 [[:psyc410_s25:sci_prog#Using Terminal|change your directory]] to ''/Users/hnl/Desktop/input/mri/anat_highres'' 
- 
-**2.** [[:psyc410_s25:brain_extraction_segmentation#Opening FSL|Open FSL]] 
- 
-**3.** Open three instances of ''FSLeyes''. 
-  * Each time you click the ''FSLeyes'' button, a new instance will open. 
- 
-<WRAP center round alert 70%> 
-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. 
-</WRAP> 
- 
- 
-**4.** Open a different **skull-stripped** brain in each instance. ([[:psyc410_s25:brain_extraction_segmentation#Open FSLeyes|Click here]] if you forgot how to load brains in FSLeyes.) 
- 
-<WRAP center round info 70%> 
-The skull-stripped brains end with ''_highres_skullstripped.nii.gz''. The number code at the beginning of the filename represents the participant number. 
-</WRAP> 
- 
- 
-**5.** Get your windows nicely organized and sized appropriately so each brain looks about the same. 
- 
-{{ :psyc410:images:fsleyes_brain_compare.png?600  |}} 
- 
-<WRAP center round box 60%> 
-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."// 
-</WRAP> 
- 
- 
-===== 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). 
- 
-{{ :psyc410:images:fsleyes_info_button.png?400 |}} 
- 
- 
-**2.** You can change the arrangement of your three brain views (axial, coronal, and sagittal) within the window with these three buttons: 
- 
-{{ :psyc410:images:fsleyes_brain_arrangement.png?400 |}} 
- 
- 
-**3.** You can turn on/off your different brain views (axial, coronal, and sagittal) with these three buttons: 
- 
-{{ :psyc410:images:fsleyes_brain_buttons.png?400 |}} 
- 
-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. 
- 
- {{ :psyc410:images:fsleyes_crosshairs.png?400 |}} 
- 
- 
-**5.** You previously learned how to take [[https://support.apple.com/en-us/102646|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. 
- 
- {{ :psyc410:images:fsleyes_screenshot.png?400 |}} 
- 
- 
-===== 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? 
- 
-{{ :psyc410:images:fsleyes_brain_compare_xyz.png?600  |}} 
- 
-<WRAP center round info 90%> 
-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. 
-</WRAP> 
- 
- 
-**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. 
- 
-<WRAP center round tip 90%> 
-It might be helpful to position your cursor at the boundary between white and grey matter or between brain and CSF. 
-</WRAP> 
- 
-{{ :psyc410:images:fsleyes_brain_compare_ac.png?600  |}} 
- 
-<WRAP center round tip 100%> 
-<WRAP centeralign><wrap em>Alternative ways to compare your brains</wrap></WRAP> 
- 
-  * 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. 
-    * [[:psyc410_s25:brain_extraction_segmentation#Load Your Skull Stripped Brain|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. 
-</WRAP> 
- 
-===== LAB REPORT Part 1 ===== 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 1 - #1 
-</typo> 
-</WRAP> 
- 
-</WRAP> 
-  * 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. 
-  * 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. 
-</WRAP> 
- 
-====== 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 [[https://www.andysbrainblog.com/andysbrainblog/2024/9/30/brief-history-of-the-mni-template|MNI coordinate system]], named for the Montreal Neurological Institute). We will use the FSL module ''flirt'' ([[https://fsl.fmrib.ox.ac.uk/fsl/docs/#/registration/flirt/index|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: How do individual brains differ?|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''. 
- 
-<WRAP center round info 80%> 
-This brain has T1 contrast and is in MNI space with 1 mm resolution. It has already been skull stripped. 
-</WRAP> 
- 
-{{  :psyc410:images:flirt_reference.png?400  |}} 
- 
-**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) 
- 
-<WRAP center round tip 80%> 
-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/...'' 
-</WRAP> 
- 
-{{  :psyc410:images:flirt_input.png?400  |}} 
- 
-**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). 
- 
-<WRAP center round alert 100%> 
-Make sure that directory ''~/Desktop/output/lab05'' exists on your computer. If it does not, then create it before proceeding. 
-</WRAP> 
- 
-<WRAP center round tip 100%> 
-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. 
-</WRAP> 
- 
-{{  :psyc410:images:flirt_output.png?400  |}} 
- 
-**6.** Change the ''Model/DOF (input to ref)'' option from ''Affine (12 parameter model)'' to ''Rigid Body (6 parameter model)''. 
- 
-{{  :psyc410:images:flirt_rigid.png?400  |}} 
- 
-<WRAP center round help 80%> 
-<WRAP centeralign> 
-<wrap em>**What did I just do?**</wrap> 
-</WRAP> 
-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. 
-</WRAP> 
- 
-**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. 
- 
-<WRAP center round info 40%> 
-Each Flirt should take about 2-3 min. 
-</WRAP> 
- 
-===== LAB REPORT Part 2 ===== 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 2 
-</typo> 
-</WRAP></WRAP> 
-  * There are no questions for this part of the lab. 
-</WRAP> 
- 
- 
-====== 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; [[http://afni.nimh.nih.gov/afni/|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/lab04''. 
- 
-{{  :psyc410:images:southpark_meme.jpg?350  |}} 
- 
-**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). 
- 
-<code bash> 
-cp /Users/hnl/Desktop/input/mri/fsl_standard/MNI152_T1_1mm_brain.nii.gz . 
-</code> 
- 
-**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'' 
- 
-{{  :psyc410:images:afni_underlay.png?350  |}} 
- 
-**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''  
- 
-{{  :psyc410:images:afni_open_view.png?350  |}} 
- 
-**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. 
- 
-{{  :psyc410:images:afni_window_lock.png  |}} 
- 
-**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. 
- 
-<WRAP center round tip 80%> 
-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. 
-</WRAP> 
- 
- 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 3 
-</typo> 
-</WRAP></WRAP> 
-  * Include a figure showing at least two of the examples above. 
-</WRAP> 
- 
-<WRAP center round alert 50%> 
-Do not close AFNI. You will use it in Part 4. 
-</WRAP> 
- 
- 
-====== 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: Comparing the shapes of individual's brains after transformation into MNI space|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. 
- 
-<WRAP center round info 80%> 
-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** 
-</WRAP> 
- 
-<WRAP center round info 80%> 
-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. 
-</WRAP> 
- 
-**2.** Open the files that were generated with different DOFs in 'locked' AFNI windows. 
-  * The four AFNI viewers should display 
-    - the MNI152 template brain 
-    - your 6 DOF FLIRTed brain 
-    - your 12 DOF FLIRTed brain 
- 
-<WRAP center round info 80%> 
-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'' 
-</WRAP> 
- 
- 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 4 
-</typo> 
-</WRAP></WRAP> 
-  * 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? 
-</WRAP> 
- 
-<WRAP center round tip 80%> 
-Once you've completed this section you can close all of your AFNI windows. 
-tip box 
-</WRAP> 
- 
-====== Part 5 - Using the FSL Atlases ====== 
- 
-FSLeyes provides nice set of probabilistic atlases that you can overlay on the standard brain to understand the name given to different anatomical locations. 
- 
-<WRAP center round info 80%> 
-  * 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. 
-</WRAP> 
- 
-===== 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. 
- 
-{{ :psyc410:images:fsleyes_atlas.png?800 |}} 
- 
-<WRAP center round info 80%> 
-  * 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. 
-</WRAP> 
- 
-===== 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 [[http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Atlases|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. 
- 
-{{  :psyc410:images:fsleyes_atlas_harvard.png?800  }} 
- 
-**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. 
- 
-{{  :psyc410:images:fsleyes_atlas_harvard_fusiform.png?800  }} 
- 
-**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'**. 
- 
-{{  :psyc410:images:fsleyes_atlas_harvard_fusiform_prob.png?800  }} 
- 
-<WRAP center round tip 80%> 
-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''. 
-</WRAP> 
- 
-**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. 
- 
-{{  :psyc410:images:fsleyes_minmax.png?800  }} 
- 
-  * 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. 
- 
- 
-/* 
-**7.** If you wanted to save this overlaid 'Left Thalamus' as an anatomical region of interest: 
- 
-  * Click on ''File'' -> ''Save As'' 
-  * Find the folder location for your output file 
-  * And hopefully you know how to do the rest. 
-*/ 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 5 
-</typo> 
-</WRAP></WRAP> 
- 
-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  
- 
-</WRAP> 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-/* 
-<WRAP center round alert 80%> 
-<WRAP centeralign> 
-<wrap em>HERE BE DRAGONS!</wrap> 
-\\ 
-\\ 
-**YOU DO NOT HAVE TO DO THE REST OF THIS SECTION (Part 5). 
-\\ 
-\\ 
-YOU MAY SKIP TO [[#Part 6: FSL First|PART 6]].** 
-</WRAP> 
-</WRAP> 
-*/ 
- 
- 
- 
-/* 
-===== Registering Atlases to Individual Subject Brains ===== 
- 
-//Do you know how we might automate the process of identifying individual subject anatomy using atlases like those in FSL?// 
- 
-One approach is to register the brain region from the Atlas to your individual subject's brain. We have already done this for you via the script below. More specifically, this script will 
- 
-  * Transform two regions from the Harvard-Oxford atlas, which are in standard space, to the subject's brain (native space). 
-  * Then load the subject's brain and the two transformed atlas regions in FSLView. 
- 
-<code bash> 
-# Be patient this command will take a moment to apply the registration 
-# and will then promptly load FSLView. 
-# BTW, anything with '#' is treated as a comment on the terminal 
-# Oh and Feel free to open this script if you want to more learn about how it works. 
-cd ~/Desktop/input/scripts 
-bash transform_atlas_demo.bash 34353 12 
-</code> 
- 
-  * //34353// refers to the subject found in the folder ''~/Desktop/input/mri/anat_highres_trans'' 
-  * //12// refers to 12 degrees-of-freedom (DOF) for the registration to/from standard space 
- 
-<note> 
-  * **Can you guess what the region shown in //red// is and the region should in //blue//?** 
-  * Would you say the registration from standard to this subject's space is well done? 
- 
-  * The intensity values for each region represent the probability value representing the number of subjects who were found to have that brain region at that voxel. 
-  * Try to change the threshold of each probabilistic atlas region using the textbox to the right of 'Min'. Currently it is set at 25. This threshold sets the minimum percent of subjects in the atlas who will have this brain region. 
-</note> 
- 
-{{  :psyc410_s16:images:flirt_atlas_reg_example.png?600  |}} 
- 
-*/ 
-/* 
-===== Details on the Script ===== 
- 
-The script will make use of two files: 
- 
-  * The subjects brain as the reference (this is the space you want your atlas to be in) 
-  * The pre-computed transformation matrix (12 DOF) for moving that subject to standard space. 
- 
-The script will execute the following steps: 
- 
-  * Using ''convert_xfm'', invert the transformation matrix so we can move from standard space to subject space 
-  * Using ''flirt -applyxfm -init'', apply the inverted matrix to transform the left 'Superior Frontal Gyrus' and 'Amygdala' in standard space to native space. 
- 
-The original ROIs are from the Harvard-Oxford cortical atlas in FSLView so they might look familiar. 
- 
-<note> 
-If you want to learn more about the tools used in this section, please refer to the [[http://fsl.fmrib.ox.ac.uk/fsl/fsl-4.1.9/flirt/overview.html|FLIRT overview page]] and the [[http://fsl.fmrib.ox.ac.uk/fsl/fsl-4.1.9/flirt/examples.html|FLIRT examples page]]. 
-</note> 
- 
- 
-*/ 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-====== 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 [[http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIRST|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. 
- 
-<code bash> 
-INPUTDIR=~/Desktop/input/mri/anat_highres 
-OUTPUTDIR=~/Desktop/output/lab04 
-</code> 
- 
-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. 
- 
-<WRAP center round tip 80%> 
-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''. 
-<code bash> 
-echo $INPUTDIR 
-</code> 
-</WRAP> 
- 
-**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. 
- 
-<code bash> 
-run_first_all -v -b -i ${INPUTDIR}/34353_highres_skullstripped.nii.gz -o ${OUTPUTDIR}/34353_ 
-</code> 
- 
-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. 
- 
-<WRAP center round tip 80%> 
-**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. 
-</WRAP> 
- 
- 
-**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''. 
- 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 6 
-</typo> 
-</WRAP></WRAP> 
-  * 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? 
-</WRAP> 
-====== 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'' 
- 
-<code bash> 
-3dcalc \ 
--prefix /Users/hnl/Desktop/output/lab04/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' 
-</code> 
- 
-<WRAP center round info 80%> 
-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''**. 
-</WRAP> 
- 
- 
- 
-===== 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: Comparing the shapes of individual's brains after transformation into MNI space (est 20 min)|Part 3]] if you need a refresher on how to do this. 
- 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 7 
-</typo> 
-</WRAP></WRAP> 
-  * How does the Kenyon5 brain look? 
-  * Is it as nice as the MNI152 brain?. 
-    * Why (or why not)? 
-</WRAP> 
- 
- 
- 
-<WRAP center round alert 80%> 
-Don't forget to return to [[#Part 6: FSL First|Part 6]] and see if it's done running. If so, complete step #3 of that part. 
-</WRAP> 
- 
- 
-====== Part 8: Examining a fully labeled FreeSurfer brain ====== 
- 
-[[http://freesurfer.net/|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. 
- 
-<code bash> 
-  # 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 
-</code> 
- 
-The following image should pop up. 
- 
-{{  :psyc410:images:freesurfer01.png?0x400  }} 
- 
-You can use the notes below with the accompanying image to get an idea of the different buttons for tksurfer. 
- 
-{{  :psyc410:images:freesurfer02.png?500  }} 
- 
-<WRAP center round info 80%> 
-  - 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. 
-</WRAP> 
- 
- 
-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 
- 
-{{  :psyc410:images:freesurfer03.png?500  |}} 
- 
-Or use the following command from the terminal: 
-   
-<code bash> 
-  tksurfer $SUBJID lh pial -curv lh.curv 
-</code> 
-   
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 8 - #1 
-</typo> 
-</WRAP></WRAP> 
-  * 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). 
-</WRAP> 
- 
-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. 
- 
-{{  :psyc410:images:freesurfer04.png?500  |}} 
- 
-<WRAP center round important 100%> 
-<WRAP centeralign> 
-<WRAP centeralign> 
-<typo fs:x-large; fc:purple; fw:bold; text-shadow: 2px 2px 2px #ffffff> 
-LAB REPORT Part 8 - #2 
-</typo> 
-</WRAP></WRAP> 
-  * Create a figure depicting the labeled brain showing the pial surface (see the info box above describing what each button does). 
-</WRAP> 
- 
-For reference, here is a labeled image of a sample freesurfer brain done by the freesurfer folks: 
- 
-{{  :psyc410:images:freesurfer_surface_labeled.png?1000  |}} 
- 
- 
-/* 
-You can also view the data in 2D slices with segmentation using the viewer tkmedit. 
-<code bash> 
-tkmedit $SUBJID brainmask.mgz lh.white \ 
--aux T1.mgz -aux-surface rh.white \ 
--segmentation aseg.mgz $FREESURFER_HOME/FreeSurferColorLUT.txt 
-</code> 
-*/ 
  
psyc410_s2x/brain_registration_atlases.1739201183.txt.gz · Last modified: 2025/02/10 10:26 by admin

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki