#Script to create group of volumes from Toshiba image
# This script needs to be run once the images have been opened as Raw Generic 
# and the entire set of slices is being viewed as one single volume on screen
#
# Running the script will pop up a widget asking for number of frames, number\
# of slices per frame and the voxel dimensions of the image
#
# The script then proceeds to extract the slices from the image being viewed
# and creates a group of volumes on a page called Volume_Group
# 
#
# Script wirtten by Raj Jagannathan - March 2, 2001
#
#

InputFromWidget "Image Parameters" 5 "No. of Frames" num_vols 3 "No.of slices per frame" num_slices_vol 3 "X voxel dimension" x 8 "Y voxel dimension" y 8 "Z voxel dimension" z 8

MxGetCurrentVolume Volume
MxGetAllSlicesFromVolume $Volume Slices

set vol_grp {}

set num_slices [expr $num_vols*$num_slices_vol]

for {set i 0} {$i < $num_vols} { incr i} {

	set vol {}
	
	for {set j $i} {$j < $num_slices} {incr j $num_vols} {
		lappend vol [lindex $Slices $j]
	}
	
	MxComposeVolume $vol Volume
	MxSetScale $Volume $x $y $z
	lappend vol_grp $Volume	
}

MxGroupVolumes $vol_grp Volume_Group Grp



