Automates the drawing of an ROI using thresholding and smoothing algorithms.
var mainWin = VQ.mainWin();
var smoothed = false;
// smoothImage(0.5);
ccThreshold("Tumor");
erodeDilate(-2);
erodeDilate(+2);
lowPassSmoothing(20);
// can be automated in VQ 1.22alpha34 or higher:
if (smoothed) {
VQ.showMessage("Please reload original data to undo smoothing");
}
function smoothImage(fwhm) {
VQ.debug("Smoothing the Image");
VQ.mainWin().setViewMode("Slice View", "Filtering");
VQ.getWidget("cbSelect").setCurrentIndex(1);
VQ.getWidget("SmoothingFWHM").setValue(fwhm);
VQ.getWidget("buttonBox").accepted();
smoothed = true;
}
function ccThreshold(roiName) {
VQ.debug("Confidence Connected Thresholding: "+roiName);
VQ.mainWin().setViewMode("Slice View", "3D ROI Tool");
VQ.currentOp().addROI(roiName, "red");
VQ.getWidget("MagicSegmentationSelector").setCurrentIndex(4);
VQ.currentOp().setInputROI(0);
VQ.currentOp().setCurrentROI(1);
VQ.getWidget("MagicApply").click();
}
function erodeDilate(val) {
VQ.debug("Erode/Dilate "+val);
// VQ.mainWin().setViewMode("Slice View", "3D ROI Tool");
var idx = -val + 4;
if (val > 0) idx++;
VQ.debug("val="+val+", idx="+idx);
VQ.getWidget("cbMagicEDRadius").setCurrentIndex(idx);
VQ.getWidget("cbErodeMapTo").setChecked(false);
VQ.getWidget("buttonMagicErode").click();
}
function lowPassSmoothing(rad) {
VQ.debug("lowPassSmoothing "+rad);
// VQ.mainWin().setViewMode("Slice View", "3D ROI Tool");
VQ.getWidget("MagicSegmentationSelector").setCurrentIndex(7);
// VQ.getWidget("qt_spinbox_lineedit").setValue(rad);
VQ.getWidget("MagicApply").click();
}