// Makro pro spuštění tréninku klasifikátoru Weka.
// Viz https://imagej.net/Trainable_Weka_Segmentation#Complete_macro_example:
// Uživatel vybere soubor, pravděpodobně s příponou TIF.
path = File.openDialog("Select a TIF File");
delay = 1000;
twsWindowName = "Trainable Weka Segmentation v3.2.34";
// Pokud nechcete pomocné texty, nastavte "false":
showMessages = true;
open(path);
// Spustíme TWS.
run("Trainable Weka Segmentation");
// Lepší je počkat.
wait(delay);
selectWindow(twsWindowName);
// Připravné operace.
call("trainableSegmentation.Weka_Segmentation.setFeature", "Hessian=false");
call("trainableSegmentation.Weka_Segmentation.setMembranePatchSize", "16");
call("trainableSegmentation.Weka_Segmentation.setMaximumSigma", "8.0");
// Přejmenování a přidání tříd.
call("trainableSegmentation.Weka_Segmentation.changeClassName", "0", "background");
call("trainableSegmentation.Weka_Segmentation.changeClassName", "1", "cell wall");
call("trainableSegmentation.Weka_Segmentation.createNewClass", "cell no phenolics");
call("trainableSegmentation.Weka_Segmentation.createNewClass", "cell with phenolics");
// Stanovení "oblasti zájmu" třídy - kde bude probíhat trénink pro danou třídu.
// Možná by se oblast zájmu mohla nastavit i pro ostatní třídy?
/*
makeRectangle(0, 0, 100, 100);
title = "Vyberte ROI pro cell wall";
msg = "Vyberte obdélník\nPro pokračování klepněte na 'OK'.";
waitForUser(title, msg);
// add one region of interest to each class
call("trainableSegmentation.Weka_Segmentation.addTrace", "1", "1");
*/
// BACKGROUND
run("Line Width...", "line=50");
setTool("freeline");
wait(delay);
if (showMessages) {
msg = "Vyberte vzorky pro trénink pozadí a přidávejte je tlačítkem Add to background.
"
+ "Šířku linky upravte poklepáním na Freehand lines.";
showMessage(msg);
}