#!/bin/tcsh -f if ("$1" == "-h" || "$1" == "-help") then goto HELP endif #Make copies of the original data set zver = "1.5-July3107" set home_dir = $PWD set orig_dir = ~/spm5/toolbox/Anatomy set orig_anat = colin27T1_seg.hdr set MNI2TTHead = $home_dir/N27/TT_N27+tlrc.HEAD set out_dir = $home_dir/CA_EZ_v$zver set out_readme = $out_dir/Readme_dist set reftxt = ~/afni/src/thd_ttatlas_CA_EZ-ref.h setenv AFNI_ANALYZE_ORIENT LPI setenv AFNI_ANALYZE_VIEW tlrc setenv AFNI_ANALYZE_ORIGINATOR YES if ( -d $out_dir ) then echo "Directory $out_dir exists, cleanup before proceeding." goto END endif #Following strings taken from output of se_note.m's output if ( -f $reftxt ) then echo "" echo "WARNING: Assuming file $reftxt is current!" echo "Otherwise, run matlab script CA_EZ_Prep first!" echo "" #echo 'Keep only lines with "", and replace new lines with \n' sed -n '/"*",/p' $reftxt > ___tmp_junk #echo 'Remove the quotes and put \n' set AllRef = `sed 's/$/\\n/g;s/",//g;s/"//g' ./___tmp_junk` rm -f ./___tmp_junk else echo "" echo "WARNING:" echo " $reftxt was not found, using standard version instead!" echo " That file is usually created by CA_EZ_Prep.m" echo " Hit Enter to proceed or stop script..." set jnk = $< set TitString = "Anatomy Toolbox Version $zver\n\n" set AuthorString = "Written by:\nSimon Eickhoff\nInstitut for Medicine (IME) Research Center Juelich\nLeo-Brandt-Str. 5; 52425 Juelich, Germany\nPhone + 49 2461-61-5219 / Fax + 49 2461-61-2820\ne-mail: s.eickhoff@fz-juelich.de\n\n" set RefString = "The following cytoarchitectonic maps have been published in peer reviewed journals:\n" set RefString = "${RefString}Auditory cortex (TE 1.0, TE 1.1, TE 1.2) : Morosan et al., Neuroimage, 2001\n" set RefString = "${RefString}Broca's area (BA 44, BA 45) : Amunts et al., J Comp Neurol, 1999\n" set RefString = "${RefString}Motor cortex (BA 4a, BA 4p, BA 6) : Geyer et al., Nature, 1996 ; S. Geyer, Springer press 2003\n" set RefString = "${RefString}Somatosensory cortex (BA 3a, BA 3b, BA 1 BA 2) : Geyer et al., Neuroimage, 1999 + 2000 ; Grefkes et al., Neuroimage, 2001\n" set RefString = "${RefString}Parietal operculum / SII (OP 1, OP 2, OP 3, OP 4) : Eickhoff et al., Cerebral Cortex, 2005a,b\n" set RefString = "${RefString}Amygdala (CM/LB/SF), Hippocampus (FD/CA /SUB/EC/HATA) : Amunts et al., Anat Embryol, 2005\n" set RefString = "${RefString}Visual cortex (BA 17, BA 18) : Amunts et al., Neuroimage, 2000\n" set RefString = "${RefString}\n" set WarnString = "Warning:\nAll other areas may only be used after consultation !\n" set AllRef = "$TitString" set AllRef = "$AllRef$AuthorString" set AllRef = "$AllRef$RefString" set AllRef = "$AllRef$WarnString" endif #goto README #The N27 data exists in N27 directory. After version 12, the datasets in the Zilles database appear in MNI_Anatomical space #Compile a list of all the .hdr files in the home dir cd $home_dir set comp_lbls = ( AllAreas MacroLabels AnatMask colin27T1_seg ) set comp_pref = ( N27_CA_EZ_MPM N27_EZ_ML N27_EZ_LR N27 ) set comp_resm = ( NN NN NN Cu ) set comp_list = ($orig_dir/${comp_lbls[1]}*.hdr $orig_dir/${comp_lbls[2]}*.hdr $orig_dir/${comp_lbls[3]}*.hdr $orig_dir/${comp_lbls[4]}*.hdr) set pmaps_list = ($orig_dir/PMaps/*.hdr) echo "Have $#comp_list dsets in $orig_dir" foreach ds ($comp_list) echo " $ds:t" end echo "Have $#pmaps_list dsets in $orig_dir/PMaps" foreach ds ($pmaps_list) echo " $ds:t" end echo "Pausing (Hit Enter to continue, ctrl+c to exit)..." set jnk = $< #make a copy of each pre-calculated dset and move them to MNI space mkdir $out_dir cd $out_dir set cnt = 0 foreach ds ($comp_list) @ cnt ++ set pref = "MNIa_"$comp_pref[$cnt] 3dcopy $ds ./${pref}+tlrc # changed AFNI_ANALYZE_VIEW above to go directly to +tlrc # 3drefit -view +tlrc ${pref}+orig set note = "${pref}+tlrc is in MNI_Anatomical Space. It contains the $comp_lbls[$cnt] atlas data." 3dNotes -a "$note" ${pref}+tlrc 3dNotes -a "$AllRef" ${pref}+tlrc 3drefit -sublabel 0 $comp_lbls[$cnt] ${pref}+tlrc #Now move the data to MNI space set prefn = "MNI_"$comp_pref[$cnt] @Shift_Volume -MNI_Anat_to_MNI -dset $pref+tlrc -prefix $prefn set note = "${prefn}+tlrc is in MNI Space. It contains the $comp_lbls[$cnt] atlas data." 3dNotes -a "$note" ${prefn}+tlrc 3dNotes -a "$AllRef" ${prefn}+tlrc 3drefit -sublabel 0 $comp_lbls[$cnt] ${pref}+tlrc #Now create the TT version set in_pref = "MNI_"$comp_pref[$cnt] set out_pref = "TT_"$comp_pref[$cnt] adwarp -resam $comp_resm[$cnt] -force -apar $MNI2TTHead -dpar ${in_pref}+tlrc -prefix ${out_pref} set note = "${out_pref}+tlrc is in AFNI TLRC Space. It contains the comp_lbls[$cnt] atlas data." 3dNotes -a "$note" ${out_pref}+tlrc 3dNotes -a "$AllRef" ${out_pref}+tlrc end cd $home_dir #Now assemble all the pmaps into one bucket set buck_pref = N27_CA_EZ_PMaps cd $out_dir 3dbucket -prefix MNIa_${buck_pref} $pmaps_list #fix the labels and the view 3drefit -view +tlrc MNIa_${buck_pref}+orig set note = "MNIa_${buck_pref}+tlrc is in MNI_Anatomical Space. Each sub-brick contains the proabability map of a cortical area" 3dNotes -a "$note" MNIa_${buck_pref}+tlrc 3dNotes -a "$AllRef" MNIa_${buck_pref}+tlrc set cnt = 0 foreach anat ($pmaps_list) set lbl = `@NoExt $anat hdr` 3drefit -sublabel $cnt $lbl:t MNIa_${buck_pref}+tlrc @ cnt ++ end #Now create the MNI version set in_pref = MNIa_${buck_pref} set out_pref = MNI_${buck_pref} @Shift_Volume -MNI_Anat_to_MNI -dset ${in_pref}+tlrc -prefix ${out_pref} set note = "${out_pref}+tlrc is in MNI Space. Each sub-brick contains the proabability map of a cortical area" 3dNotes -a "$note" ${out_pref}+tlrc 3dNotes -a "$AllRef" ${out_pref}+tlrc #Now create the TT version set in_pref = MNI_${buck_pref} set out_pref = TT_${buck_pref} adwarp -resam NN -force -apar $MNI2TTHead -dpar ${in_pref}+tlrc -prefix ${out_pref} set note = "${out_pref}+tlrc contains the Maximum Probability maps in AFNI TLRC Space." 3dNotes -a "$note" ${out_pref}+tlrc 3dNotes -a "$AllRef" ${out_pref}+tlrc cd $home_dir #Create a Readme file README: echo "AFNI adaptation of atlases from 'Anatomy Toolbox Version $zver'" > $out_readme echo "----------------------------------------------------------------" >> $out_readme echo "" >> $out_readme echo "++ References, Disclaimer and Usage Conditions for Anatomy Toolbox Atlases:" >> $out_readme 3dNotes -a "$AllRef" -ses >> $out_readme echo "" >> $out_readme echo "++ Notes on AFNI implementation of the toolbox:" >> $out_readme echo "Data were transformed to standard Talairach space to be consistent" >> $out_readme echo "with AFNI's coordinate system. However, the coordinates from" >> $out_readme echo "interactive and stand-alone 'whereami' are output in TLRC, MNI and" >> $out_readme echo "MNI Anatomical spaces." >> $out_readme echo "To use the database, simply copy place all datasets TT_N27* to AFNI's bin directory." >> $out_readme echo "" >> $out_readme echo "++ Thanks, Contact and Log" >> $out_readme echo "We thank Drs. Eickhoff and Zilles for providing the data." >> $out_readme echo "Questions and comments on AFNI's implementation should be directed to:" >> $out_readme echo " Dr. Ziad S. Saad, ziad@nih.gov" >> $out_readme echo "" >> $out_readme echo "(Data archive created on `date`," >> $out_readme echo "`hostname -s` in $PWD using `basename $0 $argv[*]`)" >> $out_readme echo "" >> $out_readme goto END HELP: echo "Creates AFNI version of the CA atlas by Eickhoff, Amnuts and Zilles." echo "You'll need to edit a few variables at the top of the script." echo "You'll need to run the matlab function CA_EZ_Prep to update the" echo "AFNI source files." echo "See also:" echo "SUMA/Readme_Modify.log" echo " search for + How you install a new Zilles, Amunts, Eickhoff SPM toolbox:" echo " to get info on proper sequence of execution" echo " @Create_suma_tlrc.tgz" echo " @Create_ca_ez_tlrc.tgz" echo " @DistArchives" echo " ZSS Feb 06" goto END END: