Dear all,
Can anyone see any problems with the following macro? I can't for the life of me get it doing what I want it to do. In essence I want my segmented particle (bright foreground, black background) and its associated ROI saved, but all I keep getting is black and white images (black particle + specks, white background). I've tried all various settings I can think of (threshold, etc), but nothing. My current problem is this: The 'Particle Analyzer' box comes up with "A threshold image or 8-bit binary image is required. Threshold levels can ve set using the Image -> Adjust -> Threshold tool." I am doing this (see macro), but the strange thing is, it seems to work manually...?! Many thanks, Andy <MACRO> setBatchMode(true); img = getImageID; setAutoThreshold(); getThreshold(lo, up); lo = lo-30; if (lo<0) { lo = 0; } setThreshold(lo, up); run("Threshold", "thresholded remaining"); run("Analyze Particles...", "size=10000-Infinity circularity=0.00-1.00 show=Masks clear include"); mask = getImageID; run("Copy"); setPasteMode("AND"); selectImage(img); run("Paste"); resetThreshold(); save(fileName+".tif"); selectImage(mask); run("Create Selection"); // requires 1.37j selectImage(img); run("Restore Selection"); save(fileName+".roi"); |
Andy Weller wrote:
> Dear all, > > Can anyone see any problems with the following macro? I can't for the > life of me get it doing what I want it to do. > > In essence I want my segmented particle (bright foreground, black > background) and its associated ROI saved, but all I keep getting is > black and white images (black particle + specks, white background). I've > tried all various settings I can think of (threshold, etc), but nothing. > My current problem is this: > > The 'Particle Analyzer' box comes up with "A threshold image or 8-bit > binary image is required. Threshold levels can ve set using the Image -> > Adjust -> Threshold tool." I am doing this (see macro), but the strange > thing is, it seems to work manually...?! > > Many thanks, Andy > > <MACRO> > > setBatchMode(true); save(fileName+".tif"); > selectImage(mask); > run("Create Selection"); // requires 1.37j > selectImage(img); > run("Restore Selection"); > save(fileName+".roi"); Hello Andy, hello ImageJers I might be wrong, but I noticed some strange behaviours with the setBatchMode(true) recently. I don't know yet what's going wrong but when setBatchMode is set to "true" before some piece of macro code creating a new image it seems to fail, at least with some combinations of ij/JRE. I didn't post it because I had to check first on other ij installations. Could you try without setBatchMode? sebastien. |
OK, so it's not setBatchMode that's causing the problem, but
thresholding. I've tried several combinations of: run("Threshold", "thresholded"); run("Threshold", "thresholded remaining"); run("Threshold", "thresholded remaining black"); run("Threshold", "thresholded black"); etc and it appears that it isn't doing it correctly. It kinda just thresholds everything, and therefore the Particle Analyzer doesn't work as the wrong information is passed to it. I've tried opening and re-saving my images as new tifs, but nothing. Is this a bug? I am running 1.37j and need this as I use the run("Create Selection") function. Thanks, Andy On Fri, 2006-06-30 at 14:57 +0200, seb wrote: > Andy Weller wrote: > > Dear all, > > > > Can anyone see any problems with the following macro? I can't for the > > life of me get it doing what I want it to do. > > > > In essence I want my segmented particle (bright foreground, black > > background) and its associated ROI saved, but all I keep getting is > > black and white images (black particle + specks, white background). I've > > tried all various settings I can think of (threshold, etc), but nothing. > > My current problem is this: > > > > The 'Particle Analyzer' box comes up with "A threshold image or 8-bit > > binary image is required. Threshold levels can ve set using the Image -> > > Adjust -> Threshold tool." I am doing this (see macro), but the strange > > thing is, it seems to work manually...?! > > > > Many thanks, Andy > > > > <MACRO> > > > > setBatchMode(true); > [SNIP] > > save(fileName+".tif"); > > selectImage(mask); > > run("Create Selection"); // requires 1.37j > > selectImage(img); > > run("Restore Selection"); > > save(fileName+".roi"); > > > Hello Andy, hello ImageJers > > I might be wrong, but I noticed some strange behaviours with the > setBatchMode(true) recently. > I don't know yet what's going wrong but when setBatchMode is set to > "true" before some piece of macro code creating a new image it seems to > fail, at least with some combinations of ij/JRE. > I didn't post it because I had to check first on other ij installations. > Could you try without setBatchMode? > > sebastien. |
I copied and pasted this exactly as it appears and the 'Particle
Analyzer' box pops up again with "A threshold image or 8-bit binary image is required. Threshold levels can ve set using the Image -> Adjust -> Threshold tool." Maybe I'll download version 1.37j again... Andy On Fri, 2006-06-30 at 11:49 -0400, Wayne Rasband wrote: > On Jun 30, 2006, at 10:29 AM, Andy Weller wrote: > > > OK, so it's not setBatchMode that's causing the problem, but > > thresholding. I've tried several combinations of: > > > > run("Threshold", "thresholded"); > > run("Threshold", "thresholded remaining"); > > run("Threshold", "thresholded remaining black"); > > run("Threshold", "thresholded black"); > > etc > > > > and it appears that it isn't doing it correctly. It kinda just > > thresholds everything, and therefore the Particle Analyzer doesn't work > > as the wrong information is passed to it. I've tried opening and > > re-saving my images as new tifs, but nothing. > > > > Is this a bug? > > I am not aware of any thresholding bugs. Please send me a macro that I > can run to reproduce the problem. This macro, which operates on the Dot > Blot sample image, appears to work fine on my system. Note that I had > to change the minimum particle size to 700. > > -wayne > > run("Dot Blot (7K)"); > setBatchMode(true); > img = getImageID; > > setAutoThreshold(); > getThreshold(lo, up); > lo = lo-30; > if (lo<0) { > lo = 0; > } > setThreshold(lo, up); > run("Threshold", "thresholded remaining"); > > run("Analyze Particles...", "size=700-Infinity circularity=0.00-1.00 > show=Masks clear include"); > mask = getImageID; > run("Copy"); > setPasteMode("AND"); > selectImage(img); > run("Paste"); > resetThreshold(); > selectImage(mask); > run("Create Selection"); // requires 1.37j > selectImage(img); > run("Restore Selection"); |
Free forum by Nabble | Edit this page |