Login  Register

make selection, run macro, and open next file in directory

Posted by Andrew Sanchez on Jun 25, 2015; 8:22pm
URL: http://imagej.273.s1.nabble.com/make-selection-run-macro-and-open-next-file-in-directory-tp5013306.html

This is what I want my macro to do

1) prompt me to select a directory
2) open the first file in that directory
3) wait for me to draw a circle
4) run the macro
5) open the next file in the selected directory
6) repeat 3) - 5)

Currently I need to manually open images one at a time, run the macro on them individually, then open another file and repeat.  I thought the "Open Next" command (Ctrl + Shift + O) would do the trick, but after running this macro, I get a message saying “Directory information for ‘file_name.JPG’ not found.”

Here is the macro I am currently working with:


run("Set Measurements...", "area display redirect=None decimal=2");
run("Measure");
run("Crop");
setBackgroundColor(255, 255, 255);
run("Clear Outside");


// Color Thresholder 1.48v
// Autogenerated macro, single images only!
min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=38;
max[0]=127;
filter[0]="pass";
min[1]=27;
max[1]=190;
filter[1]="pass";
min[2]=18;
max[2]=254;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Colour Thresholding-------------

run("Analyze Particles...", "size=5-Infinity summarize");