ImageJ setResult

macro
Tags: #<Tag:0x00007fd542fb6048>

#1

I am trying to create a new excel with my results and then replace it using this code for macro ImageJ:

  run("Clear Results");
  path = saveDir +"Results.xls";
  saveAs("Results" , path);
  setResult("my name",  i, ct2);

my name: place holder for another column name
i : a for loop used to change the row
ct2: a number changing as the for loop progresses

However it keeps returning an error stating there is not enough Rows or row(1) out of range, and I was wondering how exactly to fix it.

If there is an alternative method to create new excel spread sheet and constantly add new data using my same variable please let me know.


#2

Dear @zing,

from https://imagej.nih.gov/ij/developer/macro/functions.html#setResult:

setResult(“Column”, row, value)
[…] A row is added to the table if row=nResults. […]

Could you check if i > nResults in your macro at some point? If so, that would explain the issue.

In general, it is useful if you can provide a minimal, complete, verifiable example macro for your issue and not just an excerpt.

Best,
Stefan


#3

My i was not greater than nResults infact it was far bellow it.


#4

If that’s the case, maybe you can provide a ResultsTable (as CSV) that you are trying to change and a macro that demonstrates the issue i.e. running that macro should show the error you are describing.