// 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++) { if (endsWith(filelist[i], "/")) { // only open folders, not files in the parent direcory sublist = getFileList(filelist[i]); // List image files in sub folder firsttif = dir+filelist[i]+"ChanA_0001_0001_0001_0001.tif"; // Import image using Bioformats to preserve metadata. virtual stacks for speed. run("Bio-Formats Importer", "open=[&firsttif] color_mode=Default rois_import=[ROI manager] split_channels view=Hyperstack stack_order=XYCZT use_virtual_stack"); // Rename all of the files once imported runMacro("MANTIS_imgrename_ext.ijm"); // Save 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 print(filelist[i]+" COMPLETE"); } print("FINISHED file extraction: "+dir); }