Here is a little script I wrote. It isn't very refined, and can be improved. It is also attached. It references a file you muct make in which you put all your subject names, one on each line of the text file like this:
sub001 sub002 sub003 ... Here is the script. #run this script from the Freesurfer Subjects Directory...alterntively, you can modify the script to work automatically #from the the FreeSurfer Subjects Directory Variable. However, since you might not be using the bash shell, maybe that variable wont be available. Anyway.. filename=/home/local/AD3/jlee31/Desktop/NORA/segmentz #This points to a file you will make in which every line contains a subject directory name. #The script will read this file line by line to get the data from each subject listed in the script statsfile=rh.curv.stats #Tells the scipt which kind of stat files you want to collect #Name the file you want to put your results into resultsFileName=results.txt #Ok here we go while read line; do sub=`echo $line | cut -d\. -f1` #gets the subject name from the file in the first line of this script currentStatsFile=./"$sub"/stats/$statsfile #puts together the fullpath of the stats file #Next Grep finds a line in the file (stored in the variable $myStatsFile) that mathces the criteria #(for example here I find the line "Raw Total Surface Area:" and echos that out to a result text file echo $sub" "`grep "Raw Total Surface Area:" $currentStatsFile` #>> $resultsFileName #creates a results txt file done < "$filename" - Joshua Lee Graduate Student Center for Mind and Brain & Department of Psychology University of California, Davis 530.747.3805 On Thu, May 17, 2012 at 2:37 PM, Vy Dinh <vy_d...@rush.edu> wrote: > Thanks for the suggestion Josh! I have definitely thought about this, but > since I'm a total novice bash programmer, I thought that it would be quicker > to learn which option to add to asegstats2table and aparcstats2table. I > would really appreciate it if you could help me come up with this code? What > shell function could I use to open each .stats file? How do I use grep to > call, say line 53 in the stats file? > > Many thanks, > > Vy > > > On Thu, May 17, 2012 at 4:19 PM, Joshua Lee <jki...@ucdavis.edu> wrote: >> >> Why not use a bash or csh script that loops through your subjects stat >> files, and use grep read the appropriate lines to a single text file >> with >>. >> >> - >> Josh >> >> >> On Thu, May 17, 2012 at 1:04 PM, Vy Dinh <vy_d...@rush.edu> wrote: >> > Dear Freesurfer Experts, >> > >> > I've created a couple of ROIs from qdec comparisons of thickness and >> > volume >> > between two groups. We extracted the data from these ROIs for each >> > subject >> > using mris_anatomical_stats. >> > >> > The stat files are located within each subjects folder: >> > sub/stats/rh.roi.stats >> > >> > Now, we would like to combine the data from each stat file to a text >> > file >> > using aparcstats2table and asegstats2table (for volume measures). I >> > already >> > have batch scripts that call these functions for multiple subjects. The >> > script basically concatenates all of the subject ids and inputs the >> > concatenated string into the aparcstats2table (or asegstats2table) >> > command. >> > >> > EX: >> > asegstats2table -s s1 -s s2 -s s3 -s s4 --hemi lh --meas volume >> > -tablefile >> > test_stats.txt >> > >> > I would like to modify my script so that I can extract the data from the >> > roi.stats file. This is only a matter of entering the correct inputs for >> > aparcstats2table and asegstats2table but I have tried with little >> > success. >> > The problems with each command are explained below. >> > >> > For asegstats2table: >> > According to documentation >> > (http://surfer.nmr.mgh.harvard.edu/fswiki/asegstats2table), I have tried >> > running "asegstats2table $STRING --meas volume --skip --tablefile >> > $OUTFILE " where string is "-i s1/stats/lh.roi.stats -i >> > s2/stats/lh.roi.stats ......etc" but get the error message: >> > >> > Building the table.. >> > Traceback (most recent call last): >> > File >> > >> > "/Users/skip/Desktop/harlow_mount/apps/fmri_progs/freesurfer_v51/freesurfer/bin/asegstats2table", >> > line 513, in <module> >> > rows, columns, table = sanitize_table(options, pretable) >> > File >> > >> > "/Users/skip/Desktop/harlow_mount/apps/fmri_progs/freesurfer_v51/freesurfer/bin/asegstats2table", >> > line 412, in sanitize_table >> > _specs, _id_name_map, _measl = _t[0] >> > IndexError: list index out of range >> > >> > >> > For aparcstats2table: >> > when I run the command: >> > >> > aparcstats2table $STRING --hemi lh --parc roi_name --skip --tablefile >> > $OUTFILE >> > >> > where string is "-s s1 -s s2 -s s3 ", I get a text file with 3 columns. >> > The >> > first column lists the subject ids, but what are the values for the 2nd >> > and >> > 3rd columns? Also, is it possible to input more than 2 .stats file for >> > the >> > command? >> > >> > >> > Looking forward to your responses, >> > >> > >> > Vy >> > >> > >> > Vy T.U. Dinh >> > Neurological Sciences >> > Rush University Medical Center >> > Phone: (312) 563-3853 >> > Fax: (312) 563-4660 >> > Email: vy_d...@rush.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. >> > > >
getResults.sh
Description: Bourne shell script
_______________________________________________ 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.