Friday, October 30, 2009

Comparing two methods of measurement in Matalb or Octave

How to compare two methods that measure the same variable? How to check if one method produces results constantly higher than the other method and if the difference is significant? How to determine whether new method, can replace the old one? The anwser to these question lies in the analysis of bias between the two method of measurement [1]. Below is a Matlab implementation of Ordinary least products (OLP) regression analysis [1] that can be used to anwser to these questions.

function res = mgr(X,Y,varargin)
% res = mgr(X,Y)
% Mean Geometric Regression (i.e. Ordinary least products (OLP) regression)
% Used to evaluate two measurement methods in terms of fixed and
% proportional bias as described in [1].
% X - vector of values calculated by the first method.
% Y - vector of values calculated by the second method.
% boolean - plot or not scattergram of the values
% string - label of x axis of scattergram
% string - label of y axis of scattergram
% EXAMPLE from [1]:
% M1=[132 138 144 146 148 152 158 130 162 168 172 174 180 180 188 194 194 200 200 204 210 210 216 220 220];
% M2=[130 134 132 140 150 144 150 122 160 150 160 178 168 174 186 172 182 178 196 188 180 196 210 190 202];
% res=mgr(M1,M2)
%res =
% a: 13.9506
% b: 0.8611
% a_CI95: [-6.9476 32.3364]
% b_CI95: [0.7576 0.9788]
% res=mgr(M1,M2,true); % produces scattergram
% res=mgr(M1,M2,true,'SBP(M1)','SBP(M2)'); % produces scattergram with x and y axis
% % labels of 'SBP(M1)' and 'SBP(M2)'
% The above calculated values of a and b agree with the values in [1]
% Values of CI95 are marginally different, becouse, as expalined in [1],
% they are calculated using approximate formulas.
%[1] J Ludbrook, Comparing methods of measurement, Clinical and
% Experimental Pharmacology and Physiology, 1997:24,193-203
Full code of the above script is here.
Script was tested on Matlab 2007a and in Octave 3.2. En example of the scattergram that is generated by the script is below. This scattergram is the same as an example given in [1].


[1] J Ludbrook, Comparing methods of measurement, Clinical and Experimental Pharmacology and Physiology, 1997:24,193-203.

Friday, October 23, 2009

Ten clicks to install Ubuntu 9.04

Update: My honest mistake: It should be Ubuntu 9.10, not 9.04. Thanks Tom!

Click 1

Click Enter for English language.

Clicks 2 and 3

Go to Install Ubuntu and Click Enter.

Click 4




Click 6


Click 7


Click 8

Forward (Typing username and password were not counted).

Click 9


Waiting for installation to complete

Click 10

Restart Now and Ubuntu installation is finished.

So 10 clicks is enough to install Ubuntu 9.04 9.10. Is it much or not? You can compare it with the number of clicks in other systems [Image taken from Benchmarked: Ubuntu vs Vista vs Windows 7]:

Monday, October 19, 2009

How ImageMagick can save you time

ImageMagick is a great tool! Many times it has saved me from programming. Here is just one example of many applications of the ImageMagick that can save one's time.

Recently, I was asked to check whether a set of images (few hundreds of them) contains one particular image. So, basically I was given and image (called testImage.tiff), and I needed to check whether this image belongs to a set a few hundreds of images. En example of the images from the set is below:

So how to anwser this? You can do manual (i.e. visual comparison), you can also write some simple script in Python with PIL. All would take some time. But why to do this, if you can just write one for loop in bash with compare command from ImageMagick?

So first thing I did is to create the following folders:

The input folder contains all images from the set, the output folder will be where the results of my search will be stored, and the testImage.tiff is my test image.

So thanks to ImageMagick's, the only thing I had to do is to execute its compare command on all images from the set (i.e. input folder).  In other words, I compared, in a loop, an image from the set with the testImage.tiff and the results of the comparison went to output folder. Below is the bash for loop that was executed inside the input folder.
for f in *.tiff ; do
compare $f ../testImage.tiff ../output/$f ;
After loop finished, I could go to output folder, and quickly find out whether testImage.tiff is in the set:

As can be seen in the above picture, the testImage.tiff belongs this this set.

One limitation of this procedure is that I had to manually go through the output folder. But because all not matching images are in red, it was very quick to find, the one image that was not red. (if any). Additionally, if the testImage.tiff and images from the set were of different size or type additional code would be necessary.

So thanks to the ImageMagick, I could do the job in just a few minutes.

Sunday, October 18, 2009

xampp / lampp: upgrade PHPUnit in lampp 1.7.1

The default PHPUnit that ships with lampp 1.7.1 is not suited for use with Zend Framework 1.9. The reason is that the PHPUnit version in lampp is to low. So it is necessary to upgrade it using pear. However, before it can be done, pear version that comes with lampp 1.7.1 needs to be also upgraded. The pear executable is in /opt/lampp/bin so I went to this folder.

First PHPUnit channel must be added sudo ./pear channel-discover
Adding Channel "" succeeded
Discovery of channel "" succeeded

Then pear chanels can be updated sudo ./pear update-channels

Then we can try to install PHPUnit:sudo ./pear install phpunit/PHPUnit
phpunit/PHPUnit requires PEAR Installer (version >= 1.8.1), installed version is 1.7.1
phpunit/PHPUnit requires package "pear/Image_GraphViz" (version >= 1.2.1), installed version is 1.1.0
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5)
No valid packages found
install failed

To upgrade pear I used sudo ./pear upgrade PEAR To check if upgrade was successful I used ./pear -V
PEAR Version: 1.9.0
PHP Version: 5.2.9
Zend Engine Version: 2.2.0
Running on: Linux arch 2.6.31-ARCH #1 SMP PREEMPT Tue Oct 13 13:36:23 CEST 2009 i686

Before PHPUnit can be upgraded, pear/Image_GraphViz package must be upgraded first. So sudo ./pear upgrade pear/Image_GraphViz
downloading Image_GraphViz-1.2.1.tgz ...
Starting to download Image_GraphViz-1.2.1.tgz (4,872 bytes)
.....done: 4,872 bytes
upgrade ok: channel://

and install PHPUnit ./pear install -a phpunit/PHPUnit
phpunit/PHPUnit can optionally use PHP extension "xdebug" (version >= 2.0.5)
downloading PHPUnit-3.4.1.tgz ...
Starting to download PHPUnit-3.4.1.tgz (326,659 bytes)
...................................................................done: 326,659 bytes
install ok: channel://

After this, when I could use PHPUnit with Zend Framework as described in a tutorial here.

Thursday, October 15, 2009

SPSS: create random binary variable

To create a random binary variable called e.g. new_var one can use the following code:COMPUTE new_var=RND(RV.UNIFORM(0,1)).

Wednesday, October 07, 2009

Xampp: SQLSTATE[HY000] [2002] Invalid argument

I'm currently developing a web application using Zend Framework 1.9.x. For this purpose I used Xampp for linux (i.e. lampp 1.7.2). Most of the time I was using arch linux with xampp 1.7.2 and there was no problem. Then I changed my os to Ubuntu 9.04 and I installed the same xampp 1.7.2. Interestingly, when I wanted to run my application under Ubuntu I got an errorMessage: SQLSTATE[HY000] [2002] Invalid argumentAfter googling I found that the reason was that in my php.ini (i.e. for xampp it is /opt/lampp/etc/php.ini) the variable pdo_mysql.default_socket was not set: Therefore I set it to /opt/lampp/var/mysql/mysql.sockOf course, I also had to restart Xamppsudo /opt/lampp/lampp restartIt is interesting why Xampp 1.7.2 worked under Arch Linux, but it did not work under Ubuntu 9.04?

Friday, October 02, 2009

Gnome desktop icons disappear

I have gnome 2.26.3 and sometimes all my icons on the desktop disappear. I found that in Gnome, program called nautilus manages it. So for my case it was enough to restart/start itnautilus --no-default-window &Nautilus is the same program that you use for browsing folders under Gnome.