title: setting threshold and batch processing in ImageJ (FIJI) macro
body: <p>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.</p>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>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. </p>
  
  <p>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!</p>
  
  <p>What I have been using for my simple macro:</p>
  
  <pre><code> 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");
  </code></pre>