Skip to content

Instantly share code, notes, and snippets.

@romainGuiet
Created June 17, 2025 11:18
Show Gist options
  • Select an option

  • Save romainGuiet/837eb46109418aa922af328135e226ab to your computer and use it in GitHub Desktop.

Select an option

Save romainGuiet/837eb46109418aa922af328135e226ab to your computer and use it in GitHub Desktop.
show that different thresholds can output similar results
// clear the environment
run("Close All");
roiManager("Reset");
//open an image
run("Fly Brain (1MB)");
// make it composite, duplicate one slice and get information
run("Make Composite");
run("Duplicate...", "duplicate channels=1 slices=27");
getDimensions(width, height, channels, slices, frames);
// here we run the Auto_Threshold
run("Auto Threshold", "method=[Try all] white");
getDimensions(output_Width, output_Height, output_channels, output_slices,output_frames);
// I will highlith the categories with some ROIs of different colors
xSize = 258;
ySize = 274;
// so I define the categories and their colors
//arrayCatNbr = newArray(1,2,3,1, 2,1,1,3 ,1,2,1,2 ,1,2,2,1);
//Mod from 2018/06/12 to account for new auto threshold method
arrayCatNbr = newArray(1,2,2,1, 1,2,1,2,2,3,1,1,2,1,3,2,1);
arrayRoiColor = newArray("50FFFF00", "5000FF00", "50FF00FF");
// adding ROIs
i = 0;
for (y = 0 ; y < output_Height ; y+=ySize){
for (x = 0 ; x < output_Width ; x+=xSize){
if(i<lengthOf(arrayCatNbr)) {
makeRectangle(x, y, xSize, ySize);
Roi.setName("Cat-"+arrayCatNbr[i]);
Roi.setFillColor(arrayRoiColor[arrayCatNbr[i]-1]);
roiManager("Add");
i++;
}
}
}
// Sort the ROi and Tile the images
roiManager("Sort");
run("Tile");
selectImage("Montage")
roiManager("Show All");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment