{"id":281,"date":"2015-02-10T15:22:14","date_gmt":"2015-02-10T20:22:14","guid":{"rendered":"http:\/\/brainybehavior.com\/neuroimaging\/?p=281"},"modified":"2015-02-12T09:56:30","modified_gmt":"2015-02-12T14:56:30","slug":"brain-template-creation-with-ants","status":"publish","type":"post","link":"https:\/\/brainybehavior.com\/neuroimaging\/2015\/02\/brain-template-creation-with-ants\/","title":{"rendered":"Brain Template Creation with ANTs"},"content":{"rendered":"<p>These instructions use FA images to create an FA template using the software package ANTs (<a title=\"ANTs\" href=\"http:\/\/stnava.github.io\/ANTs\/\">http:\/\/stnava.github.io\/ANTs\/<\/a>); the process should work well with other image modalities.<\/p>\n<p>First we can\u00a0use FLIRT to register a group of 4 brains (semi-randomly chosen by looking at the slicesdir output created from an initial step of TBSS; the 4 brains chosen were ones that appeared to be straightest and least affected by artifact) to a common space (in this case MNI152 2mm) using a linear registration with 12 dof.<\/p>\n<p><code>flirt -in \/path\/to\/FA\/directory\/con001_fa_brain.nii.gz -ref \/usr\/local\/fsl\/data\/standard\/MNI152_T1_2mm_brain -out \/path\/to\/FA\/directory\/con001_fa_brain2MNI152 -omat \/path\/to\/FA\/directory\/con001_fa_brain2MNI152\u00a0-bins 256 -cost corratio -searchrx -180 180 -searchry -180 180 -searchrz -180 180 -dof 12 -interp trilinear \u2013v<\/code><\/p>\n<p>That is repeated for each of the four brains (you can pick another number but I used four to be semi-representative of my sample). This step can also be looped with a simple <code>for<\/code> statement.<\/p>\n<p>I then used <a href=\"http:\/\/www.itksnap.org\/pmwiki\/pmwiki.php?n=Convert3D.Convert3D\">c3d<\/a> (fslmaths could also be used) to create a mean FA image from the four aligned brains.<\/p>\n<p><code>c3d *_brain2MNI152.nii.gz -mean -o con_mean_fa.nii.gz<\/code><\/p>\n<p><code>#create mean image from four aligned images. Make sure you are in the directory or that you specify the whole path to the files.<\/code><\/p>\n<p><a href=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/4subject_mean_FA.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-282 size-medium\" src=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/4subject_mean_FA-247x300.png\" alt=\"4subject_mean_FA\" width=\"247\" height=\"300\" srcset=\"https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/4subject_mean_FA-247x300.png 247w, https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/4subject_mean_FA.png 843w\" sizes=\"(max-width: 247px) 100vw, 247px\" \/><\/a><\/p>\n<p>Then use ANTs to create a template. In my case I used 80 MRI images to create the template. Note, you will need to do minor edits of the template creation script (provided with the\u00a0ANTs installation in the <code>bin<\/code> directory). The first part of the script looks like this (this is my edited version, specific for my ANTs installation):<\/p>\n<p><code>function setPath {<br \/>\ncat &lt;&lt;SETPATH<br \/>\n------------------------------------------------------------<br \/>\nError locating ANTS<br \/>\n------------------------------------------------------------<br \/>\nIt seems that the ANTSPATH environment variable is not set. Please add the ANTSPATH\u00a0variable. This can be achieved by editing the .bash_profile in the home directory.<\/code><\/p>\n<p>Add: ANTSPATH=\/Applications\/antsbin\/bin<\/p>\n<p>Or the correct location of the ANTS binaries.<br \/>\nAlternatively, edit this script ( `basename $0` ) to set up this parameter correctly.<br \/>\nSETPATH<br \/>\nexit 1<br \/>\n}<br \/>\n# Uncomment the line below in case you have not set the ANTSPATH variable in your<br \/>\n# environment.<br \/>\nexport ANTSPATH=${ANTSPATH:=&#8221;\/Applications\/antsbin\/bin\/&#8221;} # EDIT THIS<\/p>\n<p>Below is the command I used to run the script and create the template brain.<\/p>\n<p><code>\/path\/to\/FA\/template\/directory\/antsMultivariateTemplateConstruction2.sh -d 3 -o template_ -c 2 -j 4 -z \/path\/to\/FA\/template\/directory\/initial_template\/con_mean_fa.nii.gz *.nii.gz<\/code><\/p>\n<p><code>#I ran the script using the following flags: -d 3 (3D image); -c 2 (use localhost multiprocessors; i.e., not a parallel computing environment); -j 4 (use #up to 4 processors at a time); -z is input initial template; *.nii.gz warps all brains in the directory (skull-stripped FA images in my case) into the template. Make sure that is including only what you want it to include.<\/code><\/p>\n<p>This runs for a while &#8211; days at a minimum on a fast late 2012 iMac &#8211; with this many brains. The template can then be used for a registration target as a study-sepcific image. I&#8217;ve found that using a study-specific template potentially yields better results, especially for TBSS. Others have published on this:<\/p>\n<p>Bach, M., Laun, F. B., Leemans, A., Tax, C. M., Biessels, G. J., Stieltjes, B., &amp; Maier-Hein, K. H. (2014). Methodological considerations on tract-based spatial statistics (TBSS).\u00a0<i>NeuroImage<\/i>,\u00a0<i>100<\/i>, 358-369.<\/p>\n<p>Keihaninejad, S., Ryan, N. S., Malone, I. B., Modat, M., Cash, D., Ridgway, G. R., et al. (2012). The Importance of Group-Wise Registration in Tract Based Spatial Statistics Study of Neurodegeneration: A Simulation Study in Alzheimer&#8217;s Disease. <i>PLoS One<\/i>, <i>7<\/i>(11), e45996. doi:10.1371\/journal.pone.0045996<\/p>\n<p>The FA template result is below.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/80brain_FA_template.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-283\" src=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/80brain_FA_template-244x300.png\" alt=\"80brain_FA_template\" width=\"244\" height=\"300\" srcset=\"https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/80brain_FA_template-244x300.png 244w, https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/80brain_FA_template.png 777w\" sizes=\"(max-width: 244px) 100vw, 244px\" \/><\/a><\/p>\n<p>Just for fun, here is a 3D rendering of the FA template. Image rendered in <a title=\"Freeview\" href=\"http:\/\/surfer.nmr.mgh.harvard.edu\/fswiki\/FreeviewGuide\/FreeviewIntroduction\">Freeview<\/a>.<\/p>\n<p><a href=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/3D_FA_template_FA__2__9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-284 size-large\" src=\"http:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/3D_FA_template_FA__2__9-1024x821.png\" alt=\"3D_FA_template_FA__2__9\" width=\"1024\" height=\"821\" srcset=\"https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/3D_FA_template_FA__2__9-1024x821.png 1024w, https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/3D_FA_template_FA__2__9-300x240.png 300w, https:\/\/brainybehavior.com\/neuroimaging\/wp-content\/uploads\/2015\/02\/3D_FA_template_FA__2__9.png 1371w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>These instructions use FA images to create an FA template using the software package ANTs (http:\/\/stnava.github.io\/ANTs\/); the process should work well with other image modalities. First we can\u00a0use FLIRT to register a group of 4 brains (semi-randomly chosen by looking &hellip; <a href=\"https:\/\/brainybehavior.com\/neuroimaging\/2015\/02\/brain-template-creation-with-ants\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":284,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4,40,3],"tags":[34,66,64,63],"_links":{"self":[{"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/posts\/281"}],"collection":[{"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":8,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/posts\/281\/revisions\/303"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/media\/284"}],"wp:attachment":[{"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brainybehavior.com\/neuroimaging\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}