Dear all,
Playing around with some images that has 1, or more, slice(s) and with the Automatic Threshold we (@oburri and I) are a bit puzzled…
Briefly:
- on a 1 slice image
- when a ROI is present
the Threshold plugin COULD give a different value if the option “Stack Histogram” is selected.
Please, find below a example code and the log we got with it.
Furthermore, this issue occurs when scripting (ijm and java tested so far) and not when using the Threshold GUI (this why you would have to refresh manually the stack option of Threshold in the macro code below).
Thank you for your inputs about it,
Cheers,
Romain
// clean environment
run("Close All");
print("\\Clear");
// change to 0 to test on a stack
testSingleSlice = 1;
// defien a Threshold algo
threshold = "Default";
// open an image
if (testSingleSlice){ // to test on 1 z image
run("Fluorescent Cells (400K)");
print("Running on a 1 slice image ");
}else{// to test on multi-z image
run("Confocal Series (2.2MB)");
print("Running on a multi-slice image ");
}
run("Threshold...");
title = getTitle();
run("Split Channels");
selectWindow("C1-"+title);
run("Select All");
setAutoThreshold(threshold+" dark");
//waitForUser("");
getThreshold(lowerC1, upperC1);
print("C1 : Threshold value , stack not selected : "+ lowerC1);
setAutoThreshold(threshold+" dark stack");
//waitForUser("");
getThreshold(lowerC1Stack, upperC1Stack);
print("C1 : Threshold value , stack selected : "+ lowerC1Stack);
selectWindow("C2-"+title);
run("Select All");
setAutoThreshold(threshold+" dark");
//waitForUser("");
getThreshold(lowerC2, upperC2);
print("C2 : Threshold value , stack not selected :"+ lowerC2);
setAutoThreshold(threshold+" dark stack");
//waitForUser("");
getThreshold(lowerC2Stack, upperC2Stack);
print("C2 : Threshold value , stack selected : "+ lowerC2Stack);
// with a ROI
print ("with a ROI");
selectWindow("C1-"+title);
makeRectangle(128, 128, 175, 175);
setAutoThreshold(threshold+" dark");
//waitForUser("");
getThreshold(lowerC1, upperC1);
print("C1 : Threshold value , stack not selected : "+ lowerC1);
setAutoThreshold(threshold+" dark stack");
//waitForUser("");
getThreshold(lowerC1Stack, upperC1Stack);
print("C1 : Threshold value , stack selected : "+ lowerC1Stack);
selectWindow("C2-"+title);
makeRectangle(128, 128, 175, 175);
setAutoThreshold(threshold+" dark");
//waitForUser("");
getThreshold(lowerC2, upperC2);
print("C2 : Threshold value , stack not selected :"+ lowerC2);
setAutoThreshold(threshold+" dark stack");
//waitForUser("");
getThreshold(lowerC2Stack, upperC2Stack);
print("C2 : Threshold value , stack selected : "+ lowerC2Stack);
waitForUser(" Refresh 'Stack Histogram' option please ");
getThreshold(lowerC2StackHuman, upperC2Stack);
print("C2 : Threshold value , stack selected by hoooman : "+ lowerC2StackHuman);
here is the log :
Running on a 1 slice image
C1 : Threshold value , stack not selected : 79
C1 : Threshold value , stack selected : 79
C2 : Threshold value , stack not selected :71
C2 : Threshold value , stack selected : 71
with a ROI
C1 : Threshold value , stack not selected : 92
C1 : Threshold value , stack selected : 92
C2 : Threshold value , stack not selected :94
C2 : Threshold value , stack selected : 87
C2 : Threshold value , stack selected by hoooman : 94