/* * BlindAnalysis.ijm * This macro will take a directory of TIFFs * strip the label from them * save each with a randomised filename * log the association between original file and blind analysis file * Adapted from: * Shuffler macro by Christophe Leterrier v1.0 26/06/08 */ macro "Blind Analysis" { DIR_PATH=getDirectory("Select a directory"); print("\\Clear"); print("DIR_PATH :"+DIR_PATH); // Get all file names ALL_NAMES=getFileList(DIR_PATH); // Create the output folder OUTPUT_DIR=DIR_PATH+"BLIND"+File.separator; File.makeDirectory(OUTPUT_DIR); // How many TIFFs do we have? Directory could contain other directories. for (i=0; i0) { IM_NUMBER=IM_NUMBER+1; } } IM_NAMES=newArray(IM_NUMBER); IM_EXT=newArray(IM_NUMBER); // Test all files for extension j=0; for (i=0; i0) { IM_NAMES[j]=ALL_NAMES[i]; j=j+1; } } // Generate a permutation array of length IM_NUMBER IM_PERM=newArray(IM_NUMBER); for(j=0; j 1 || ff > 1) { stripFrameByFrame(cc,ss,ff); } else { setMetadata("Label", ""); // strips the label data from the image for blinding purposes } save(OUTPUT_PATH_PERM); print(f,IM_NAMES[j]+"\t"+IM_PERM_NAMES[j]); close(); } setBatchMode("exit and display"); showStatus("finished"); } function stripFrameByFrame(cc,ss,ff) { if(Stack.isHyperstack) { for(i = 0; i < ss; i++){ Stack.setSlice(i+1); for(j = 0; j < ff; j++) { Stack.setFrame(j+1); for(k = 0; k < cc; k++) { Stack.setChannel(k+1); setMetadata("Label", ""); } } } } else if(cc > 1 && ss == 1 && ff == 1) { setMetadata("Label", ""); } else if(cc == 1 && ss > 1) { for(i = 0; i < ss; i++){ setSlice(i+1); setMetadata("Label", ""); } } else if(cc == 1 && ff > 1) { for(i = 0; i < ff; i++){ setSlice(i+1); setMetadata("Label", ""); } } }