It is trying to use the annotation when making the registration tif. This is hard coded in your version of make_average_surface. I've attached a new version. Run it with --no-annot. Let me know if it works and I'll check it into our distribution
doug On 10/02/2014 12:00 AM, Reza Rajimehr wrote:
Hi Doug, Step 1 did not generate "/iter00/lh.reg.template.tif" - though there was no obvious error for that on the screen. Not sure if this happened because of not having an annot file for mris_make_template. Here is what I saw on the screen: %%%%%%%%%% /usr/local/freesurfer/bin/make_average_surface --subjects F99 --out iter00 --template-only --surf-reg sphere $Id: make_average_surface,v 1.53.2.1 2011/05/25 20:53:44 greve Exp $ Wed Oct 1 23:00:55 EDT 2014 /home/reza/structurals setenv SUBJECTS_DIR /home/reza/structurals/ output ddir is /home/reza/structurals/ uid=1000(reza) gid=1000(reza) groups=1000(reza),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare) ==================== make_average_surface ==================== Wed Oct 1 23:00:56 EDT 2014 /home/reza/structurals /usr/local/freesurfer/bin/make_average_surface --subjects F99 --out iter00 --template-only --surf-reg sphere input subjects: F99 output subject: iter00 mri_add_xform_to_header -c auto /home/reza/structurals//iter00/mri/mni305.cor.mgz /home/reza/structurals//iter00/mri/mni305.cor.mgz INFO: extension is mgz #@# Making lh registration template --------- /home/reza/structurals/iter00 mris_make_template -norot -annot aparc lh sphere F99 lh.reg.template.tif not aligning hemispheres before averaging. zeroing medial wall in aparc creating new parameterization... processing subject F99 (1 of 1) reading spherical surface /home/reza/structurals//F99/surf/lh.sphere... could not read annot file /home/reza/structurals//F99/surf/../label/lh.aparc.annot No such file or directory mris_make_template: could not read annot file aparc No such file or directory ERROR: cannot find /home/reza/structurals//iter00/lh.reg.template.tif ERROR: cannot find /home/reza/structurals//iter00/lh.reg.template.tif ERROR: cannot find /home/reza/structurals//iter00/lh.reg.template.tif %%%%%%%%%% Reza Hi Reza, I think that this should work. doug set subjectlist = (subject1 subject2 ...) 1. Create a template from a single subject make_average_surface --subjects $subjectlist[1] \ --out iter00 --template-only --surf-reg sphere.reg 2. Register each subject to this template, including first subject. Each of these may take 30 min, so, if you have a lot of subjects, you may want to submit each job to the cluster. foreach subject ($subjectlist) # Create subject/surf/iter00.sphere.reg, --no-annot for monkey surfreg --s $subject --t iter00 --no-annot end 3. Create a new template from all subjects using the new registration make_average_surface --subjects $subjectlist \ --out iter01 --template-only --surf-reg iter00.sphere.reg 4. Register each subject to this new template foreach subject ($subjectlist) # Create subject/surf/iter01.sphere.reg, --no-annot for monkey surfreg --s $subject --t iter01 --no-annot end 5. Return to step 3. Iterate 4 or 5 times to remove the dependence on the first subject. When using mri_surf2surf or mris_preproc, spec --surfreg iterXX.sphere.reg. For mris_preproc also spec --targ iterXX _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
-- Douglas N. Greve, Ph.D. MGH-NMR Center gr...@nmr.mgh.harvard.edu Phone Number: 617-724-2358 Fax: 617-726-7422 Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting FileDrop: https://gate.nmr.mgh.harvard.edu/filedrop2 www.nmr.mgh.harvard.edu/facility/filedrop/index.html Outgoing: ftp://surfer.nmr.mgh.harvard.edu/transfer/outgoing/flat/greve/
#! /bin/tcsh -f # # make_average_surface # # Creates average surfaces and curvatures from a set of subjects. # # --help option will show usage # # Original Author: Doug Greve # CVS Revision Info: # $Author: greve $ # $Date: 2012/01/15 22:58:00 $ # $Revision: 1.58 $ # # Copyright © 2011 The General Hospital Corporation (Boston, MA) "MGH" # # Terms and conditions for use, reproduction, distribution and contribution # are found in the 'FreeSurfer Software License Agreement' contained # in the file 'LICENSE' found in the FreeSurfer distribution, and here: # # https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense # # Reporting: freesurfer@nmr.mgh.harvard.edu # # # uncomment this to increase number of allowable open files to maximum: #limit descriptors unlimited set VERSION = '$Id: make_average_surface,v 1.58 2012/01/15 22:58:00 greve Exp $'; setenv FIX_VERTEX_AREA set PrintHelp = 0; set UseSymLink = 1; set sdout = (); set inputargs = ($argv); if ( $?SUBJECTS) then set SUBJECTS=($SUBJECTS) endif if ( $?SUBJECTS_DIR) then set SUBJECTS_DIR=($SUBJECTS_DIR) endif set average_subject=average set sphere_reg=sphere.reg set transform_fname="" set XFORM_FLAG="" set ico_no=7 set DoXHemi = 0; set topdir = (); set DoTemplateOnly = 0; set hemilist = (); set measlist = (sulc curv thickness area volume inflated.H) set UseAnnot = 1; # these should match latest declarations in recon-all set DESIKAN_GCS = curvature.buckner40.filled.desikan_killiany.2010-03-25.gcs set DESTRIEUX_GCS = destrieux.simple.2009-07-29.gcs # note: SUBJECTS can be set by --subjects # SUBJECTS_DIR can be set by --sdir # average_subject can be set by --out # sphere_reg can be set by --surf-reg # transform_fname can be set by --xform (default is no file specified) # XFORM_FLAG appends -X to transform_fname if --xform is specified if($#argv == 0) then # zero args is allowed only if SUBJECTS env var is declared if ( ! $?SUBJECTS) then goto usage_exit; endif endif goto parse_args; parse_args_return: goto check_params; check_params_return: # This will put the data under $sdout (SUBJECTS_DIR by default) set ddir = ${sdout}/${average_subject} mkdir -p ${ddir} \ ${ddir}/surf \ ${ddir}/mri \ ${ddir}/mri/transforms \ ${ddir}/scripts \ ${ddir}/label \ ${ddir}/stats cd $sdout/${average_subject} set LF = ${ddir}/scripts/make_average_surface.log if(-e $LF) mv $LF $LF.bak echo "" | tee -a $LF echo "setenv SUBJECTS_DIR $SUBJECTS_DIR" | tee -a $LF echo $0 $inputargs | tee -a $LF echo "" | tee -a $LF echo $VERSION | tee -a $LF date | tee -a $LF pwd | tee -a $LF echo "output ddir is $sdout" | tee -a $LF id | tee -a $LF set tSecStart = `date '+%s'`; # # Begin script guts... # echo ==================== | tee -a $LF echo make_average_surface | tee -a $LF echo ==================== | tee -a $LF date | tee -a $LF pwd | tee -a $LF echo $0 | tee -a $LF echo $inputargs | tee -a $LF echo input subjects: ${SUBJECTS} | tee -a $LF echo output subject: ${average_subject} | tee -a $LF # Copy MNI 305 to output mri dir set mni305 = $FREESURFER_HOME/average/mni305.cor.mgz if(! -e $mni305) then echo "ERROR: cannot find $mni305" exit 1; endif cp $mni305 $sdout/${average_subject}/mri # Set the MNI305 xfm fname to 'auto' set mnivol = $sdout/${average_subject}/mri/mni305.cor.mgz set cmd = (mri_add_xform_to_header -c auto $mnivol $mnivol) echo $cmd | tee -a $LF $cmd | tee -a $LF if($status) exit 1; # Create a file with the list of subjects (will not include xhemi) set subjlistfile = /tmp/subjlistfile.$$ rm -f $subjlistfile foreach s ($SUBJECTS) echo $s >> $subjlistfile end cp $subjlistfile list.subjects.txt set subjlistfile = $SUBJECTS_DIR/$average_subject/list.subjects.txt # Include cross-hemi registration if($DoXHemi) then set tmp = (); foreach s ($SUBJECTS) set tmp = ($tmp $s $s/xhemi) end set SUBJECTS = ($tmp); endif #------------------------------------------------------------ # Make the lh and rh template first so that other jobs can be started foreach hemi ($hemilist) echo "" | tee -a $LF # ------------------------------------------------------------------ echo "#@# Making $hemi registration template ---------" | tee -a $LF set atlas = $hemi.reg.template.tif set cmd = (mris_make_template -norot aparc \ $hemi $sphere_reg $SUBJECTS $atlas) if($UseAnnot) set cmd = ($cmd -annot) pwd | tee -a $LF echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit(1); end #------------------------------------------------------------ # Now do everything else foreach hemi ($hemilist) if($DoTemplateOnly) continue; echo "" | tee -a $LF cd $sdout/$average_subject #-------------------------------------------------------------- foreach s (white pial orig) echo "#@# Making average $hemi.$s surface ---------------------" | tee -a $LF date | tee -a $LF set cmd = (mris_make_average_surface $XFORM_FLAG \ -i $ico_no -o $s -sdir-out $sdout\ ${hemi} \ ${s} ${sphere_reg} \ ${average_subject} \ $SUBJECTS ) pwd | tee -a $LF echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) then echo "mris_average_surface failed" | tee -a $LF exit 1; endif echo "" | tee -a $LF echo "" | tee -a $LF end # loop over surfaces #-------------------------------------------------------------- # Create sphere and sphere.reg # mris_make_average_surface creates its own sphere.reg, # so delete it and copy ico rm -f surf/$hemi.$sphere_reg if($ico_no == 7) then # for historical reasons, use ?h.sphere.reg for ico7 set icoreg = ${FREESURFER_HOME}/average/surf/${hemi}.sphere.reg else set icoreg = ${FREESURFER_HOME}/average/surf/${hemi}.sphere.ico$ico_no.reg endif cp $icoreg surf/$hemi.sphere # Create a link to sphere.reg (want to do this? or reg to fsaverage?) if($UseSymLink) then cd surf ln -s $hemi.sphere $hemi.sphere.reg ln -s $hemi.sphere $hemi.$average_subject.sphere.reg cd .. else cp surf/$hemi.sphere surf/$hemi.sphere.reg cp surf/$hemi.sphere surf/$hemi.$average_subject.sphere.reg endif echo "---------------------------------------------------" | tee -a $LF echo "" | tee -a $LF #-------------------------------------------------------------- echo "#@# Smoothing, inflating, etc $hemi ----------------" | tee -a $LF cd $sdout/${average_subject}/surf pwd | tee -a $LF # Smooth white to get smoothwm (should average the indiv smoothwms?) set cmd = (mris_smooth -nw -n 5 ./${hemi}.white ./${hemi}.smoothwm) echo $cmd |& tee -a $LF $cmd | tee -a $LF if($status) exit 1; echo "" | tee -a $LF # Inflate the smoothwm set niters = "-n 15"; if($ico_no <= 5) set niters = "-n 2"; set cmd = (mris_inflate -dist .01 -f .001 -no-save-sulc $niters ./${hemi}.smoothwm ./${hemi}.inflated) echo $cmd |& tee -a $LF $cmd | tee -a $LF if($status) exit 1; echo "" | tee -a $LF cd $sdout/$average_subject # Create average annot foreach annot (aparc aparc.a2009s) set cmd = (annot2std --o label/$hemi.$annot.annot --$hemi \ --f $subjlistfile --t $average_subject --a $annot \ --srcsurfreg $sphere_reg --trgsurfreg sphere.reg) if($DoXHemi) set cmd = ($cmd --xhemi) echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit 1 end # Create cortex label from Christophe's medial wall set annot = $ddir/label/$hemi.aparc.a2009s.annot if(! -e $annot) then echo "ERROR: cannto find $annot" |& tee -a $LF exit 1; endif # Create tmpdir set tmpdir = $ddir/make_cortex_label.tmp.$$ rm -rf $tmpdir mkdir -p $tmpdir # Unload all of Christophe's labels into tmpdir set cmd = (mri_annotation2label --subject $average_subject \ --hemi $hemi --outdir $tmpdir --annotation aparc.a2009s) echo $cmd |& tee -a $LF $cmd |& tee -a $LF if($status) exit 1; set MW = $tmpdir/$hemi.Unknown.label if(! -e $MW) set MW = $tmpdir/$hemi.Medial_wall.label if(! -e $MW) then echo "ERROR: cannot find $hemi.Unknown.label or $hemi.Medial_wall.label" exit 1; endif mv $MW $ddir/label/$hemi.Medial_wall.label # Move medial wall out of dir # Create the cortex label with all the remaining labels set ctxlabel = $ddir/label/$hemi.cortex.label set cmd = (mri_mergelabels -o $ctxlabel -d $tmpdir) echo $cmd |& tee -a $LF $cmd |& tee -a $LF if($status) exit 1; rm -rf $tmpdir; # Cleanup # Create average surface measures foreach meas ($measlist) set measout = $ddir/surf/stack.$hemi.$meas.mgh set cmd = (mris_preproc --out $measout --f $subjlistfile \ --target $average_subject --hemi $hemi --meas $meas \ --srcsurfreg $sphere_reg --log $ddir/scripts/mris_preproc.$hemi.$meas.log) if($DoXHemi) set cmd = ($cmd --xhemi) echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit 1 # Compute average across subject set avgmeas = $ddir/surf/$hemi.$meas.avg.mgh if($meas == area) set avgmeas = $ddir/surf/$hemi.white.avg.area.mgh; # backcompat set cmd = (mri_concat $measout --mean --o $avgmeas) echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit 1 # Compute std across subject set stdmeas = $ddir/surf/std.$hemi.$meas.mgh set cmd = (mri_concat $measout --std --o $stdmeas) echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit 1 # Convert avg to curv set tval = $ddir/surf/$hemi.$meas set cmd = (mri_surf2surf --sval $avgmeas --s $average_subject \ --tval $tval --trg_type curv --hemi $hemi) pwd | tee -a $LF echo $cmd | tee -a $LF $cmd |& tee -a $LF if($status) exit 1 # Delete temporary stuff if($meas != area) rm $avgmeas end # meas end # hemi echo "---------------------------------------------------" | tee -a $LF echo "" | tee -a $LF set tSecEnd = `date '+%s'`; @ tSecRun = $tSecEnd - $tSecStart; set tRunHours = `echo $tSecRun/3600|bc -l` set tRunHours = `printf %5.2f $tRunHours` echo "make_average_surface-Run-Time-Hours $tRunHours" |& tee -a $LF date | tee -a $LF echo "make_average_surface done" | tee -a $LF echo "" exit 0 ############################################### ############--------------################## parse_args: set cmdline = ($argv); set getting_subjects = 0; while( $#argv != 0 ) set flag = $argv[1]; if (! $getting_subjects) then shift; endif switch($flag) case "--help": set PrintHelp = 1; goto usage_exit; exit 0; case "--version": echo $VERSION exit 0; case "--s": case "--subjects": if ( $#argv == 0) goto arg1moreerr; set SUBJECTS = $argv[1]; shift; # loop on getting variable number of subject names set getting_subjects = 1; # see 'default:' case breaksw case "--fsgd": if ( $#argv == 0) goto arg1err; set fsgdf = $argv[1]; shift; if(! -e $fsgdf) then echo "ERROR: cannot find $fsgdf"; exit 1; endif set sl = `cat $fsgdf | awk '{if($1 == "Input") print $2}'`; set SUBJECTS = ($sl); breaksw case "--out": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if ( $#argv == 0) goto arg1err; set average_subject = $argv[1]; shift; breaksw case "--surfreg": case "--surf-reg": case "--surf_reg": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if ( $#argv == 0) goto arg1err; set sphere_reg = $argv[1]; shift; breaksw case "--topdir": case "--sd-out": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if( $#argv < 1) goto arg1err; set sdout = $argv[1]; shift; breaksw case "--sd": case "--sdir": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if ( $#argv == 0) goto arg1err; set SUBJECTS_DIR = $argv[1]; shift; setenv SUBJECTS_DIR $SUBJECTS_DIR breaksw case "--xform": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if ( $#argv == 0) goto arg1err; set transform_fname = $argv[1]; shift; set XFORM_FLAG = "-X $transform_fname"; breaksw case "--ico": case "--i": if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if ( $#argv == 0) goto arg1err; set ico_no = $argv[1]; shift; breaksw case "--meas" if ( $getting_subjects ) then # got em all, from --subjects variable arg loop set getting_subjects = 0; shift; endif if($#argv < 1) goto arg1err; set measlist = ($measlist $argv[1]); shift; breaksw case "--symlink": if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif set UseSymLink = 1; breaksw case "--no-annot": if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif set UseAnnot = 0; breaksw case "--no-symlink": case "--no-link": if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif set UseSymLink = 0; breaksw case "--nocleanup": # This has no effect, but needed for compat with make_average_volume set cleanup = 0; if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--debug": case "--echo": set echo = 1; set verbose = 1; if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--template-only": set DoTemplateOnly = 1; if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--xhemi": set DoXHemi = 1; if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--lh": set hemilist = (lh) if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--rh": set hemilist = (rh) if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--lhrh": set hemilist = (lh rh) if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw case "--no-xhemi": set DoXHemi = 0; if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw # These are flags passed to make_average_subject, but dont apply here case "--no-surf": case "--no-vol": case "--force": case "--link": case "--keep-all-orig": if ( $getting_subjects ) then set getting_subjects = 0; # got em all, from --subjects variable arg loop endif breaksw default: if ( $getting_subjects ) then # loop on getting variable number of subjects, # until a new flag is found, or no more args set SUBJECTS = ( $SUBJECTS $argv[1] ); shift; set getting_subjects = 1; else echo ERROR: Flag $flag unrecognized. echo $cmdline exit 1 endif breaksw endsw end goto parse_args_return; ############--------------################## ############--------------################## check_params: if (! $?SUBJECTS) then echo "ERROR: no subjects declared!" echo "Either declare subjects in SUBJECTS variable," echo "or declare using --subjects argument." exit 1 endif if (! $?SUBJECTS_DIR) then echo "ERROR: SUBJECTS_DIR is not declared!" echo "Either set the SUBJECTS_DIR environment variable," echo "or declare using --sdir argument, the root directory" echo "for subject data files." exit 1 endif if(! -e $SUBJECTS_DIR ) then echo "ERROR: SUBJECTS_DIR $SUBJECTS_DIR does not exist." exit 1; endif if(! $?FREESURFER_HOME ) then echo "ERROR: environment variable FREESURFER_HOME not set." exit 1; endif if(! -e $FREESURFER_HOME ) then echo "ERROR: FREESURFER_HOME $FREESURFER_HOME does not exist." exit 1; endif if($#sdout == 0) set sdout = $SUBJECTS_DIR; if($#hemilist == 0) set hemilist = (lh rh) goto check_params_return; ############--------------################## ############--------------################## arg1err: echo "ERROR: flag $flag requires one argument" exit 1 ############--------------################## ############--------------################## arg1moreerr: echo "ERROR: flag $flag requires one or more arguments" exit 1 ############--------------################## ############--------------################## usage_exit: echo "" echo "USAGE: make_average_surface" echo "" echo "Required Arguments" echo " --subjects <subj1> <subj2> ... <subjN>" echo " : or declare subjects in SUBJECTS env var" echo " --fsgd fsgdfile : get subject list from fsgd" echo "" echo "Optional Arguments" echo " --out <average subject name> : default name is 'average'" echo " --sdir <SUBJECTS_DIR to use instead of the one in the env>" echo " --sd : same as --sdir" echo " --sd-out topdir : put data here" echo " --xform <transform_fname> : filename of transform file" echo " --ico <number> : specify icosahedron number, default is 7 (ic7.tri)" echo " --surf-reg <surface name> : alternative registration surface" echo " --lh : only do left hemi (default is to do both)" echo " --rh : only do right hemi (default is to do both)" echo " default: sphere.reg" echo " --force : overwrite existing average subject data" echo " --no-annot : do not use annotation when making template tif" echo " --template-only : useful when creating iterative atlases" echo "" echo " --help : short descriptive help" echo " --no-symlink : do not use symbolic links (just copy files)" echo " --no-lik : same as --no-symlink" echo " --version : script version info" echo " --echo : enable command echo, for debug" echo " --debug : same as --echo" echo "" echo "See also: recon-all, make_final_surfaces, morph_subject" echo "" if(! $PrintHelp) exit 1; echo Version: $VERSION cat $0 | awk 'BEGIN{prt=0}{if(prt) print $0; if($1 == "BEGINHELP") prt = 1 }' exit 1; #---- Everything below here is printed out as part of help -----# BEGINHELP Creates average surfaces and curvatures from a set of subjects. Calls mris_average_curvature, mris_make_average_surface, mris_smooth, mris_inflate, and mris_curvature. EXAMPLE make_average_surface --out avgsubject --subjects subj1 subj2 subj3 subj4 will create $SUBJECTS_DIR/avgsubject with average surfaces for orig, white, pial, inflated for each hemi. SEE ALSO make_average_subject, make_average_volume GETTING HELP Run recon-all --help for extensive text on the reconstruction process. Or, send email to freesurfer@nmr.mgh.harvard.edu. Also see http://surfer.nmr.mgh.harvard.edu.
_______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.