/* This imageJ macro creates a compact montage from the image stack created by the RoiManager.multiCrop command introduced in 1.53d. It expects each slide to have an overlay from which the selections can be generated. v230726: 1st version. Peter J. Lee, Applied Superconductivity Center, National High Magnetic Field Laboratory, Florida State University. */ macroL = "ROI-Crop-Stack-Cleanup_v230727.ijm"; getDimensions(width, height, channels, slices, frames); nOverlays = Overlay.size; if (slices<2) exit("Sorry, this macro needs a stack"); else if (nOverlays==0) exit("Sorry, this macro expects overlays generated by the RoiManager.multiCrop command"); else if (nOverlays!=slices){ if(!getBoolean("There are " + slices + " slices and " + nOverlays + "\(the number should be the same\); continue?")) exit(); } Dialog.create ("ROI save options \(" +macroL+ "\)"); stackOptions = newArray("Hide overlays in stack","Unselect selections from stack","Add selections to ROI Manager","White background"); Dialog.addCheckboxGroup(2,2,stackOptions, newArray(true,true,true,true)); Dialog.show(); hideOverlays = Dialog.getCheckbox(); remSelections = Dialog.getCheckbox(); roiManagerAdd = Dialog.getCheckbox(); whiteBG = Dialog.getCheckbox(); oTitle = replace(getTitle,".tif",""); /* Assumes that if saved as a stack this will be a tif file */ oROICropStackID = getImageID(); if (whiteBG) oForegroundColor = Color.foreground; for (i=0; i