Z-axis Profile macro


I have here a macro from Plot Z-axis Profile

when i manual save is the Result in my csv so : 0,0.0142

and with the makro is the Resultin csv so: 1,0,0.0142

how can change to output is standard; 0,0.0142

extension = ".tif";
dirpath = getDirectory ("Choose Source Directory ");

setBatchMode (true);
n = 0;
processFolder (dirpath);

function processFolder (dirpath) {
  fnames = getFileList (dirpath);
  for (i = 0; i < fnames.length; i++) {
    fpath = dirpath + fnames[i];
    if (endsWith (fpath, "/"))
      processFolder (fpath);
    else if (endsWith(fpath, extension))

function processImage (fpath) {
  open (fpath);
  run ("Plot Z-axis Profile");
  xpoints = newArray ();
  ypoints = newArray ();
  Plot.getValues (xpoints, ypoints);

  run ("Clear Results");
  for (i = 0; i < xpoints.length; i++) {
    setResult ("x", i, xpoints[i]);
    setResult ("y", i, ypoints[i]);
  updateResults ();
  saveAs ("Measurements", fpath + ".csv");

Just for the record:

This is a cross-post from the ImageJ-list and has been answered there:


1 Like

The answer that @schmid responded with was:

Hi Tobi,

it seems that the first column in your csv file is the row number.
Use Edit>Options>Input/Output to control whether you want row numbers or
not (“Save row numbers”).

You can use the Macro recorder Plugins>Macros>Record to get the macro
command for settings the Input/Output options of your choice.

By the way, in your macro

xpoints = newArray ();
ypoints = newArray (); 
Plot.getValues (xpoints, ypoints);

you don’t need the two lines for creating the xpoints & ypoints arrays;
Plot.getValues creates them anyhow.