Tutorial for count

I hope that you will forgive me the name tutorial. It is in fact just a few examples how program's options can affect the number of counted cells.

Program options summary

Program should be invoked from the command line. If you do not know what is the command line, I cannot help you much. Try G Under Linux or Mac you should run a program called Konsole, under Windows go to the Menu Start, find Run and type cmd. In both cases a window will appear, and this is the place where you can type some commands. What commands? - this is beyond the scope of this tutorial, see Download and Installation for more details. But to run the program count, you will always need to write:

> count.exe OPTIONS FILES

where FILES is one or more BMP files (with an extension *.bmp). To specify a single file, just type its name. To process more than one file, you can either type their names separated by spaces, or type something like *.bmp which means that all BMP files in the current directory shall be analyzed.

OPTIONS means one or more of the following options, all separated by spaces

Now some more options, but not very useful:

All these options can be listed by typing count.exe -help .

Examples

Below please find some examples of pictures, analyzed with different options.

Example 1

Let us start with an example of a very good staining of nuclei in dorsal spinal cord, shown already in How does it work section. When we invoke the program without any options (only the filename is given):

> count.exe pic1.bmp

the following message will be displayed:

PROGRAM count: which channel? (7=all, +1=r,+2=g,+4=b)

and the execution stops until the user will type something. The program asks which channel should be analyzed. To have only green channel, type 2 and press Enter. If we would like to count cells which are simultaneously green and red, we should type 3 (because it is 1+2). Similarly, it should be 6 for green-blue cells (2+4). If we decide to have only green and type 2, the program will display:

only channel G
pic1.bmp : av.size=5.72121 cells=633
end

and we will get the following picture:

The picture is saved into the current directory, and its name with the sign _ followed by the name of the input file. In our case it will be _pic1.bmp. The meaning of the printed numbers is the following. av.size stands for the average diameter of cell, here it was about 6 pixels. cells is the number of counted cells - this is what we are really looking for. These data will be also saved to a file named counting.dat. It consists of two lines with program parameters, and then goes the result of counting:
# number 	diameter 	pixels 	av. bright. 	name

633		5.72121		18212	25	        pic1.bmp
number is the number of cells, diameter is the same as av. size above, the two next columns are for us unimportant, and the last one is the name of file.

The same output can be produced simpler, when the channel is given explicitely when invoking the command:

> count.exe -m 2 pic1.bmp

where the number 2 means as before that only the green channel should be taken into account. When the option -m is given, the program does not ask about the channel and starts immediately. To calculate the number of red cells, we type:

> count.exe -m 2 pic1.bmp               (now press enter, and see...)
PROGRAM count: only channel R
pic1.bmp : av.size=5.51128 cells=463

end

and the picture looks now a bit different:

Example 2

Now we shall face with something more complicated: we wish to count yellow (green+red) cells in the following picture:

We see that the green staining looks poor - cells seem to be perforated and sometimes even split into several parts. If we try to invoke the program without any parameters except of that indicating counting red-green cells:

> count.exe -m 3 pic2.bmp

we will get the picture which does not seem to be quite reasonable:

The program counted some cells twice, three, or more times, because the green staining was not homogeneous enough, and multiple maxima of the brightness could appear within a single cell. However, the result can be much improved by typing:

> count.exe -m 3 -b 80 -D 10 -S 4 pic2.bmp

which means that we set the background level to 80 (default value: 60, range 0...255), minimal distance between cells is 10 pixels, and the cut-off for the diameter of a single cell is 4 (we reject cells smaller than 4 pixels). The result is now much better:

All parameters were chosen empirically, to get visually the best counting. One could argue, that it makes no sense to use a program when one has to examine the picture several times before one finds the best set of parameters, and that it is better to count cells manually. I have nothing to do but agree - but only when you have a single photo, with small number of cells. However, when there are 500 or more cells in the picture, and you have to count many pictures taken at the same conditions, so that they visually are very similar, the program offers a great spare of time, because it can be applied to all of them at the same time. Guessing the correct values of parameters take usually 1-10 minutes and then you immediately have a file with numbers. To do the same manually, it can take up to several hours (and many mistakes during counting).

Example 3

Now I shall demonstrate how some options affect the program behavior. Our source file is shown below and we want to count blue cells:


1. Default parameters:

>count.exe -m 4 ex3.bmp
PROGRAM count: only channel B
ex3.bmp : av.size=7.23069 cells=411



2. Background set to higher value (150):

>count.exe -m 4 -b 150 ex3.bmp
PROGRAM count: only channel B
ex3.bmp : av.size=4.40809 cells=391



3. Spots smaller than 10 pixels are rejected:

>count.exe -m 4 -S 10 ex3.bmp
PROGRAM count: only channel B
ex3.bmp : av.size=7.23069 cells=352



4. Minimal distance between cells is set to 10 pixels:

>count.exe -m 4 -D 10 ex3.bmp
PROGRAM count: only channel B
ex3.bmp : av.size=7.23069 cells=244



5. The average diameter (width) is set to 10 pixels:

>count.exe -m 4 -w 10 ex3.bmp
PROGRAM count: only channel B
ex3.bmp : av.size=10 cells=233