Differences between revisions 1 and 2
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Line 45: Line 44:
To save an rgb image: To save a TIFF image:
Line 48: Line 47:
set rgb <filename>
save_rgb
save_tiff <filename>
Line 52: Line 50:
Where <filename> is the name of the RGB file you want to create. Where <filename> is the name of the TIFF file you want to create.

You will probably want to position the surface to different views. Use:

{{{
make_lateral_view
redraw
}}}

To set it to a lateral view. From there you can rotate it to an inferior view:

{{{
make_lateral_view
rotate_brain_x 90
redraw
}}}

Or a medial view:

{{{
make_lateral_view
rotate_brain_y 180
redraw
}}}
Line 74: Line 95:

        make_lateral_view
Line 76: Line 99:
        set rgb ${file_name}-capture.rgb
        save_rgb
        save_tiff ${file_name}-lateral.tiff
Line 81: Line 103:
This will load overlay1.w and create overlay1.w-capture.rgb, then overlay2.w
and create overlay2.w-capture.rgb, and so on.
This will load overlay1.w and create overlay1.w-lateral.tiff, then overlay2.w
and create overlay2.w-lateral.tiff, and so on.
Line 85: Line 107:
from the current directory and save all the RGBs there. Tcl has a nice set from the current directory and save all the TIFFs there. Tcl has a nice set
Line 111: Line 133:
        set rgb_directory [file join path to my rgbs]
        set rgb [file join $rgb_directory [file tail [file name $val]]].rgb
        set tiff_directory [file join path to my tiffs]
        set tiff [file join $tiff_directory [file tail [file name $val]]].tiff
Line 115: Line 137:
This will set val to /path/to/my/data/overlay1.w, and rgb to
/path/to/my/rgbs/overlay1.rgb
This will set val to /path/to/my/data/overlay1.w, and tiff to
/path/to/my/tiffs/overlay1.tiff

This is a simple introduction to scripting. This will get you started on writing a script to open a series of overlay files and take screen shots of them.

First of all, the scripting langugage for tkmedit and tksurfer is Tcl, so you should get an introduction to Tcl on the web or from a book. The syntax is pretty simple.

You will start up tksurfer from the command line normally, so you can load your subject and surface from there. Then, you pass the script you want to run with the -tcl option. For example:

tksurfer bert lh inflated -tcl my_script.tcl

my_script.tcl would be a text file with your script commands.

Every tksurfer script must start with the command:

open_window

To turn on the color bar:

set colscalebarflag 1

To read a .w file, use the commands:

set val <filename>
sclv_read_from_dotw <field>

Where <filename> is the .w file name and <field> is 0-9, signifying which overlay layer you want to load this into. If you load an overlay into a layer that is already filled, it will replace what's there.

You will need to force a redraw of the screen after loading an overlay, so use this command:

redraw

To save a TIFF image:

save_tiff <filename>

Where <filename> is the name of the TIFF file you want to create.

You will probably want to position the surface to different views. Use:

make_lateral_view
redraw

To set it to a lateral view. From there you can rotate it to an inferior view:

make_lateral_view
rotate_brain_x 90
redraw

Or a medial view:

make_lateral_view
rotate_brain_y 180
redraw

There are different kinds of loops available, but if you want to loop over a series of elements in a list, such as file names to load, you can use:

foreach <varname> <list> {

}

This will iterate over all the elements in <list>, setting <varname> to each. For example:

open_window

set colscalebarflag 1
foreach file_name { overlay1.w overlay2.w overlay3.w } {

        set val $file_name
        sclv_read_from_dotw 0

        make_lateral_view
        redraw

        save_tiff ${file_name}-lateral.tiff
}

This will load overlay1.w and create overlay1.w-lateral.tiff, then overlay2.w and create overlay2.w-lateral.tiff, and so on.

You may need to use full file names if you don't want to load everything from the current directory and save all the TIFFs there. Tcl has a nice set of functions in the file command to do stuff like join paths, extract file names, and chop off extensions, e.g.:

set path [file join path to my data]

- path becomes /path/to/my/data

set file_name [file tail /path/to/my/data/overlay1.w]

- file_name becomes overlay1.w

set simple_file_name [file name overlay1.w]

- simple_file_name becomes overlay1

So:

        set base_directory [file join path to my data]
        set file_name overlay1.w
        set val [file join $base_directory $file_name]
...
        set tiff_directory [file join path to my tiffs]
        set tiff [file join $tiff_directory [file tail [file name $val]]].tiff

This will set val to /path/to/my/data/overlay1.w, and tiff to /path/to/my/tiffs/overlay1.tiff

There's a lot here, so I would suggest starting out with an introduction to Tcl, then creating a simple script to load and display an overlay file, then gradually add to it.

TkSurferGuide/TkSurferScripting/IntroToScripting (last edited 2008-04-29 11:46:19 by localhost)