// Filename Randomizer // // This macro makes .tif copies of images inside a chosen folder // renaming them with a 'pseudo-mock' random number. // While running, the macro matches the assigned random filename // to the original image title in a printed table. It also saves this // information in the image header ('Show Info...' command); // // Use it for unbias/blind analyses that may be sensitive to user // interpretation, or to randomize the sequence in which images // of a folder are analyzed. // // It does not process subfolders. // // Tiago Ferreira - ferreira at embl dot it // 04.2009 var extensions=newArray(".tif",".tiff",".stk",".jpeg",".jpg",".png",".zip",".lif",".gif"); var myDir,currentFldr, tbl; macro " Filename Randomizer [F6]" { requires("1.42j"); setBatchMode(true); settings(extensions); chosenDir=getDirectory("Choose a Directory "); start = getTime(); makeNewDir(chosenDir); makeTable(); processFiles(chosenDir); stop = getTime(); showStatus("Finished... ("+((stop-start)/1000)+" seconds)"); beep; setBatchMode(false); } // functions function settings(extlist) { msg1="Choose extension of images to obfuscate\n"+ "below. The chosen images will then be copied\nto a '*_randomized'"+ " folder.\n \nRetrieve original names at any time by using\n"+ "the 'Show Info...' command.\n \nYou will next be prompted to choose the images\nfolder. "+ "Subfolders will not be processed."; Array.sort(extlist); lgth=extlist.length; gridSide=sqrt(lgth); rows=round(gridSide)-1; cols=round(gridSide)+2; defaults = newArray(lgth); defaults= Array.fill(defaults, 1); Dialog.create('Settings'); Dialog.addMessage(msg1); Dialog.addCheckboxGroup(rows,cols, extlist, defaults); Dialog.show(); count=0; chosenExt=newArray(lgth); for (i=0; i< lgth; i++) { chosenExt[i]=Dialog.getCheckbox(); if(chosenExt[i]==1) count++; } finalExt=newArray(count); h=0; for (i=0; i