var scriptPath = VQ.getScriptPath().replace(/[/\\][^/\\]+$/, "");
var outputPath = "";
//---------------------------------------------------------
// Start - Only for internal testing (users can disregard or remove)
//---------------------------------------------------------
var isTestModule = scriptPath.indexOf("extern/t/TestModules") !== -1;
VQ.setTestMode(isTestModule);
function getArtifactOutputFolder() {
const cachePath = VQ.getCache();
return cachePath.substring(0, cachePath.lastIndexOf("/") + 1) + "artifacts";
}
if(VQ.isTestMode()){
outputPath = getArtifactOutputFolder();
}
//---------------------------------------------------------
// End - Only for internal testing (users can disregard or remove)
//---------------------------------------------------------
VQ.setConfig('Data/resampleROI',1,true);
VQ.setConfig('DICOM/useFOR', 1, true);
VQ.setConfig('Data/orientation', "Neurologist (LR)", true);
VQ.setConfig('Data/dynamicSupportEnabled', true, true);
VQ.setConfig('Data/disableMIPViewer', true, true);
//----------------------------------------------
var dm = VQ.dataManager();
var mw = VQ.mainWin();
var CTTestData = scriptPath + "/data/CTSynthetic.dcm";
dm.openDat(0, [CTTestData]);
VQ.debug("LOADED:"+dm.getSOPUID(0));
test_switch_labels(false);
if(outputPath == ""){
outputPath = scriptPath;
}
neighborhoodSegmentation();
test_save_slices(getTestName());
if(VQ.isTestMode()){
VQ.quit();
}
function neighborhoodSegmentation() {
VQ.mainWin().setViewMode("Slice View", "3D ROI Tool");
VQ.mainWin().normalSize();
VQ.getWidget("tabWidget").setCurrentIndex(3);
var op = VQ.currentOp();
VQ.getWidget('cbCropRange').setChecked(false);
op.addROI("ROI 1", "red");
// Applying Neighborhood Thresholding
VQ.getWidget("MagicSegmentationSelector").setCurrentIndex(2);
op.setInputROI(0);
op.setCurrentROI(1);
VQ.getWidget("MagicThresholdMin").setText("1");
VQ.getWidget("MagicThresholdMax").setText("100");
VQ.getWidget("MagicPreview").setChecked(true);
test_save_slices(getTestName() + "-preview");
VQ.getWidget("MagicPreview").setChecked(false);
VQ.getWidget("MagicApply").click();
}
function getTestName() {
var scriptFilename = VQ.getScriptPath();
return scriptFilename.substring(scriptFilename.lastIndexOf("/")+1, scriptFilename.lastIndexOf("."));
}
function test_save_slices(base) {
test_save_image("test-" + base + "-sag.png", 1);
test_save_image("test-" + base + "-cor.png", 2);
test_save_image("test-" + base + "-tra.png", 3);
}
function test_save_image(filename, direction) {
VQ.mainWin().saveImage(outputPath + "/" + filename, direction);
}
function test_switch_labels(b) {
VQ.mainWin().switchCornerInfo(b);
VQ.mainWin().switchCrosshair(b);
VQ.mainWin().switchPosLabels(b);
VQ.mainWin().switchShowActive(b);
}