weird problems

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

weird problems

Martin du Saire
Hi,

1)  I think ij 1.37n doesn't record starts when running the particle
analyzer, at least it doesn't display them in the Results table.

2)  Either there is a BatchMode problem with 1.37h, m, and n, or my
programming stinks:  When running the following macro in BatchMode,
ImageJ opens a blank image with the name of the input image and then
hangs.  I have to close ImageJ to do anything else.  If I comment out
line 137:  close();  Everything "works", except when I run the macro
on a entire folder I eventually run out of memory...

Assuming this is not just the result of poor programming on my part,
does anyone have any old versions of ij.jar I could use?

3)  Not to whine or anything, but every once in a while, when I try
to run a macro from the Plugins drop-down menu I get what appears to
be the plugin editor.

Over and out.

M


macro "_ApHue_1.0" {
var version = "AH_1.0";

// Clear old Results and Log
if (isOpen("Log") == 1)  {
    selectWindow("Log");
    run("Close");
}
run("Clear Results");
Dialog.create("ApHue_1.0");
  Dialog.addCheckbox("Batch mode", false);
  Dialog.addCheckbox("Single image", true);
Dialog.show();
batchOn = Dialog.getCheckbox();
doSingleImage = Dialog.getCheckbox();
setBatchMode(batchOn);
processTimeTotal = getTime();
processTime = processTimeTotal;
// ***************** Hardcoded values ****************
imCount = 0;
hueTh = 52;
blurRadius = 5;
// ***************************************************
if (doSingleImage == true) {
     fileDir = getDirectory("image");
     path = fileDir;
     imName = getTitle();
     selectImage(imName);
     datetime=substring(getTitle(),9,24);
     baseName = substring(imName,0,lengthOf(imName) - 4);
     HCount = hueThreshold(blurRadius, imName, baseName);
     fMax = 1;
     imCount = 1;
     datetime=substring(datetime,0,8)+substring(datetime,9,15); //
Output datetime in MySQL friendly format
     print(datetime+","+HCount);
     selectImage(imName);
     close();
} else {
     fileDir = getDirectory("Choose a directory to process");
     path = fileDir;
     fileList = getFileList(fileDir);
     fMax = fileList.length;
     for (f=0; f<fMax; f++) {
          if (startsWith(fileList[f],"snap") &
endsWith(fileList[f],".jpg") & (lengthOf(fileList[f]) == 28)) {  //
Only process "snap"shots and
              imagePath =
fileDir+fileList[f];                                  // ".jpg" images
              open(imagePath);
              imCount++;
              imName = getTitle();
              selectImage(imName);
              datetime=substring(getTitle(),9,24);
              baseName = substring(imName,0,lengthOf(imName) - 4);
              HCount = hueThreshold(blurRadius, imName, baseName);
              datetime=substring(datetime,0,8)+substring(datetime,9,15);
// Output datetime in MySQL friendly format
              print(datetime+","+HCount);
              selectImage(imName);
              close();
          }
     }
}
if (batchOn == true) setBatchMode(false);
selectWindow("Log");
outFile = fileDir+"Log"+substring(datetime,0,8)+version+".txt";
print(outFile);
save(outFile);
processTimeTotal = (getTime() - processTime) * 0.001;
print("Total processing time (s): "+processTimeTotal);
print("Number of images processed: "+imCount);
} //******************* End of main *********************

function hueThreshold(fblurRadius, inName, bName) {
//print("hueThreshold");
run("Duplicate...", "title=imageCopy");
run("HSB Stack Splitter");
selectImage('imageCopy (saturation)');
close();
selectImage('imageCopy (brightness)');
close();
selectImage('imageCopy (hue)');
run("Gaussian Blur...", "radius="+fblurRadius);
setThreshold(0, hueTh);
run("Make Binary", "thresholded remaining black");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Outlines clear");
hueBlobOutlines = getTitle();
run("RGB Color");
imageCalculator("AND create", hueBlobOutlines, inName);
outImage = fileDir+bName+version+".jpg";
saveAs("jpeg", outImage);
close();
selectImage(hueBlobOutlines);
close();
if (nResults > 0) {
     selectImage('imageCopy (hue)');
     close();
}
return nResults;
}
   
Reply | Threaded
Open this post in threaded view
|

Re: weird problems

Wayne Rasband
> 1)  I think ij 1.37n doesn't record starts when running the particle
> analyzer, at least it doesn't display them in the Results table.

This is fixed in v1.37o, available at
<http://rsb.info.nih.gov/ij/notes.html>.

