// Dave Barry, Francis Crick Institute // 2018.08.14 // david.barry@crick.ac.uk // Generates "preview" images of stacks in a directory macro "Huygens Browser"{ input = getDirectory("Choose Input Directory"); list = getFileList(input); Dialog.create("Huygens Browser"); Dialog.addNumber("Number of channels:", 3); Dialog.addNumber("Display constrast saturation (0.0 - 1.0):", 0.35); Dialog.addString("File extension:", ".tif"); Dialog.show(); channels = Dialog.getNumber(); saturation = Dialog.getNumber(); extension = Dialog.getString(); for (i = 0; i < list.length; i++){ if(endsWith(toLowerCase(list[i]), toLowerCase(extension))){ makePreview(input, list[i], channels); waitForUser("Huygens Browser", "Press OK to open next image."); } } print("Done"); function makePreview(input, filename, channels) { fullFilename = input + filename; print (fullFilename); run("Bio-Formats Importer", "open=fullFilename color_mode=Custom rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT"); slices = nSlices() / channels; run("Stack to Hyperstack...", "order=xyzct channels=" + channels + " slices=" + slices + " frames=1 display=Composite"); Stack.setSlice(slices / 2); for(c = 1; c <= channels; c++){ Stack.setChannel(c); run("Enhance Contrast", "saturated=" + saturation); } } }