After selecting a seed point, this script uses the 3D ROI Spline Tool for skill stripping a brain data set slice-by-slice.
/**
* Script for skull stripping a brain data set slice-by-slice using
* the 3D ROI Spline Tool in VivoQuant. User only has to select a
* seed point and QA the results at the end.
*
* Author: Gabriel Tobon <tobon@invicro.com>
*/
// GLOBAL VARIABLES
var DM = VQ.dataManager();
var MW = VQ.mainWin();
var VC = VQ.controler();
function main()
{
MW.setViewMode("Slice View", "3D ROI Tool");
var roiOp = VQ.currentOp();
// Delete all current ROIs and create a "Brain ROI"
var ids = [];
var numROIs = roiOp.numROIs();
for (var i=1; i < numROIs; ++i) ids.push(i);
if (ids.length > 0)
{
roiOp.deleteROIs(ids, 0);
}
roiOp.addROI("Brain", "red");
roiOp.setCurrentROI(1);
// Activate spline mode
VQ.getWidget("tabWidget").setCurrentIndex(2);
roiOp.setModeSplineIsocount();
VC.setPos(2, 0);
// Ask for seed point
VQ.suspend("Please select a seed point and threshold");
// Iterate through slices, computing percentile threshold
// and applying that threshold to generate the mask
for (var z=0; z < DM.getDimZ(); ++z)
{
roiOp.acceptedSplineNext();
}
// Display Message
VQ.showMessage("VivoScript complete! Please QA and adjust the brain mask as needed");
}
main();