> 2)  Either there is a BatchMode problem with 1.37h, m, and n, or my
> programming stinks:  When running the following macro in BatchMode,
> ImageJ opens a blank image with the name of the input image and then
> hangs.  I have to close ImageJ to do anything else.  If I comment out
> line 137:  close();  Everything "works", except when I run the macro
> on a entire folder I eventually run out of memory...
>
> Assuming this is not just the result of poor programming on my part,
> does anyone have any old versions of ij.jar I could use?

Some older versions of ij.jar are available at
<http://rsb.info.nih.gov/ij/download/jars/>.

> 3)  Not to whine or anything, but every once in a while, when I try to
> run a macro from the Plugins drop-down menu I get what appears to be
> the plugin editor.

This is a "feature" that does not always work right. Holding down the
shift key when selecting a macro from the Plugins menu opens it in the
editor instead of running it, but sometimes the shift key gets "stuck"
down. What you can do when this happens is press ctrl-r (the editor's
Run Macro command).

-wayne

>
>
> macro "_ApHue_1.0" {
> var version = "AH_1.0";
>
> // Clear old Results and Log
> if (isOpen("Log") == 1)  {
>    selectWindow("Log");
>    run("Close");
> }
> run("Clear Results");
> Dialog.create("ApHue_1.0");
>  Dialog.addCheckbox("Batch mode", false);
>  Dialog.addCheckbox("Single image", true);
> Dialog.show();
> batchOn = Dialog.getCheckbox();
> doSingleImage = Dialog.getCheckbox();
> setBatchMode(batchOn);
> processTimeTotal = getTime();
> processTime = processTimeTotal;
> // ***************** Hardcoded values ****************
> imCount = 0;
> hueTh = 52;
> blurRadius = 5;
> // ***************************************************
> if (doSingleImage == true) {
>     fileDir = getDirectory("image");
>     path = fileDir;
>     imName = getTitle();
>     selectImage(imName);
>     datetime=substring(getTitle(),9,24);
>     baseName = substring(imName,0,lengthOf(imName) - 4);
>     HCount = hueThreshold(blurRadius, imName, baseName);
>     fMax = 1;
>     imCount = 1;
>     datetime=substring(datetime,0,8)+substring(datetime,9,15); //
> Output datetime in MySQL friendly format
>     print(datetime+","+HCount);
>     selectImage(imName);
>     close();
> } else {
>     fileDir = getDirectory("Choose a directory to process");
>     path = fileDir;
>     fileList = getFileList(fileDir);
>     fMax = fileList.length;
>     for (f=0; f<fMax; f++) {
>          if (startsWith(fileList[f],"snap") &
> endsWith(fileList[f],".jpg") & (lengthOf(fileList[f]) == 28)) {  //
> Only process "snap"shots and
>              imagePath = fileDir+fileList[f];                          
>         // ".jpg" images
>              open(imagePath);
>              imCount++;
>              imName = getTitle();
>              selectImage(imName);
>              datetime=substring(getTitle(),9,24);
>              baseName = substring(imName,0,lengthOf(imName) - 4);
>              HCount = hueThreshold(blurRadius, imName, baseName);
>              
> datetime=substring(datetime,0,8)+substring(datetime,9,15); // Output
> datetime in MySQL friendly format
>              print(datetime+","+HCount);
>              selectImage(imName);
>              close();
>          }
>     }
> }
> if (batchOn == true) setBatchMode(false);
> selectWindow("Log");
> outFile = fileDir+"Log"+substring(datetime,0,8)+version+".txt";
> print(outFile);
> save(outFile);
> processTimeTotal = (getTime() - processTime) * 0.001;
> print("Total processing time (s): "+processTimeTotal);
> print("Number of images processed: "+imCount);
> } //******************* End of main *********************
>
> function hueThreshold(fblurRadius, inName, bName) {
> //print("hueThreshold");
> run("Duplicate...", "title=imageCopy");
> run("HSB Stack Splitter");
> selectImage('imageCopy (saturation)');
> close();
> selectImage('imageCopy (brightness)');
> close();
> selectImage('imageCopy (hue)');
> run("Gaussian Blur...", "radius="+fblurRadius);
> setThreshold(0, hueTh);
> run("Make Binary", "thresholded remaining black");
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Outlines clear");
> hueBlobOutlines = getTitle();
> run("RGB Color");
> imageCalculator("AND create", hueBlobOutlines, inName);
> outImage = fileDir+bName+version+".jpg";
> saveAs("jpeg", outImage);
> close();
> selectImage(hueBlobOutlines);
> close();
> if (nResults > 0) {
>     selectImage('imageCopy (hue)');
>     close();
> }
> return nResults;
> }
>