Hello,
I am very new to ImageJ and writing macros. I've been slowly piecing together a macro to quantify apoptosis and it looks something like this: macro "full [1]" { run("RGB Split"); close(); close(); run("Select All"); run("Copy"); newImage("Counts", "8-bit Black", 1300, 1030, 1); run("Paste"); run("Subtract Background...", "rolling=5"); //run("Threshold..."); setThreshold(56,255); setOption("BlackBackground", false); run("Convert to Mask"); run("Watershed"); run("Analyze Particles...", "size=1-100 circularity=0.00-1.00 show=Nothing display clear"); } My questions for this macro are: 1) In the newImage line, I want the name to reflect the original image, e.g. I opened the image, image_1331.tif, and want the new image to reflect that automatically but also have it distinguished with "counts" or something. 2) If I wanted the macro to pause at the setThreshold step to allow me to set a different threshold (even a 1x step for a batch process), how would that go? I may not need to do this because I could use an image to determine a threshold for the entire set, then change the settings. 3) I am having the most difficulty getting the results to save automatically (as you can see by not even having any code here). I have tried several google searches and cannot get any of the suggestions to work. Ultimately, I would like it to save to the folder from which the images were opened, reflect the image name with a .xls or .csv extension, and be able to use it to batch process a large number of images. Any suggestions/help would be great! Thanks, JP -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi,
1) get the name of your image and then concatenate in newImage(): 2) you may use the "wait(n)", but I am not so sure. 3) getInfo("image.directory") and saveAs("Results", "Results.xls"); should do the job. macro "full [1]" { imgName=getTitle(); dir=getInfo("image.directory"); run("RGB Split"); close(); close(); run("Select All"); run("Copy"); newImage("Counts_"+imgName, "8-bit Black", 1300, 1030, 1); run("Paste"); run("Subtract Background...", "rolling=5"); //run("Threshold..."); setThreshold(56,255); setOption("BlackBackground", false); run("Convert to Mask"); run("Watershed"); run("Analyze Particles...", "size=1-100 circularity=0.00-1.00 show=Nothing display clear"); saveAs("Results", dir+"Results_"+imgName+".xls"); } you can also check the built in macro page of imagej website ( http://rsb.info.nih.gov/ij/developer/macro/functions.html) hope it helps, Jean-Philippe 2015-08-20 14:52 GMT-04:00 JP Dustin <[hidden email]>: > Hello, > > I am very new to ImageJ and writing macros. I've been slowly piecing > together a macro to quantify apoptosis and it looks something like this: > > macro "full [1]" { > run("RGB Split"); > close(); > close(); > run("Select All"); > run("Copy"); > newImage("Counts", "8-bit Black", 1300, 1030, 1); > run("Paste"); > run("Subtract Background...", "rolling=5"); > > > //run("Threshold..."); > setThreshold(56,255); > setOption("BlackBackground", false); > run("Convert to Mask"); > > run("Watershed"); > run("Analyze Particles...", "size=1-100 circularity=0.00-1.00 show=Nothing > display clear"); > > } > > My questions for this macro are: > > 1) In the newImage line, I want the name to reflect the original image, > e.g. I opened the image, image_1331.tif, and want the new image to reflect > that automatically but also have it distinguished with "counts" or > something. > > 2) If I wanted the macro to pause at the setThreshold step to allow me to > set a different threshold (even a 1x step for a batch process), how would > that go? I may not need to do this because I could use an image to > determine a threshold for the entire set, then change the settings. > > 3) I am having the most difficulty getting the results to save > automatically (as you can see by not even having any code here). I have > tried several google searches and cannot get any of the suggestions to > work. Ultimately, I would like it to save to the folder from which the > images were opened, reflect the image name with a .xls or .csv extension, > and be able to use it to batch process a large number of images. > > Any suggestions/help would be great! > > Thanks, > JP > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you! It worked beautifully. I'll have to play with the threshold to get it to pause until I enter the threshold. This is more for a batch process. Ideally, I would like it to pause for only the first image; once I set the threshold for the first image, I would love it to just process the rest in the batch.
Again, thanks for your help. JP |
you may want to use
waitForUser; it pauses the macro, displays a dialog box, and the macro proceeds when you click "ok". You should have time to adjust thresholds. best, jp 2015-08-21 9:15 GMT-04:00 jpdustin <[hidden email]>: > Thank you! It worked beautifully. I'll have to play with the threshold to > get > it to pause until I enter the threshold. This is more for a batch process. > Ideally, I would like it to pause for only the first image; once I set the > threshold for the first image, I would love it to just process the rest in > the batch. > > Again, thanks for your help. > JP > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/newimage-help-tp5014083p5014097.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |