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 |
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 |
Dear Michael,
Many thanks, it does the trick. Kees ________________________________________ From: ImageJ Interest Group [[hidden email]] On Behalf Of Michael Schmid [[hidden email]] Sent: 12 May 2010 08:33 To: [hidden email] Subject: Re: Data analysis Summary file 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 |
Free forum by Nabble | Edit this page |