Saturday, June 13, 2009

imagemagick: change color image to gray

convert -type Grayscale old.tiff new.tiffor to overiate original imagemogrify -type Grayscale old.tiff or to convert all images in a current folder:for f in *.tiff; do mogrify -type Grayscale $f ;done

Tuesday, June 02, 2009

Paired t-test assumption of normality

It is important to remember that paired t-test is valid if the differences of pairs of variables are normally distributed. It appears that the variables itself do not need to be normally distributed, as paired t-test only operates on the differences. This observation is based on [Bland2000, p. 161 and 260].

Normality of a sample can be evaluated using Q-Q plots [Bland2000, ch. 7.5]. However, the problem with these plots is that they are not objective, i.e. for one person a sample is normally distributed, for other person the same sample may be only approximately normally distributed while for the third person it is not normally distributed. For that reason quantitative methods are better. One of such methods is Shapiro-Wilk test. The other method is Kolmogorov-Smirnov test. For small samples (i.e. 50) Shapiro-Wilk is generally more accurate [Marques2003 p.157].

If sample was found to be non Normal, Wilcoxon signed-rank test (called also Wilcoxon matched pairs test) can be used [Bland2000, ch.12.3].

All the above tests can be performed easily in SPSS.

References
Bland, Martin. An Introduction to Medical Statistics 3th ed, Oxford University Press, 2000
J. P. Marques de Sá Applied statistics: using SPSS, STATISTICA, and MATLAB, Springer, 2003

Wednesday, May 27, 2009

Setting new nice value for a user's processes

To set a new nice value for all processes of a user the renice command can be used. For example to set a nice to 10:sudo renice 10 -u username.

Tuesday, May 26, 2009

Matlab: generate unique ID number

To generate a unique ID number for e.g. a temporary file or seed for random number generator current date/time in milliseconds can be used. I matlab the only command that gives time in milliseconds is datestr with FFF input e.g. datestr(now,'MMSSFFF')

ans =

5139451
datestr(now,'MMSSFFF')

ans =

5140057

UID=datestr(now,'MMSSFFF')

UID =

5214981

Unfortunatly other commands such as cputime or now don't return time in milliseconds, which is not so good.

Sunday, May 24, 2009

CentOS 5: Set a background wallpaper for fluxbox.

To set a background wallpaper for fluxbox in CentOS 5.2 the following command can be used:
fbsetbg -f /usr/share/backgrounds/images/c5-center-2048x1536.jpg or fbsetbg -f /usr/share/backgrounds/images/default.jpg The above commands in my case was executed in xterm in running fluxbox. The CentOS's wallpapers are in usr/share/backgrounds/.

Friday, May 22, 2009

python: simple start with simplejson

JSON (i.e. JavaScript Object Notation) is a popular way of exchanging data in a string format. It can also be used to provide setup parameters for a program. The second option I used to show very basic JSON usage in python with simplejson package. Lets assume that we have a txt file called data.json with the following JSON code:{
"Name": "W",
"Job": "Programmer",
"Movies": ["Star Wars", "Star Trek", "Terminator"],
"Address" : {
"Street": "Some Streat",
"House": 3,
"City": "Some City"
}
}
The above JSON code can be read into python object using load function as followsIn [7]: import simplejson as json
In [8]: f=open("data.json")
In [9]: data=json.load(f)
In [10]: f.close()
In [11]: data
Out[11]:
{'Address': {'House': 3, 'Street': 'Some Streat', 'City': 'Some City'},
'Job': 'Programmer',
'Movies': ['Star Wars', 'Star Trek', 'Terminator'],
'Name': 'W'}
In [12]: print data['Address']['House']
3
In [13]:
That's it:-)

Wednesday, May 20, 2009

Arch Linux: "Create archive" in gnome context menu

"Create archive" option in context menu is provided by Nautilus extenssion called file-roller. To install it in Arch linux it is enough to write (if sudo was installed previusly) sudo pacman -S file-roller With this extension files and folders can be archived, and archve files can be extracted

Thursday, May 14, 2009

Ubuntu 9.04 CD

I got my version of Ubuntu 9.04 on a CD from Canonical. These are the photos.

Monday, May 04, 2009

Matlab 2008b: Execute matlab from python in CentOS 5.2

I have Matlab 2008b running on CentOS 5.2 server. I wanted to be able to execute Matlab commands from python. After a search I found mlabwrap 1.0.1. I decided to install it. On CentOS 5.2 I have python 2.4.3. I also installed numpy 1.0.4 from epel repository. numpy is required to install mlabwrap. To install mlabwrap I fallowed the instructions. Fortunately, I had no problems with the installation.Note: the appearance of the windows in the image is from Mac X because I X forward them from CentOS server.

Sunday, May 03, 2009

Arch Linux: dual monitor

I use gnome 2.26.1 + compiz-fusion on my Archlinux box. I wanted to add a second monitor to it. I have nVidia GeFore FX 5200 card and the following drivers[W@localhost ~]$ pacman -Q | grep nvidia
nvidia-173xx 173.14.18-2
nvidia-173xx-utils 173.14.18-1
I connected one monitor through DVI cable and the second by the VGA cable. I had no problems setting dual screen using nvidia-settings program (it comes with the above drivers). Below are my settings:I also attach a photo of my compiz 3D cube on dual monitor screen. Later I change the monitors to have two, the same one. It can be noticed, that each monitor "is" on a different site of the 3D cube:-)