/* 04.04.20, 22:10 Recover_Old_Tiffs_1d.txt https://sils.fnwi.uva.nl/bcb/objectj/examples/Coli-Inspector/utils/ */ /* Adds .tif extension to all file names in chosen folder except those with extensions defined by 'exclude': */ macro "Add .tif extension to old Tiffs"{ exclude = split("ojj,tif,tiff,jpg,txt,/,\\,obj", ",,"); showMessage("Click OK and choose directory"); dir = getDirectory("Choose Directory");; OldNames = getFileList(dir); len = OldNames.length; NewNames = newArray(len); for(jj = 0; jj < len; jj++){ path = dir + OldNames[jj]; doIt = true; name = toLowerCase(OldNames[jj]); for(kk = 0; kk < exclude.length; kk++) if(endsWith(name, exclude[kk])) doIt = false; if(doIt){ run("Raw...", "open=[" + path + "] image=8-bit width=50 height=1"); MM =getPixel(0, 0) == 77 && getPixel(1, 0) == 77; II =getPixel(0, 0) == 73 && getPixel(1, 0) == 73; doIt = (MM || II);//Intel or Motorola Tiff close; } NewNames[jj] = ""; if(doIt) NewNames[jj] = OldNames[jj] + ".tif"; } Array.show(OldNames, NewNames); waitForUser; showMessageWithCancel("Click OK to rename"); for(jj = 0; jj < len; jj++){ nameA = OldNames[jj]; nameB = NewNames[jj]; if(nameB != "") b=File.rename(dir+nameA, dir+nameB); } } /*Image Folder to one Hyperstack -------------------------------- - Converts all images in the chosen folder to one hyperstack (2-channels) - We expect alphabetic order where each PhC is followed by its associated FLuor image - Chosen folder should not contain subfolders - All images must have same dimensions - The resulting hyperstack cam optionally be inverted - (If you want to import manually, choose: File>Import>Image Sequence..., Image> Hyperstacks> Stack to Hyperstack ) */ macro "Image Folder to one Hyperstack"{ showMessage("Click OK, then choose directory"); run("Image Sequence...", ""); nFrames = nSlices / 2; //2 channels if(round(nFrames) != nFrames) exit("nFrames = " + nFrames); run("Stack to Hyperstack...", "order=xyczt(default) channels=2 slices=1 frames=&nFrames display=Grayscale"); Stack.setChannel(1); run("Grays"); Stack.setChannel(2); run("Green"); setSlice(1); showMessageWithCancel("Invert entire stack?"); run("Invert", "stack"); }