How to process image and output the plot profile in batch?

imagej

#1

Hi, I’m very new to the imagej macro language, and I want to get .spe images in a folder and get the measurement plot values in a .csv file with the same name as the image, in the same folder. I tried a lot of ways but they all failed. here’s what I got so far.

extension = ".spe";
  dir1 = getDirectory("Choose Source Directory ");
  dir2 = getDirectory("Choose Destination Directory ");
  setBatchMode(true);
  n = 0;
  processFolder(dir1);

  function processFolder(dir1) {
     list = getFileList(dir1);
     for (i=0; i<list.length; i++) {
          if (endsWith(list[i], "/"))
              processFolder(dir1+list[i]);
          else if (endsWith(list[i], extension))
             processImage(dir1, list[i]);
      }
  }

  function processImage(dir1, name) {
     open(dir1+name);
     makeLine(1, 640, 1200, 640);
     run("Plot Profile");
     saveAs(measurements, dir2+name+".csv");
     close();
  }

could anyone help? thanks.


#2

Hi,
you can use the macro function getProfile() instead of run("Plot Profile"). The documentation at https://imagej.nih.gov/ij/developer/macro/functions.html references an example that creates and saves a profile.