0

I'm creating a script for automated measuring fluorescence intensity. I have done some progress, the macro opens the image, split in as many channels as I have and perform some trasformation so that it is possible to execute particle analysis at image 1. Then, what I want is to measure all the created ROIs but I am stacked at this point:

here is my code

 dir1 = getDirectory("Choose Source Directory ");
  list = getFileList(dir1);                                                           // get the list of all filenames in the directory
  subst = 3;                                                                          // set the "subst" variable to 3
  Dialog.create("BatchSplitStacks");                                                  // create a dialogue to change the stack divisor
  Dialog.addNumber("Number of substacks:", subst);                                    // in the dialogue, get the number of substacks, default is "subst" (=3)
  Dialog.show();                                                                      // show the above created dialogue
  chan = Dialog.getNumber();                                                          // the stack divisor is defined
  setBatchMode(false);                                                                 // do not show the images while processing them
  for (i=0; i<list.length; i++) {                                                     // go through the files of the folder
      showProgress(i+1, list.length);                                                 // the progress of the processing of the actual stack is shown in the ImageJ window
      open(dir1+list[i]);                                                             // open an original stack
      name = list[i];                                                                 // get the filename of the original stack
      run("Stack Splitter", "number="+chan);                                          // run the Stack Splitter plugin with the defined divisor
      for (e=0; e<chan; e++) {                                                        // for each substack a saving routine is run
         dotIndex = lastIndexOf(name, ".");                                           // this line and the following line I took from another macro but I do not know 
                                                                          // substacks with a number below 10 are saved with a suffix and a 2 digit extension (e.g. 01 instead of the standard 1)
             saveAs("tiff", dir1+"c0"+e+".tif");
          close();
                                                                          // closing substack
      }                                                                               // next saving routine
                     close();                                                                   // closing current original stack

                     open(dir1+"c02.tif");
                                run("Enhance Contrast", "saturated=0.35");
                                run("Enhance Contrast", "saturated=0.35");
                                run("Enhance Contrast", "saturated=0.35");
                                setAutoThreshold("Default");
                                setAutoThreshold("Default dark");
                                run("Make Binary");
                                run("Make Binary");
                                run("Watershed");
                                run("Analyze Particles...", "size=0.30-50.00 circularity=0.00-0.70 show=Masks display summarize add in_situ");
                     open(dir1+"c01.tif");
                     run("Subtract Background...", "rolling=50");


        saveAs("Results", dir1+name+"c02"+ ".txt");
  }                                                                                   // move on to next original stack in the folder

Thanks

Santi
  • 368
  • 2
  • 15

1 Answers1

0

You can measure all ROIs in the ROI Manager using the Measure button. In a macro, the lines are: roiManager("Deselect"); roiManager("Measure");

You can learn more macro commands easily by using the Macro Recorder.

You can browse all the available macro functions online.

For more sophisticated per-ROI analysis, you can loop over the ROIs in the manager using the roiManager("count") and roiManager("select", i) commands. The Scale_All_ROIs macro gives an example of this; you can easily load that macro into the Script Editor by opening a new script (File > New > Script) and then choosing it from the Templates > IJ1 Macro menu of the Script Editor.

ctrueden
  • 6,751
  • 3
  • 37
  • 69