Login  Register

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

Posted by fabrice senger-2 on Jun 26, 2015; 3:38pm
URL: http://imagej.273.s1.nabble.com/make-selection-run-macro-and-open-next-file-in-directory-tp5013306p5013332.html

Hi there,

you could use a loop and at the point you have to make a drawing or
selection or whatever use the "wait for user" command.

For the loop you can have a look at example macros and the "wait for user"
is described in macro functions.

Cheers,

Fabrice.

2015-06-25 22:22 GMT+02:00 Andrew Sanchez <[hidden email]>:

> 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");
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/make-selection-run-macro-and-open-next-file-in-directory-tp5013306.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