Login  Register

Re: Data analysis Summary file

Posted by Michael Schmid on May 12, 2010; 7:33am
URL: http://imagej.273.s1.nabble.com/Data-analysis-Summary-file-tp3688318p3688319.html

Hi Kees,

the error message is misleading, the problem is that 'split' results  
in Strings (text), but you need numbers for division (you can use '+'  
on Strings, it is String concatenation).

e.g.
a = parseFloat(values[2]);

Michael
________________________________________________________________

On 12 May 2010, at 00:40, Straatman, Kees R. (Dr.) wrote:

> Dear List members,
>
> I try to write a macro that will analyse different types of  
> staining and write the results in a Summary file. When all the  
> images are analysed we want to make further calculations from the  
> data in the Summary file, like difference in area fraction between  
> two different stains of the same sample. So, the results file has  
> the total area of the sample on line 2 (line 1 is the heading),  
> results of stain 1 on line 3,stain 2 on lin 4 and stain 3 on line  
> 5. To calculate the area of stain 1 I use the next piece of code:
>
> selectWindow("Summary");
>    lines = split(getInfo(), "\n");
>    headings = split(lines[0], "\t");
>   for (j=1; j<lines.length; j++)
>   {
>       values = split(lines[j], "\t"); //lines in table
>       a = values[2];
>       values = split(lines[j+1], "\t");
>       b = values[2];
>       c = b/a*100;
>       print(c);
>       j = j + 3;
> }
>
> Unfortunately I get the error ';' expected in line 10 for </> . I  
> have tried many different options and checked the archives but  
> cannot find what is wrong. If I replace c=b/a by c=(b+a) all is  
> fine. However if I change to * or - I get the same error.
> Any suggestions?
>
> Thanks
>
> Kees
>
> Dr K.R. Straatman
> Senior Experimental Officer
> College of Medicine, Biological Sciences and Psychology
> University of Leicester
> http://www.le.ac.uk/biochem/microscopy/home.html