[Freesurfer] Re: tcl script - rotate and save graphics (Darren Weber)

2006-02-22 Thread Glenn Lawyer




Hi, Darren,

I once made an animated gif of a rotating brain showing some freesurfer
results. I did this with two scripts. The first is a tcl script that
was passed to tksurfer; it rotates the brain and saves the resulting
images. The second is a shell script that uses imagemagik to convert
all of the resulting rgb images into one animated gif. 

I am attaching the scripts. Please be aware, however, that the tcl
script isn't very elegent. I'm actually a little embarassed by it.
Also, both scripts are set up for my file system, you will need to edit
a few of the settings to get them to work for you.

The tcl script is based on an earlier one I saw on the mailing list, I
think it was Doug Greve's, but I'm not sure. I don't give credit in the
script itself, sorry for the oversight!

+glenn
-- 
It is not an aesthetic process; it's a form 
of magic that interposes itself between us 
and the hostile universe, a means of seizing 
power by imposing a form on our terrors as 
well as on our desires.

  Glenn Lawyer   
  +352 061 967 244   
  Instituttgruppe for psykiatri  
  Postboks 1130 Blindern  
  0318 Oslo  
  http://folk.uio.no/davidgl 
:)



# snapshot.tcl
#
# tcl script for making pics using tksurfer.
#
# This script automates a set of tksurfer commands.
#
# Be sure to check the base directory and the
# regular expression before running!
#
# Pictures will be put in the images directory
# underneath the basedir.
#
# You may also want to adjust the thresholds
# and lighting models.
#
# glenn, sept 2005
##

# To use: Set all the parameters and then
# pass the script as an argument to tksurfer
# for example:
#  tksurfer average7 lh inflated -tcl snapshots.tcl
#


# The basedir is where all the w files are found
# You probably need to set this to the correct value
set basedir /home/DARREN/MY_ANALYSIS/   


