0

I know this has been posted elsewhere and that this is no means a difficult problem but I'm very new to writing macros in FIJI and am having a hard time even understanding the solutions described in various online resources.

I have a series of images all in the same folder and want to apply the same operations to them all and save the resultant excel files and images in an output folder. Specifically, I'd like to open, smooth the image, do a Max intensity Z projection, then threshold the images to the same relative value.

This thresholding is one step causing a problem. By relative value I mean that I would like to set the threshold so that the same % of the intensity histogram is included. Currently, in FIJI if you go to image>adjust>threshold you can move the sliders such that a certain percentage of the image is thresholded and it will display that value for you in the open window. In my case 98% is what I am trying to achieve, eg thresholding all but the top 2% of the data.

Once the threshold is applied to the MIP, I convert it to binary and do particle analysis and save the results (summary table, results, image overlay.

My approach has been to try and automate all the steps/ do batch processing but I have been having a hard time adapting what I have written to work based on instructions found online. Instead I've been just opening every image in the directory one by one and applying the macro that I wrote, then saving the results manually. Obviously this is a tedious approach so any help would be much appreciated!

What I have been using for my simple macro:

 run("Smooth", "stack");
 run("Z Project...", "projection=[Max Intensity]");

 setAutoThreshold("Default");
 //run("Threshold...");
 run("Convert to Mask");

 run("Make Binary");
 run("Analyze Particles...", "  show=[Overlay Masks] display exclude clear include summarize in_situ");
Harry B
  • 351
  • 1
  • 5
  • 17
  • 2
    Did you have a look at http://imagej.net/How_to_apply_a_common_operation_to_a_complete_directory ? The script editor template at *Templates ▶ IJ1 Macro ▶ Process Folder* is particularly suitable for this task. In general, questions like this are best asked on the [ImageJ forum](http://forum.imagej.net/) (in particular the [batch-processing](http://forum.imagej.net/tags/batch-processing) tag). – Jan Eglinger Feb 14 '16 at 07:12

1 Answers1

3

You can use the Process ▶ Batch ▶ Macro... command for this.

For further details, see the Batch Processing page of the ImageJ wiki.

ctrueden
  • 6,751
  • 3
  • 37
  • 69
  • Thanks for the tip, the batch processing template was very helpful! Any suggestions though about how to set the threshold? I see there's options for changing the the threshold method ie default, huang, intermodes, etc. but nothing where I could specify a particular percent of the histogram? – Harry B Feb 20 '16 at 17:10
  • 1
    It seems like you need to use a (somewhat nontrivial) macro for that. See e.g. http://imagej.1557.x6.nabble.com/Threshold-as-a-percentage-of-image-histogram-td3695671.html. Try pasting snippets into the [Script Editor](http://imagej.net/Using_the_Script_Editor) and running them. – ctrueden Apr 26 '16 at 21:53