Dear Forum,
I've wrote a little macro wich helpes me exporting Images from an other software (ThorImage).
Basically the Macro asks me wich slices I want to export from an Image Sequence.
I want to implement three checkboxes.
1st Ckechbox asks if I want to export them as a stack
2nd Checkbox asks if I want to export as Image Sequence (this part I have still to develop)
3rd Checkbox asks if I want to close Imagej (Fiji) after the export (at this point the if funktion always says "true")
This is my first Code, which means I'm not so skilled in writing makros.
However, I think I'm doing something wrong with the "if-Funktion" in ImageJ Macro.
Would you point me in the right direktion?
this is my code so far:
}
showMessageWithCancel("Bitte warten...","Wenn der Bilderstapel aus ThorImage geladen wurde, klicken Sie auf OK.");
setMinAndMax(20.0000, 80.0000); //Contrast
Dialog.create("ThorImage Import");
Dialog.addMessage("Tragen Sie hier die Dimensionen ein.")
Dialog.addNumber("Erste Ebene:", 80);
// first slice
Dialog.addNumber("Letzte Ebene:", 110);
// last slice
Dialog.addNumber("X-FOV in mm:", 8.00); // Field of View Value from Data aqistion
Dialog.addCheckbox("Speichere als Tiff Bilderstapel", true);
// Checkbox 1, save as tiff stack
Dialog.addCheckbox("Speichere alle Einzelbilder", false); // Checkbox 2, save as Image Sequence (code is in progress)
Dialog.addCheckbox("Exit ImageJ after Export", true); // Checkbox 3
Dialog.show();
f = Dialog.getNumber(); // for slice keeper, first image
l = Dialog.getNumber(); // for slice keeper, last image
r = Dialog.getNumber(); // for calculation (line 16)
h = 1024 // hight in pixels
result = r*1024/3.52; //calculation of widht pixels
w = result; // for "Size" (line 24)
stack = Dialog.getCheckbox(); //Checkbox 1 ( Save as Stack)
single = Dialog.getCheckbox(); // Checkbox 2 (Image Sequence)
end = Dialog.getCheckbox(); // Checkbox 3 (exit)
run("Slice Keeper", "first=f last=l increment=1");
z = nSlices; // result of Slice keeper
run("Size...", "width=w height=h depth=z average interpolation=None");
run("8-bit"); // converting to 8 Bit to save diskspace
if (stack==true); {
//only save if Checkbox 1 is "true" (checked)
dir = getDirectory("Choose a Directory"); //destination of export
title = File.getName(dir); //grabs the last part of the Directory for the filename
saveAs("Tiff", dir+title);
}
// old line showMessageWithCancel("Export erfolgreich","Der Export war erfolgreich, mit einem Klick auf OK beenden Sie FiJi.");
if (end==true); {
run("Quit");
//showMessage("true"); it always displayes "true". Why?
Some parts of the Code is in german, but I tried to comment so ypu would understand what I try to do with the code :)
Thank you for your help.
Best
Tobias