VivoQuant 5.4.1
Loading...
Searching...
No Matches
SelectSlicesMovie.vqs

This is an example of how to save a fly-through movie.

/**
* This script can be used to save a fly-through movie of the currently
* loaded data set with user specified start and end slices.
*/
function saveCustomMovie(plane, outfile) {
// If no output file is given, ask for one
if (outfile === undefined) {
outfile = VQ.getSavePath("Select output file:", ".", "Movie files (*.gif *.mpeg *.mpg)\nAll files (*)");
}
// Get base name of file
var ind = outfile.lastIndexOf(".");
var basename = outfile.substr(0, ind);
VQ.debug(basename);
// Ask for start and end slices
var planeType = "Sagittal";
if (plane == 1) {
planeType = "Coronal";
} else if (plane == 2) {
planeType = "Transverse";
}
var VC = VQ.controler();
VQ.suspend("Select start slice in " + planeType + " plane.");
var start = VC.getPos(plane);
VQ.suspend("Select end slice in " + planeType + " plane.");
var end = VC.getPos(plane);
VQ.debug("Generating movie of " + planeType + " from slice " + start + " to " + end + " in file: " + outfile);
// Save individual frames
var MW = VQ.mainWin();
var incr = 1;
if (start > end) {
incr = -1;
}
var imageList = [];
for (var i=start; i !== end+incr; i += incr) {
var tmpFileName = basename + i + ".png";
imageList.push(tmpFileName);
VC.setPos(plane, i);
MW.saveImage(tmpFileName, plane+1);
}
// Combine frames and clean up
// syntax is VQ.combineFrames(<Array of Images>, <Output path>,
// <delay in ms>, <delete frames?>)
// delay defaults to 40, delete defaults to false
var delay = 30;
if (start-end > 25 || end-start > 25) {
delay = 8;
}
VQ.combineFrames(imageList, outfile, delay, true);
}
// Save Movie of Transverse/Z-dimension plane
// 0: Sagittal, 1: Coronal, 2: Transverse
saveCustomMovie(2);