Hi Bassitenor,
I noticed this about a week ago, so I am not sure if it was there when I released the last version after bkromhout (https://github.com/bkromhout) added the cool optional parameters and the filehandling modes or if it is related to an update to the imagej api (probably the former and my shoddy real-world testing). After discovering the issue, no immediate coding solution popped into my mind or resulted in a satisfactory outcome when I tried a fix.
Line 109 is the last of this nested loop, when data is extracted from a copy of the results data:
for (int row = 0; row < numRows; row++)
for (int col = 0; col < numColumns; col++)
results[row][col] = resultsTable.getStringValue(headers[col], row);
Where ‘numRows’ and ‘numColumns’ are previously defined by:
ResultsTable resultsTable = Analyzer.getResultsTable();
int numColumns = resultsTable.getHeadings().length;
int numRows = resultsTable.size();
String[] headers = resultsTable.getHeadings();
and for reasons you have already speculated, the api command ‘getStringValue’ in the extraction loop doesn’t seem to like the null. Oddly enough, in my testing last week, a native results table column can be totally empty and the export works. I also tried to introduce a null check in the loop (something like this…):
if (resultsTable.getStringValue(headers[col], row) == null) {
resultsTable.setValue(headers[col], row, "none");
}
which compiled but didn’t solve the issue.
Basically, I need to do more testing and tweaking to fix this issue but I have included the above breakdown in case an easy solution pops into a more experienced mind that might be reading this.
As @Bio7 points out, in the macro you could also seed the empty results table cells with something prior to the export. Another quick alternative would be to delete the column altogether or to export using imagej’s native saveas .csv.
As I mentioned, I will have another look over the plugin for a proper fix, but if anybody else wants to suggest ideas, that’s also super.
Kind regards.