Hi All
I am not very experienced in writing macros, so I used the macro recorder to create a simple macro (code below). However, when I run it, I get this error that says ")" expected in line 20. i double-checked the code, but seems like all the brackets/parentheses are accounted for in the code. Any suggestions? Really appreciate the help! run("Open..."); title=getTitle() selectWindow(title); run("Split Channels"); selectWindow(title+" (blue)"); close(); selectWindow(title+" (green)"); close(); selectWindow(title+" (red)"); run("16-bit"); run("Duplicate..."," "); selectWindow(title+" (red)-1"); setAutoThreshold("Default dark"); //run("Threshold..."); setThreshold(51, 254); //setThreshold(51, 254); setOption("BlackBackground", true); run("Convert to Mask"); run("Watershed"); //line below giving ")" expected error run("Set Measurements...", "area mean standard min limit redirect=[title+ " (red)"] decimal=3"); run("Analyze Particles...", "pixel show=Outlines display clear summarize"); selectWindow(title+ " (red)"); close(); selectWindow(title+ " (red)-1"); close(); -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Good day,
the following works for me: title+=" (red)"; run("Set Measurements...", "area mean standard min limit redirect=[title] decimal=3"); run("Analyze Particles...", "pixel show=Outlines display clear summarize"); selectWindow(title); close(); selectWindow(title+ "-1"); close(); (Please watch for line breaks introduced by the mailer.) This is not a good idea: setAutoThreshold("Default dark"); setThreshold(51, 254); First you use an automatic threshold scheme (Default), then you set the threshold to fixed values. Fixed thresholds should be avoided because they don't generalize to similar images. If you are not happy with the automatic "Default"-scheme, try one of the other automatic schemes. Regards Herbie ::::::::::::::::::::::::::::::::::: Am 13.11.19 um 18:30 schrieb nhasan: > run("Open..."); > title=getTitle() > selectWindow(title); > run("Split Channels"); > selectWindow(title+" (blue)"); > close(); > selectWindow(title+" (green)"); > close(); > selectWindow(title+" (red)"); > run("16-bit"); > run("Duplicate..."," "); > selectWindow(title+" (red)-1"); > setAutoThreshold("Default dark"); > //run("Threshold..."); > setThreshold(51, 254); > //setThreshold(51, 254); > setOption("BlackBackground", true); > run("Convert to Mask"); > run("Watershed"); > //line below giving ")" expected error > run("Set Measurements...", "area mean standard min limit redirect=[title+ " > (red)"] decimal=3"); > run("Analyze Particles...", "pixel show=Outlines display clear summarize"); > selectWindow(title+ " (red)"); > close(); > selectWindow(title+ " (red)-1"); > close(); -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you Herbie!
Just to clarify, where would i put the title+=" (red)"; ? should that be right above line 20? Also, thanks for the tip on the thresholding - the reason why I set the threshold was to be able to get a quantitative estimate of particles across images that fall within the thresholded area. Is there a better way of doing that using automatic thresholding? -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Here is the code that works for me:
///////////////////////// run("Open..."); title=getTitle() run("Split Channels"); close(title+" (blue)"); close(title+" (green)"); title+=" (red)"; run("16-bit"); // not sure if this is reasonable run("Duplicate..."," "); selectImage(title+"-1"); setThreshold(51, 254); setOption("BlackBackground", true); run("Convert to Mask"); run("Watershed"); run("Set Measurements...", "area mean standard min limit redirect=[title] decimal=3"); run("Analyze Particles...", "pixel show=Outlines display clear summarize"); close(title); close(title+"-1"); exit(); ///////////////////////// "Is there a better way of doing that using automatic thresholding?" Yes! Run the first part of the macro, i.e.: ///////////////////////// run("Open..."); title=getTitle() run("Split Channels"); close(title+" (blue)"); close(title+" (green)"); title+=" (red)"; run("16-bit"); // not sure if this is reasonable run("Duplicate..."," "); selectImage(title+"-1"); ///////////////////////// Then go to "Image >> Adjust >> Threshold...", check "Dark background" and choose a scheme from the left drop-down menu and look if the threshold suits your needs. If you've found an automatic threshold that is adequate, then exchange the macro code-line setThreshold(51, 254); by this line setAutoThreshold("XXXXX dark"); where XXXXX is the name of the automatic threshold-scheme. I'm not sure if you really need the code line: run("16-bit"); Finally, please try to understand what your macro is doing! Regards Herbie :::::::::::::::::::::::::::::::::::: Am 13.11.19 um 19:24 schrieb nhasan: > Thank you Herbie! > > Just to clarify, where would i put the title+=" (red)"; ? should that be > right above line 20? > > Also, thanks for the tip on the thresholding - the reason why I set the > threshold was to be able to get a quantitative estimate of particles across > images that fall within the thresholded area. Is there a better way of doing > that using automatic thresholding? > > > > > > -- > Sent from: http://imagej.1557.x6.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 |