// Paired down ND file processer for faster data exctraction. // This macro is an iteration of Bologna_AstroCaProcess_v3.ijm macro meant to be applied to // nd2 files thrown from the STORM microscope in the Nikon Imaging core at Vanderbilt. // Turns out it's REALLY REALLY SLOW for big image files. took almost 10min to process one video. // I'm making a new slimmer version to cut down on the processing time and speed things up. path = File.openDialog("Select .nd2 Image File") par = File.getParent(path) //filename = File.getName(path) filename = File.nameWithoutExtension() print(path) print(filename) Dialog.create("Experiment Info"); Dialog.addMessage("Input Image Info?"); Dialog.addNumber("Number of Images = ", 301) Dialog.addString("File Header = ", filename) Dialog.show() ; stack = Dialog.getNumber(); header = Dialog.getString() //stack = 200 // How many images in each file stack run("Bio-Formats", "open=[&path]"); //run("Green Fire Blue"); rename(header) orig = getTitle() // Original imagge stack variable File.makeDirectory(par+"\\processed") // Make processed images directory in parent directory File.makeDirectory(par+"\\processed\\!Final\\") // !Final directory in 'processed' directory for final corrected stacks + time plots File.makeDirectory(par+"\\processed\\"+orig+"\\") // subfolder for each trial in the 'processed' folder for originals, IPs, masks, ROI lists, FFC factors, etc processed_dir = par+"\\processed\\" final_dir = par+"\\processed\\!Final\\" pro_head_dir = par+"\\processed\\"+header+"\\" getRawStatistics(mean) mean1 = mean t = nSlices() run("Z Project...", "projection=[Max Intensity]"); run("Cyan Hot"); rename(orig+"_MaxIP") MaxIP = getTitle() getRawStatistics(mean) mean2 = mean selectWindow(orig) run("Z Project...", "projection=[Median]"); MedIP = getTitle() selectWindow(orig) run("Z Project...", "projection=[Standard Deviation]"); run("!Orangeish") stdIP = getTitle() run("Calculator Plus", "i1=&MaxIP i2=&MedIP operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=0 create"); rename(MaxIP+"_bkgdsub") FFC = getTitle() //run("Subtract Background...", "rolling=250"); // just subtract background, no mask generation //run("Calculator Plus", "i1=&SIP i2=&FFC operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=&mean2 create"); //rename(SIP+"_corr") //selectWindow(FFC) //run("Duplicate...", " "); //rename(FFC+"_stack") //FFC_stack = getTitle() //run("Divide...", "value=&t"); //run("Calculator Plus", "i1=&orig i2=&FFC_stack operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=&mean1 create"); //rename(orig+"_final") //corr = getTitle() //close(FFC) //close(FFC_stack) selectWindow(MaxIP) save(pro_head_dir+MaxIP+".tif") selectWindow(MedIP) save(pro_head_dir+MedIP+".tif") selectWindow(FFC) save(pro_head_dir+FFC+".tif") selectWindow(stdIP) save(pro_head_dir+stdIP+".tif") close(MaxIP) close(MedIP) //close(SIP) //selectWindow(SIP+"_corr") //SIPcorr = getTitle() //selectWindow(corr) //save(final_dir+corr+".tif") //selectWindow(corr) //run("Z Project...", "start=10 projection=[Median]"); // Start from image 10 to get rid of photobleaching artifact. //run("Green Fire Blue"); //rename(orig+"_MedIP") //MedIP = getTitle() //save(pro_head_dir+MedIP+".tif") selectWindow(FFC) run("Enhance Contrast", "saturated=0.35"); roiManager("reset"); roiManager("show all with labels") setTool("ellipse"); run("Tile"); string = "Use the Elipse tool to make your own ROIs. Press 'Ctrl+T' to add each ROI to the ROI list. Click 'OK' when all ROIs are measured" waitForUser(string) // Wait for user input once ROIs are selected setTool("oval"); string = "Add a background ROI with the oval tool, then press 'OK'" waitForUser(string) //roiManager("Add") roiManager("save", pro_head_dir+orig+"_ROImanual.zip") // ROIs will be outputted in a fashion where each collumn is a cell/ROI, and the last collumn is a Background // Measure ROIs and save output data selectWindow(orig) roiManager("show all with labels") run("Set Measurements...", "mean redirect=None decimal=6"); roiManager("multi measure one") run("Input/Output...", "jpeg=85 gif=-1 file=.csv use_file"); saveAs("Results", final_dir+header+"_data"); //close(MedIP) selectWindow(orig) //save(pro_head_dir+header+".tif") //Files too large, take up too much room. Downsample //close() //close(SIPcorr) close("Results") roiManager("open", pro_head_dir+orig+"_ROImanual.zip") roiManager("show all with labels") //selectWindow(corr) //run("Plot Z-axis Profile"); //close(SIP) // Downsample for easy transport and revaluating. Comment out if necessary. // Set parameters: width, heigh, depth w = 800 h = 798 d = 300 run("Size...", "width=&w height=&h depth=&d constrain average interpolation=Bilinear"); run("Green"); ds = getTitle() save(pro_head_dir+orig+"_ds.tif") print("Saved: "+pro_head_dir+orig+"_ds.tif") close() print(orig+" FINISHED")