2

I'm trying write a macro to save the profiles from a sequence of images. Sadly, it's not working: the images open and close correctly (and the correct profile is drawn) but the .csv is nowhere to be found.

This is the code:

function action(input, output, filename) {
    open(input+filename);
    makeLine(568, 14, 576, 1006);
    run("Plot Profile");
            saveAs("Measurements", output + filename + ".csv");
    close();
    close();
}


input = "C:\\Users\\...etc...\\20170124\\";
output = "C:\\Users\\...etc....\\20170124\\";

list = getFileList(input);
for (i = 0; i < list.length; i++)
        action(input, output, list[i]);
odo22
  • 590
  • 1
  • 7
  • 16
  • I also tried `saveAs("Results", output + filename + ".csv");` – odo22 Jan 24 '17 at 14:41
  • I posted a [question](https://stackoverflow.com/questions/41830479/imagej-macro-saving-csv-file) that is similar to this one. Would you mind taking a look at it? – fi12 Jun 06 '19 at 14:33

1 Answers1

2

Solved :D

function action(input, output, filename) {
    open(input+filename);
    makeLine(568, 14, 576, 1006);
    run("Clear Results");
    name = filename +".csv";
    profile = getProfile();
    for (i=0; i<profile.length; i++)
    setResult("Value", i, profile[i]);
    updateResults();
    saveAs("Results", output + name);  
}
odo22
  • 590
  • 1
  • 7
  • 16