Login  Register

Help with import results with criteria

Posted by Moniraj Ghosh on Apr 09, 2011; 3:39pm
URL: http://imagej.273.s1.nabble.com/Help-with-import-results-with-criteria-tp3685060.html

Hi,
I am trying to import results table based on a certain criteria and I keep on getting a "out of range" error. Can someone help to figure what is wrong in the macro? The modification is in the last 8 lines. It is based on the import results table macro.
Thanks
_____________________________________

// Import Results Table
//
// This macro populates a fresh "Results" table
// from a saved ImageJ results table, or from
// any tab or comma-separated data file.

// This macro is built into ImageJ 1.38r and
// later as the File>Import>Results command.

 macro "Import Results Table" {
     requires("1.35r");
     lineseparator = "\n";
     cellseparator = ",\t";

     // copies the whole RT to an array of lines
     lines=split(File.openAsString(""), lineseparator);

     // recreates the columns headers
     labels=split(lines[0], cellseparator);
     if (labels[0]==" ")
        k=1; // it is an ImageJ Results table, skip first column
     else
        k=0; // it is not a Results table, load all columns
     for (j=k; j<labels.length; j++)
      setResult(labels[j],0,0);

     // dispatches the data into the new RT
     run("Clear Results");
     for (i=1; i<lines.length; i++)
    {
        items=split(lines[i], cellseparator);

      if(items[8] <=1.3)
         {
                for (j=k; j<items.length; j++)
           setResult(labels[j],i-1,items[j]);
         }
     }
     updateResults();
 }