# Use a regular expression to find all of the
# *.w files for each hemisphere
foreach wfile [glob ${hemi}*.w] {
# read the wfile
set layr 0
set val ${basedir}/${wfile}
sclv_read_binary_values $layr

# set thresholds for the overlay
# and values for the lighting model
set fthresh 1
set fslope 1
set fmid 2
do_lighting_model 0.6 0.9 0.6 0.2 0.4;


#   Make and save .rgb images
set cnt 1
set imagename [string trim $wfile .w]
set filestem /${basedir}/images/${imagename}
puts Taking Snapshots to $filestem;

make_lateral_view; # sets to default orientation
redraw;
set filestem /${basedir}/images/${cnt}_${imagename}
setfile rgb ${filestem}.rgb;
puts $rgb;
save_rgb;

# rotate up
set i 0 
while {$i  110} {
	rotate_brain_x -1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# rotate down/towards
set i 0
while {$i  90} {
	rotate_brain_x 1;
	rotate_brain_y -1;
	rotate_brain_z 1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# rotate down/away
set i 0
while {$i  20} {
	rotate_brain_x -1;
	rotate_brain_y 1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# rotate away
make_lateral_view;
rotate_brain_y -90;
set i 0 
set j 0
while {$i  100} {
	rotate_brain_y 2;
	if {$j  20  $j  -1} {
	rotate_brain_x 1;
	rotate_brain_z -1;}
	if {$j = 30  $j  50} {
	rotate_brain_x -1;
	rotate_brain_z 1;}
	if {$j == 60} {
	set j -10;}
	if {$i  79} { set j 3}
	incr j 1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# rotate up
set i 0
while {$i  40} {
	rotate_brain_x 1;
	rotate_brain_y -1;
	rotate_brain_z -1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# rotate up
set i 0
while {$i  40} {
#	rotate_brain_x -1;
	rotate_brain_y -1;
	rotate_brain_z -1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}
# and back home
#set i 0
while {$i  90} {
	rotate_brain_x -1;
#	rotate_brain_y -1;
	rotate_brain_z -1;
	incr i 1;
	incr cnt 1;
	redraw;
	set filestem /${basedir}/images/${cnt}_${imagename}
	setfile rgb ${filestem}.rgb;
	puts $rgb;
	save_rgb;
}


}
exit




immagic.sh
Description: application/shellscript
___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

[Freesurfer] file paths in mgz headers

2006-02-22 Thread Glenn Lawyer




Hi,

We like to structure our work by putting all scans into a batch account
and doing recon-all -autorecon1 -autorecon2. We then transfer the scans
to our individual accounts to check the quality before running the rest
of the processing stream.

This creates a small problem, in that the full path to the
talairach.xfm is saved as part of the mgz volume. When we move the scan
from the batch account to the user account, this path is no longer
valid. We can fix this by using mri_add_xform_to_header, as per
msg02241 on the mailing list (Doug Greve, 27 Jan 2006). 

What we are wondering is if the mgz header has any other path-dependant
information that we would need to update in the scenario such as above,
where scan workup and group analysis processing can take place over
multiple file locations? 

+glenn


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

Re: [Freesurfer] tcl script - rotate and save graphics

2006-02-22 Thread Kevin Teich

If you are using a recent dev version of tksurfer, then try the function:

save_tiff filename

If you enter this into the shell and it doesn't work, then you have an
older version. Our new release will have this function.

There is (finally) some documentation for scripting commands in
tksurfer, although it is for the newer dev version.

https://surfer.nmr.mgh.harvard.edu/fswiki/TkSurferGuide_2fTkSurferScripting


 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?


-- 

Kevin Teich
___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


Re: [Freesurfer] tcl script - rotate and save graphics

2006-02-22 Thread Daniel Goldenholz

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 theis 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
 



--
Daniel Goldenholz
-
Cell: 617-935-9421  http://people.bu.edu/danielg/


Mavet v'chaim b'yad halashon
Life and death are in the hands of language
   - Proverbs 18:21

___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


Re: [Freesurfer] file paths in mgz headers

2006-02-22 Thread Doug Greve




I don't think so.

Glenn Lawyer wrote:

  
  
Hi,
  
We like to structure our work by putting all scans into a batch account
and doing recon-all -autorecon1 -autorecon2. We then transfer the scans
to our individual accounts to check the quality before running the rest
of the processing stream.
  
This creates a small problem, in that the full path to the
talairach.xfm is saved as part of the mgz volume. When we move the scan
from the batch account to the user account, this path is no longer
valid. We can fix this by using mri_add_xform_to_header, as per
msg02241 on the mailing list (Doug Greve, 27 Jan 2006). 
  
What we are wondering is if the mgz header has any other path-dependant
information that we would need to update in the scenario such as above,
where scan workup and group analysis processing can take place over
multiple file locations? 
  
+glenn
  

___
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
[EMAIL PROTECTED]
Phone Number: 617-724-2358 
Fax: 617-726-7422

In order to help us help you, please follow the steps in:
surfer.nmr.mgh.harvard.edu/fswiki/BugReporting




___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

[Freesurfer] troubles with monkey brains (inflate)

2006-02-22 Thread Sebastian Moeller

Dear all,

at the moment I am struggling with flattening monkey anatomical scans. 
Specifically I manually got to the point where I get a wm.mgz and now I 
want to inflate it. My instructions refer to using csurf, which does 
not like my mgz volumes and is deprecated IIRC, the alternative is 
hooking my data into the recon-all pipe-line. But that fails as I do 
not have any aseg.mgz (does the segmentation work for monkeys?). So any 
advice on how to proceed with the processing?


Ahoi  Thanks
Sebastian
--
Sebastian Moeller

Tel.: 04 21 - 2 18 - 78 38 oder 96 91
Fax.: 04 21 - 2 18 - 90 04
GSM:  01 62 - 3 25 45 59
[EMAIL PROTECTED]

AG Kreiter / FB 2
Institut fuer Hirnforschung III
Abteilung Theoretische Neurobiologie
Universitaet Bremen
Biogarten
Hochschulring 16a
Postfach 33 04 40
28359 Bremen


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


Re: [Freesurfer] troubles with monkey brains (inflate)

2006-02-22 Thread Nick Schmansky
In the freesurfer dev releases post 2006-18-01, there is a -noaseg flag
in recon-all.  It will skip the auto-segmentation step, and not include
aseg.mgz in any subsequent processing (eg. wm seg and filling).  The
flag is intended for usage with baby brains and non-human primates, as
these brains cannot be auto-segmented with the default atlas (which is
based on 40 adult normals).


On Wed, 2006-02-22 at 18:19 +0100, Sebastian Moeller wrote:
 Dear all,
 
 at the moment I am struggling with flattening monkey anatomical scans. 
 Specifically I manually got to the point where I get a wm.mgz and now I 
 want to inflate it. My instructions refer to using csurf, which does 
 not like my mgz volumes and is deprecated IIRC, the alternative is 
 hooking my data into the recon-all pipe-line. But that fails as I do 
 not have any aseg.mgz (does the segmentation work for monkeys?). So any 
 advice on how to proceed with the processing?
 
 Ahoi  Thanks
   Sebastian

___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


Re: [Freesurfer] troubles with monkey brains (inflate)

2006-02-22 Thread Sebastian Moeller

Hi Nick, hi All,

On 22. Feb 2006, at 19:39 Uhr, Nick Schmansky wrote:


In the freesurfer dev releases post 2006-18-01, there is a -noaseg flag
in recon-all.  It will skip the auto-segmentation step, and not include
aseg.mgz in any subsequent processing (eg. wm seg and filling).  The
flag is intended for usage with baby brains and non-human primates, as
these brains cannot be auto-segmented with the default atlas (which is
based on 40 adult normals).
	I still run the dev20051003 version, is everything else compatible? 
Anyway I used the -nofill directive for recon-all autorecon2-wm, after 
running mri_fill manually, supplying the required cc and pons 
coordinates, but specifying -noaseg sure beats my do it by hand 
approach, by far. Thanks for the impressive automatization work.


Ahoi  Thanks
Sebastian




On Wed, 2006-02-22 at 18:19 +0100, Sebastian Moeller wrote:

Dear all,

at the moment I am struggling with flattening monkey anatomical scans.
Specifically I manually got to the point where I get a wm.mgz and now 
I

want to inflate it. My instructions refer to using csurf, which does
not like my mgz volumes and is deprecated IIRC, the alternative is
hooking my data into the recon-all pipe-line. But that fails as I do
not have any aseg.mgz (does the segmentation work for monkeys?). So 
any

advice on how to proceed with the processing?

Ahoi  Thanks
Sebastian





--
Sebastian Moeller

Tel.: 04 21 - 2 18 - 78 38 oder 96 91
Fax.: 04 21 - 2 18 - 90 04
GSM:  01 62 - 3 25 45 59
[EMAIL PROTECTED]

AG Kreiter / FB 2
Institut fuer Hirnforschung III
Abteilung Theoretische Neurobiologie
Universitaet Bremen
Biogarten
Hochschulring 16a
Postfach 33 04 40
28359 Bremen


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


Re: [Freesurfer] troubles with monkey brains (inflate)

2006-02-22 Thread Nick Schmansky
Sebastian,

I've attached a gzipped recon-all that has the -noseg flag.  Do not copy
over the recon-all in your 2005-10-03 release, as it's not fully
compatible with that.  Rather, I suggest opening the new recon-all in a
text editor, and look for instances of the variable 'UseAseg', and the -
noaseg flag, and I think you can modify your existing recon-all to do
the same.  There is no magic involved, the -noaseg flag just does what
you were probably doing manually.  Your 2005-10-03 release should work
with the changes.

Nick 

On Wed, 2006-02-22 at 20:02 +0100, Sebastian Moeller wrote:
 Hi Nick, hi All,
 
 On 22. Feb 2006, at 19:39 Uhr, Nick Schmansky wrote:
 
  In the freesurfer dev releases post 2006-18-01, there is a -noaseg flag
  in recon-all.  It will skip the auto-segmentation step, and not include
  aseg.mgz in any subsequent processing (eg. wm seg and filling).  The
  flag is intended for usage with baby brains and non-human primates, as
  these brains cannot be auto-segmented with the default atlas (which is
  based on 40 adult normals).
   I still run the dev20051003 version, is everything else compatible? 
 Anyway I used the -nofill directive for recon-all autorecon2-wm, after 
 running mri_fill manually, supplying the required cc and pons 
 coordinates, but specifying -noaseg sure beats my do it by hand 
 approach, by far. Thanks for the impressive automatization work.
 
 Ahoi  Thanks
   Sebastian
 
 
 
  On Wed, 2006-02-22 at 18:19 +0100, Sebastian Moeller wrote:
  Dear all,
 
  at the moment I am struggling with flattening monkey anatomical scans.
  Specifically I manually got to the point where I get a wm.mgz and now 
  I
  want to inflate it. My instructions refer to using csurf, which does
  not like my mgz volumes and is deprecated IIRC, the alternative is
  hooking my data into the recon-all pipe-line. But that fails as I do
  not have any aseg.mgz (does the segmentation work for monkeys?). So 
  any
  advice on how to proceed with the processing?
 
  Ahoi  Thanks
 Sebastian
 
 
 


recon-all.gz
Description: GNU Zip compressed data
___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer