Sunday, April 29, 2007

Coefficient of variation

The coefficient of variation is a dimensionless number that allows comparison of the variation of populations that have significantly different mean values. It is defined as:cv=std(X)/mean(X);
For example if:
X= [1.7 1.6 2.8 5.6 1.3 2.2 1.3 1.1 3.2 1.5 5.2 4.6 5.8 3.0];
then cv=0.5846.

P-value and t-critical values in Matlab and Octave

If one use to calculate t-critical and P-values using t statistis, those functins in Matlab/Octave do it:
t_critical= tinv(1-alpha/2,n-2);

where alpha is confidence level (e.g. alpha=0.05 for 95% confidence level);
Pval=2*(1-tcdf(abs(t),n-2))

where t is our calculated value of t statistics.

With regard to Octave, it depends which version you use. You may find that instead of tint and tcdf there are t_int and t_cdf functions.

Friday, April 27, 2007

Latex: Miktex (Windows) and TexShop (Mac X) and tetex (Linux)

Latex is great tool for writing scientific texts. You just write and do not worry about sorting references, formatting them, changing numeration when you add or remove figures, create subfigures, subtables, etc. It is just nice and I am big fun of it, even thought creating tables is not so convenient. Nevertheless, I have had lately one big problem with Latex, or rather I should say problems between Windows’ and Mac X’s Latex software.

At work I use Mac X 10.4 and I have TexShop to write in Latex. On Windows there is Miktex. Separately both tools are just fine. However, when I tried to edit tex file in Miktex file which initially was written in TexShop I found big problems. First of all, basic Miktex installation do not include subfig package. Which is very, very bed due to the fact that my PC box do not have internet connection. But after connecting to the internet and installing subfig and many other missing packages it did not help much. I still have huge problems with compiling tex files that were written in TexShop.

I know that Latex should be multiplatform but in my case it is not. As far as I can say TexShop in Mac X and MikTex in Windows are totally different, and one cannot use both. Maybe if I spend more time, I could solve all the problems and run my file on Windows, but in fact I do not have time and energy to do it. Even though I’m computer geek, believe me or not I have more important thing to do than to investigate what is happening with MikTex. I need to write, and not to waste time make MikTex working with my files from Mac XĂ…DMaybe if I install full MikTex, rather than basic, but this is not possible because full MikTex is just too big to download from the internet. One other fast possible solution is maybe to use Cygwin and to use some linux based latex software to write latex. This I can check quite quickly, but first I need to install Cygwin.

As a result I am considering working with OpenOffice or even Microsoft office, because they just work. Not perfectly but at least I can write. To be honest I’m I would prefer to work in Latex, and maybe I will do all the writing on Mac X, because Latex is much better for me than MS Office or OpenOffice.

By the way, I think that TexShop for Mac X is much better and easier to use than MikText. I wander how it looks like in Linux. I have Ubuntu on my other PC box, and maybe I will install some Latex environment there just to see if I experience the same problems or everything will work.

I also wander if only I have such problems between latex in Mac X and Windows XP, or it is rather common?

UPDATE
I have just tested latex on Ubuntu with tetex and auctex. Anfortunately the same proplems as before. I can not compile Latex files for Mac X - too many errors.

CONCLUSION
Latex is totally incompatible between different operating systems if one tries to write a little more complicated (subtables, subfigures, two column) article !!!

Wednesday, April 18, 2007

Matlab 2007a for Intel Mac. Finally!

Finally, after more than one year of waiting for Matlab with support of Intel Macs there it is - Matlab 2007a (7.4.0.287). It supports also Windows Vista, and 64-bit Sun Solaris SPARC platforms. I was happy like little child to have it installed and to use it. Unfortunately it did not work from the beginning. When I try to run Matlab from console, I got:
Failed to start the Desktop:
Failure loading desktop class


In my case to make it work properly I had to update Java in my system to the latest versions available through Software Update. After doing this, Matlab environment started without any problems.

One of many new things about this edition of Matlab, is the fact that multithreading is available of core functions of Matlab. By default this option is disabled, hence one must enable it in the preference window. Unfortunately again, still you cannot write any program with multiple threads. Multithreading is only used by the core, standard Matlab functions.

Quickly I decided to test this multithreading. To test it I used quite intensive image processing algorithm analyzing images. I analyzed 34 images twice. Once with enabled and once with disabled multithreading option. I analyzed results using paired t-test to check if there is any significant (with confidence 95%) change in the execution time. Unfortunately, according to t-test, there was no significant change (P>0.05).

Moreover, new with this version of Matlab is the fact that one can run parallel algorithms in four MATLAB sessions on single desktop with Distributed Computing Toolbox.
Unfortunately, I do not have this Toolbox, and cannot check if this form of parallel execution significantly improve speed (assuming one have program that uses it).

I think that the best way for me to use two cores in my Intel Mac, is just to start to separate Matlabs. In my case it is very useful, because I work with image processing, and often I have many images to process. Thanks to two cores one Matlab can process first half of the number of images, and the second one, the second half. Consequently, I can process all images two times faster.

Finally, as usual with matlab version there are minor problems with backward comparability. Hence to run some programs on this newest version I had to make some minor changes in few algorithms. Moreover, at the moment there is problem with compiling ANCI C mex files. It is due to that I do not have latest version of Xcode. However, I believe that once I download it (over 800MB) and install, it will work.

And really final thought. Still no hash tables!

Sunday, April 15, 2007

Matlab and hash tables

Unfortunately, Matlab does not have hash table functionality by itself. However, Matlab is based on Java, and provides programing interface to java classes. Consequently, it is possible to use Hash tables from Java!. It can be convenient and fast. You can store normal scalars, strings, matrices, etc in Java containers without much effort.
Below little example just to start with. It shows Hashtable, where we put few values, and afterwards we create iterator and iterate over Hashtable.

function testJavaHash
import java.util.*;
ja_h = Hashtable;

a='aaa';
b=12.23;
c=[1 2; 3 4];
s='marcin';

%add something to hash
ja_h.put(1,a);
ja_h.put(2,b);
ja_h.put(3,c);
ja_h.put(s,c);


%create iterator;
keys = ArrayList(ja_h.keySet( ));
iterator = keys.iterator();


%iterate over all keys
while iterator.hasNext()
key=iterator.next();
val=ja_h.get(key);
key
val
end

Unfortunately, it is not as nice as it looks like. For example it is not possible to use matrices as keys in hash tables. For instance:
ja_h.put([1 2],2);
ja_h.get([1 2])
ans =

[]
As it can be seen, ja_h.get returns nothing.
What I do do overcome this, I just convert matrix into string with num2str and back str2num. Not the best possible solution but it works for me in few limited situations:
ja_h.put(num2str([1 2]),2);
ja_h.get(num2str([1 2]))
ans =

2
However this solution does not work for e.g. 2x2 matrices ja_h.put(num2str([1 2; 3 4]),2);
ja_h.get(num2str([1 2; 3 4]))
ans =

[]
Similar problems are with mhashtable package available from Matlab Central File Exchange. I do not know why it is so difficult for Matlab engineers to create native Matlab support for Hash tables?

Wednesday, April 11, 2007

Warning: Problems in UIW_SetUpGLPrinting

This error I had in Matlab. In fact it is only warning, but when you save image using e.g. print function your figure is just black. I had it working on Windows XP. The solution was to install Nvidia drivers to my GeForce FX 5200. Afterwards, saving images worked like it should.

Monday, April 09, 2007

Inter-observer, Intra-observer, observer bias variability

Those terms are commonly used in image processing e.g. comparing reproductivity of given segmentation method. Their meaning is as fallow:

Inter-observer - one observer scores the same phenomena several times at different times. For example: few times the same radiologist selects region of interest (ROI) on the same X-ray. The question is, how similar those selections separated in time are to each other i.e. can the radiologists manually select exactly the same ROI in terms of position, shape, size?

Intra-observer - few observers score the same phenomena. For instance: few radiologists select manually ROI on the same X-ray. What is the agreement in selected ROI by different radiologists.

Observer bias - each observer can interpret the same phenomena differently. For example, if selecting ROI, radiologist can include into ROI distorted parts of an X-ray image (e.g. by noise), because for him those distortions are small. At the same time, the other radiologists can avoid those parts of X-ray, cause for him those distortions are to serious to ignore.