// MANTIS Auto-extract Macro // Automatically imports, names, and saves condensed image data from MANTIS into the parent directory for subsequent processing. // As of now, this only works on single FOV images organized into their respective folders. Each image will be saved as its own file renamed according to the FOV image folders name and appended with a suffix denoting the channel or detector rom which the image came. // Start by navigating to the parent directory of your experiments are stored when prompted and let the macro run. // Written by Wilson R Adams, 23 July 2020 // ====================================================== // Get file directory from user input dir = getDirectory("Navigate to the folder to be processed"); print("STARTING file extraction: "+dir); filelist = getFileList(dir); Array.show(filelist); // Loop through each folder in the parent directory //for (i = 0; i < 1; i++) { // for debugging one folder at a time for (i = 0; i < filelist.length; i++) { // only open folders, not files in the parent direcory if (endsWith(filelist[i], "/")) { // List image files in sub folder sublist = getFileList(filelist[i]); firsttif = dir+filelist[i]+"ChanA_0001_0001_0001_0001.tif"; // If folder has images in it, if (File.exists(firsttif)) { // Import image using Bioformats to preserve metadata. // Uses virtual stacks for speed and RAM, especially on server run("Bio-Formats Importer", "open=[&firsttif] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT use_virtual_stack"); // Rename all of the files once imported (assumes MANTIS) runMacro("MANTIS_imgrename_ext.ijm"); // Save in parent directory and close all of the images wins = getList("image.titles"); for (j = 0; j < wins.length; j++) { selectWindow(wins[j]); save(dir+wins[j]+".tif"); close(); } // Print progress once images are extracted print(filelist[i]+" COMPLETE"); } // end of 'file exist' if stmt } // end of title folder if statment } // end of image folder for loop print("FINISHED file extraction: "+dir);