Hi Kevin et al,
it's great to have these options for scripting.
I want to loop over subjects. Will read_surface_vertex_set work in this context? I can't see that it provides a way to change the subjid. I'm trying to do this:
########################################################## # BEGIN script to loop over subjects set FREESURFER_HOME "/home/dweber/freesurfer/home" set SUBJECTS_DIR "/home/dweber/freesurfer/subjects"
set subjects [ glob -directory ${SUBJECTS_DIR} "ucsf_??" ] set subjects [ lsort $subjects ]
set surfaces {inflated pial}
foreach subject $subjects {
if ![ file isdirectory $subject ] { continue }
set subjID [ file tail $subject ]
puts $subjID
set subjPath [ file join ${SUBJECTS_DIR} ${subjID} ]
set subjSurfPath [ file join ${subjPath} surf ] set subjTiffPath [ file join ${subjPath} rgb ]
foreach h {lh rh} { foreach surf $surfaces {
# ----------------------------------------------- # load the surface, with curvature # this invocation doesn't work #tksurfer -$subjID $h $surf set insurf [file join ${subjSurfPath} ${h}.${surf} ] read_binary_surf
set curv [file join ${subjSurfPath} ${h}.curv] read_binary_curv
UpdateAndRedraw # etc. } } } # END script to loop over subjects ##########################################################
This script works, but I have to call it using
tksurfer -subjid rh orig -tcl subjloop.tcl
I would prefer to invoke tksurfer inside the tcl script and run the whole thing from csh. I'm a little puzzled about how to invoke tksurfer inside a tcl script.
From csh:
$ tksurfer -subjid rh orig
will automatically call the tksurfer.tcl script. I get the same result within wish (or tclsh):
$ wish % tksurfer -subjid rh orig % exit # close tksurfer % exit # exit wish $
That works fine, so tksurfer is in the tclsh and wish path and tksurfer finds tksurfer.tcl OK.
However, almost the same invocation does not work like this:
$ cat > fs_test.tcl #!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@" tksurfer -subjid rh orig exit exit CNT-D $ chmod +x fs_test.tcl $ ./fs_test.tcl
This gives the error: invalid command name "tksurfer" while executing "tksurfer -$subjID $h $surf"
It makes no difference if the call to tksurfer is a full path to tksurfer. How do you invoke tksurfer from within a tcl script?
Essentially I want a script that will loop over subjects, hemispheres and surfaces. I can put the loops into one tcl script and call it by using the -tcl option, eg: tksurfer -subjid rh orig -tcl subjloop.tcl. However, I am wondering if the initialization for the input -subjid screws up the loops over other subjects in the tcl script? Maybe I should be using a shell script to loop over subjects, hemisphere and surfaces, using a new tksurfer invocation for each. The problem is that the initialization of tksurfer has complexity built into tksurfer.tcl, which implements a lot of initialization. It's not clear to me how this interacts with a custom script. So, what happens to tksurfer.tcl when a custom script is invoked with the -tcl option, does it still get called?
Best, Darren
Kevin Teich wrote:
Sorry, there's no way to change the resolution of the TIFF images. However, we don't supersample when taking screen shots, so just make the window as big as you can, take the TIFF, and then you can use an image conversion program to change the DPI.
I don't think you want to use read_binary_surf. If you're just trying to load a single vertex set in addition to the ones you've already loaded, use this function:
read_surface_vertex_set field fileName
Reads a set of vertices from the fle in fileName. field should be one of the following:0 Main vertices 1 Inflated vertices 2 White vertices 3 Pial vertices 4 Orig vertices
I was having your problem until I replaced read_binary_surf with read_surface_vertex_set, then labl_load works as expected.
On Sun, Feb 26, 2006 at 07:19:22PM -0800, Darren Weber wrote:
Hi Daniel et al.,
thanks for the rotate and save_tiff script. I've installed the dev version (redhat 9 download onto Debian sarge) and the script works well. I would like to set the resolution of the .tif output files (eg, 600 dpi), can we do that?
I have a problem when using a label in the tcl script (see example.tcl below). I can startup tksurfer from the csh prompt, create a label, save it, exit, start again, load the label, and it displays correctly. So I assume all the label tools are working. When I restart with -tcl example.tcl, tksurfer draws an entirely blue surface after loading the label (any label). Have you seen this before? Am I doing something wrong? Should I source the tksurfer.tcl script, at the beginning of this script, to get all the lighting etc. correct? I tried to startup tksurfer normally, with no explicit -tcl option, and then "source example.tcl" at the tcl prompt, but the entire surface turns blue after the script loads a label. Can you replicate this or advise me how to avoid it?
Is it possible to create a shell script or a tcl script that can startup tksurfer and run a specific tcl script across a group of subjects?
Thanks, Darren
################################################################## # START EXAMPLE.TCL SCRIPT
set SUBJECTS_DIR "/usr/local/freesurfer/subjects"
set subjID "ucsf_cj" set subjPath [ file join ${SUBJECTS_DIR} ${subjID} ]
set subjSurfPath [ file join ${subjPath} surf ] set subjLabelPath [ file join ${subjPath} label ] set subjTiffPath [ file join ${subjPath} rgb ]
foreach h {lh} {
# ----------------------------------------------- # load the inflated surface, with curvature
set insurf [file join ${subjSurfPath} ${h}.inflated] read_binary_surf
set curv [file join ${subjSurfPath} ${h}.curv] read_binary_curv
UpdateAndRedraw
# ----------------------------------------------- # load and display relevant .label files
set labels [ glob -directory ${subjLabelPath} "${h}_test.label" ] foreach l $labels { puts "loading label: $l" labl_load "$l" # AT THIS POINT WE HAVE AN ENTIRELY BLUE SURFACE }
# now rotate and save the views ... } # END TCL SCRIPT ##################################################################
Best, Darren
Daniel Goldenholz wrote:
Hi Darren and other Freesurfers
I wrote a tcl script to do just what was described. The one I made gives the flexibility to name the tiff files based on a prefix that you specify before running the script. This way you run the same exact script for as many pictures as you like, simply changing the prefix before running the script.
Here is what you do. In tksurfer, after you have set up whatever overlays and/or labels and/or surfaces etc that you like, you enter at the command prompt set pre <whatever-you-want>
(where the stuff inside the < > is any file prefix... for instance, set pre bold_contrast1 )
then you run the following tcl script via the menu for running a script...
UpdateAndRedraw puts "Taking Snapshots..." make_lateral_view rotate_brain_y 90 redraw set tiff "${pre}_bck.tif" save_tiff $tiff make_lateral_view redraw set tiff "${pre}_lat.tif" save_tiff $tiff rotate_brain_y 180 redraw set tiff "${pre}_med.tif" save_tiff $tiff make_lateral_view rotate_brain_x 90 redraw set tiff "${pre}_inf.tif" save_tiff $tiff rotate_brain_x 180 redraw set tiff "${pre}_sup.tif" save_tiff $tiff make_lateral_view rotate_brain_y 270 redraw set tiff "${pre}_front.tif" save_tiff $tiff
Darren Weber wrote:
Hi Bruce etal,
I would like a short tcl script to rotate each hemisphere through all the main views (lateral, medial, dorsal, ventral, anterior, posterior) and output a graphics file with the name of the subject and the view in the file name. I've found rotate_brain_[xyz] and save_rgb, but the latter does not permit a file name for the output graphics. I would like high-resolution graphics for publications, but the save_rgb outputs about 85-90 dpi images. Is there an option for vector graphics or high resolution tiff or png images?
Best, Darren _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
--
Darren L. Weber, Ph.D. Visiting Postdoctoral Scholar
Dynamic Neuroimaging Laboratory, Department of Radiology, University of California, San Francisco, 185 Berry Street, Suite 350, Box 0946, San Francisco, CA 94107, USA.
Tel: +1 415 353-9444 Fax: +1 415 353-9421 www: http://dnl.ucsf.edu/users/dweber
"To explicate the uses of the brain seems as difficult a task as to paint the soul, of which it is commonly said, that it understands all things but itself." --Thomas Willis (The Anatomy of the Brain and Nerves, 1664)
Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer