Introduction About Site Map

XML
RSS 2 Feed RSS 2 Feed
Navigation

Main Page | Blog Index

Archive for the ‘Free Software’ Category

Heart Tracking – Arrows Drawn Pixel by Pixel

Cardiac image with movement - arrows in blue

Cardiac image with movement - arrows in red

Rather than use the line function in Octave I’ve created a function that can draw several types of arrow, either with colour gradients or uniform, thick or thin (these are parameterised). I’ll soon publish the code.

The shown above arrows are very tiny, but there is a small arrowhead that tells which direction the points move in. Additionally, I have been implementing some 3-D means of visualising what is being done, but it is too early to show the results of this, possibly with arrows in hyperspace too.

These new exemplary images show a surface yielded with ‘hot’ colours where I move landmark points in between frames. It’s still work in progress.

Creating Animations With GNU Octave and the GNU Image Manipulation Program

The GIMP is an extremely powerful program and animation in the GIMP can be achieved with layers. That’s why I can get so much work done just with Free software and GNU tools like gnuplot. This includes some of the following new examples, which are done by taking screenshots (from the GIMP), stacking them up as layers, and then saving them as a GIF file with the animation option enabled.

The following file, an animated GIF image which comprises 8 frames with 600ms setting them apart (click the image to zoom), shows my new algorithm tracking the heart’s boundaries in a sequence taken from the same slice, which prevents sudden, unregistered change in the intensity values near the point being probed. 16 points are initially fixed in a region, equally spaced although that is not a strict requirement because the program takes any list of points and handles each one in turn. The points are separated by a 5-pixel distance in the x and y axes although that too can vary independently based on parameter input that sets a grid (better initialisation would look for edges of interest). The shown arrows are narrow and crude although an option exists for making them thick (which then hides interesting parts of the image). The shuffle parameters in this case involve a frame size of 9×9 pixels, a shuffle radius of 5 pixels, and a summation of pixel-wise differences.

Fiesta animation (cardiac)

A colour representation of the same images sequence is shown below (click to zoom).

Animation of heart surface

Another newly-implemented method looks at another measure for a window of pixels taken from consecutive frames. It considers a minimum of pixel-wise differences in a given range rather than take the average difference. The results obtained using each of these methods cannot be easily compared without a simplified synthetic set and a proper study would need to involve systematic experiments that look at how varying window size, radius, and calculation method affects overall performance. There is quite a project right there, but it only involves tracking, with or without tagging. Tags can help in identifying good landmark points to start with — points that define an anatomically-meaningful edge to start from and track as the sequence of frames progresses. Eventually, providing a formula for normalising a measure of similarity would be nice. Such a normalisation method — if properly applied — gives a new way of finding landmark points ‘on the move’. Doing so using non-rigid registration (NRR) is not possible for the heart as there is hardly a one-to-one correspondence between points (too much movement). The hope is that by employing a fast tracking algorithm with a good transform which adjusts itself for image intensity, size et cetera, it will be possible to identify edges and perform localised measurements, perhaps even do statistical analysis based on different sets of videos (long-term goal). These ideas are not far fetched and the body of work already done in this area ought to be explored. The novelty is the transform being used to quickly calculate similarity wrt neighbouring points, so existing work look at how to adjust parameters so as to get better results. In this particular problem domain, tracking the heart’s contours reliably and robustly enough is the objective, however it is not simple to do this ‘on he fly’ (speed of video playback for example).

3-D Fun with GNU Octave

I HAD worries that GNU Octave would not support some of the advanced graphing functionality of MATLAB, but with the help of tools like gnuplot, Octave stays on par in this game (bar some OpenGL enhancements). Much to my surprise, the 3-D charting and graphing software in GNU Octave. Here are some visualisations of cardiac images I work with.

Heart surface

Heart landmarks - mesh overlay

Surface - large

GNU Octave – Very Polished, Few Minor Pet Peeves

Fiesta - cardiac

EVERY program has areas worth improving. GNU Octave is no exception and I’ve been trying to submit bug reports (via Savannah) only to find that it has just been compromised (therefore temporarily down), so in the mean time, here is the gist of issues that I found so far.

While Octave is proving to be perfectly compatible with all the basic functions in MATLAB it also proves to be ‘compatible’ with MATLAB’s weight problem. Octave’s core is generally light and much faster to start than MATLAB’s, but when it opens child windows (e.g. ImageMagick), then it suffers a limitation due to the maximum number of allowed windows. For some reason, resources appear not to be recovered when images are closed (it may be leaking memory too), so X.org limits are sooner or later reached. This is a bizarre issue that’s hard to reproduce (in Fedora I cannot even open such windows [1, 2, 3]). But anyway, that’s mostly a performance issue. Closing an Octave session also helps as once it’s restarted windows are numbered from 1 upwards once again.

When it comes to vertical listing of files the UNIX way, there is something a little unexpected in Octave’s implementation of it (which may or may not be compatible with other software). The “ls” function, unless it gets invoked with specific options, will pick its data horizontally rather than vertically from standard I/O in the system call. To illustrate this point consider the following:

>>> ls('*.bmp')
MR000192.bmp  MR000200.bmp  MR000208.bmp  MR000216.bmp	MR000224.bmp
MR000193.bmp  MR000201.bmp  MR000209.bmp  MR000217.bmp	MR000225.bmp
MR000194.bmp  MR000202.bmp  MR000210.bmp  MR000218.bmp	MR000226.bmp
MR000195.bmp  MR000203.bmp  MR000211.bmp  MR000219.bmp	MR000227.bmp
MR000196.bmp  MR000204.bmp  MR000212.bmp  MR000220.bmp
MR000197.bmp  MR000205.bmp  MR000213.bmp  MR000221.bmp
MR000198.bmp  MR000206.bmp  MR000214.bmp  MR000222.bmp
MR000199.bmp  MR000207.bmp  MR000215.bmp  MR000223.bmp
>>> a=ls('*.bmp')
a =

MR000192.bmp
MR000200.bmp
MR000208.bmp
MR000216.bmp
MR000224.bmp
MR000193.bmp
MR000201.bmp
MR000209.bmp
MR000217.bmp
MR000225.bmp
MR000194.bmp
MR000202.bmp
MR000210.bmp
MR000218.bmp
MR000226.bmp
MR000195.bmp
MR000203.bmp
MR000211.bmp
MR000219.bmp
MR000227.bmp
MR000196.bmp
MR000204.bmp
MR000212.bmp
MR000220.bmp
MR000197.bmp
MR000205.bmp
MR000213.bmp
MR000221.bmp
MR000198.bmp
MR000206.bmp
MR000214.bmp
MR000222.bmp
MR000199.bmp
MR000207.bmp
MR000215.bmp
MR000223.bmp

The arrangement is supposed to be on a column-by-column basis (the real ordering), but in the case of an assignment the data gets flattened in a way which does not preserve the original file ordering (alpha-numeric in this case).

By all means move from MATLAB to GNU Octave because these issues are not critical and some may be matters of convenience rather than practicality. If anything, this proves that Octave has only minor creases and no major deficiencies. That’s all I could find after heavy usage.

Migrations From MATLAB to GNU Octave

Octave packages

THIS MORNING I spent some time helping others make the same migration which happily enough I made over a month ago (so far, so good!). It’s a migration from proprietary software (and BSA backer) to free-as-in-freedom software, which also happens to be a GNU project. It helps that the project is cross-platform because unlike myself and many others, there are still a lot more Windows users out there. Moving them to Free software on Windows is an essential step which removes barriers when they swap the whole platform. GNU works better on GNU/Linux than on Windows, for obvious reasons. Although it’s a matter of opinion, under KDE QtOctave looks better than MATLAB, as well.

Installing GNU Octave in GNU/Linux is very simple because it is packaged in the repositories of *buntu and Fedora. These are the two distributions where I have checked to verify this although I encountered bumps along the way in Fedora [1, 2, 3]. It is not entirely Fedora’s fault and it’s a known issue that affects many people who are Octave users.

The packages one need to fetch via yum/apt-get (or graphical front ends like Synaptic and KPackageKit) are “Octave” and “QtOctave”. They are not large packages and they should be able to fetch dependencies that are being determined and resolved by the packager/packaging process. Once these are installed, an icon will typically show up somewhere along/inside the menus. If not, run qtoctave from the command line and ensure it gets access to the octave executable (it usually works perfectly ‘out of the box’ based on my experience on multiple boxes). Yes, this should work by default without user intervention, but in case it does not, ensure octave is properly installed and put in the path.

I am unfortunate enough to have faced Windows for about half an hour just now (not my computer) because in some cases, for collaboration purposes, computers that run Windows also need to have Octave installed on them, along with QtOctave for improved ease of use. The way to get that installed is a lot more complex and time consuming because Windows does not have packages managers (this is one of the areas where GNU/Linux is ahead of its competition). In any case, here is how one should install everything and get it set up

Navigate to the downloads page of Octave. At the time of writing (and this may change in the future) there is a native build for Windows, which seems to work without any issues in Windows XP and probably predecessors too. Scroll down to part which says: “The Octave Forge project hosts a native Windows binary distribution of Octave built with the MinGW compiler.”

This leads to Octave-Forge. Near the top of the page there is a “Windows installer (Octave and Octave-Forge)” listed. Now, download the file which is an executable (.exe) and run that. Follow the simple process of installation until completion and at the end ensure that Octave is installed and then listed among the programs in the Windows “Start” (now just Windows logo) menu. The main program is just called “Octave”. When it’s executed it offers a command line prompt which is the Octave interpreter. If everything works fine at this stage, then Octave runs properly and it is time to install the graphical wrapper, QtOctave.

Qt is a cross-platform graphical toolkit and a front end for Octave was written with it not so long ago. The main build is for GNU/Linux with tendency towards KDE, but there is also a Windows port and the one which works best can currently be found in outsch.org. There is a ZIP archive in there, so download it with caution (it is not an official source). Finally, uncompress the file and install it in a suitable location of choice on your hard-drive partition (e.g. C:). When all the files are extracted from the ZIP archive find the qtoctave executable (qtoctave.exe) under the directory containing the DLL files and the other binaries. If necessary, create a convenient shortcut to this file. Unlike UNIX-type environments, paths in Windows are not quite as universal, so QtOctave may not have anything defined regarding the location of the octave executable. Depending on where it’s installed, it may need to be entered manually, otherwise QtOctave will not be able to access the very core and engine of Octave. If that’s the case, go to the “Config” menu (top menu), then “general configuration” (menu item), then “Octave”, “Octave path”. Put in the text field the full path to the Octave executable where you had it installed earlier. This ensures QtOctave knows where to find it. Restart QtOctave (for settings changes to take effect) and once the program can detect the executable ensure it can provide a command prompt for .m files to be run or for commands to be entered manually. If needed, run a basic function like plot just to ensure that graphical units of Octave are also fully supported and installed without any conflicts. QtOctave comes with several units including an editor and it integrates quite well, including drag-and-drop support.

The point of this whole exercise is to liberate users whose personal programs that they write are stuck in the “MATLAB trap”, so to speak (like the old “Java trap”).

If you are interested in converting fellow staff and their students to Octave, remember that it suits an educational environment much better as it encourages sharing and collaborating, not asking for permissions, paying heavy fees/fines, and begging developers to fix bugs rather than have access to the source code, which in turn enables participation. Additionally, most of the basic functions are truly compatible with MATLAB’s and the lack of JIT optimisation, for example, should not matter much in an educational setting. Not many people create MATLAB GUIs either, so there is hardly a need for such advanced functionality. At a later date I hope to make some screencasts about Octave.

Trying Linux Mint for Running GNU Octave

FEDORA 14 is an adorable distribution, at least on the KDE (4.5) side of it. I only had problems in the repository and ones that were not truly Fedora’s fault. Image-related functions gave me a hard time in Fedora because of a known conflict and version numbers. It was not simple to resolve even after hours of trying. I consider myself to be an expert user (not guru) and unless I start compiling from source code as I did 5 years ago, Octave will be a challenge to use. Over on a Kubuntu machine I had no such issues. As the pictures below show, things worked perfectly well without any effort at all. Say what you will about Ubuntu GNU/Linux, but it does tend to work rather well.

Octave tagging - synthetic

Octave tagging

My goal is to do my entire daytime job under a true GNU/Linux/KDE experience with Gnash, no proprietary codecs, and even Konqueror (KIO/kio and sftp/ssh support make it indispensable) as the only Web browser along with Okular, LyX (not OpenOffice.org), and other great Qt/KDE SC programs. There are some limitations in use, but there are usually ways around those (although never as easy to install as Firefox extensions for example). In addition, advances in the Web itself can prove a tad tricky. The nature of the World Wide Web and the Web browsers which change over time is not predictable, so presentations that worked alright with background pictures in the past no longer appear correctly, unless the code is redone (I still use S5 for presentations. It is an excellent presentation tool I’ve used happily for over half a decade).

The main issue I’ve had with Fedora is to do with Octave, which I hope to replace MATLAB with. MATLAB was the last bit of proprietary software I was still using on GNU/Linux (since I began using GNU/Linux exclusively at work, around 7-8 years ago). The problem is not at all exposure to Windows or Mac OS; I never need those, but proprietary software in general is the problem here because of lock-in (practicality), which makes it not a purely philosophical argument.

After wasting many hours trying to get Octave to work the way I want and need it to work under Fedora 14 I decided to just virtualise another distribution under Fedora. The first thing which occurred to me is that VirtualBox was not available (see below).

No virtualbox

In the mean time I also decided to give Mint a go for the first time (I was curious after doing a special audiocast about it). That was a smooth experience luckily. Debian makes it daunting for one to download, so after a couple of minutes I left their Web site. Here’s Mint’s less-than-perfect download experience, assuming one particular route:

Mint download

Fedora makes it a lot more user-friendly when one downloads an ISO. There are usability issues here as most people cannot tell the difference between the different files.

To run it I needed a hypervisor and here is what Fedora had under the virtualisation category (descriptions would help enw users):

Fedora virtualisation

In summary, it is a bit of a shame that one needs to have those barriers; using Octave is not a case of using basic applications, but I was hopeful that Fedora would make it easy. I still reject MATLAB at all costs and I avoid installing it because Octave is doing almost everything that I need. In a future post I hope to write about Linux Mint.

Scilab in Fedora GNU/Linux

Having encountered problems with Octave in Fedora 14, I decided to explore scilab, which I wanted to try about a week ago anyway (and canceled the process after being warned that it was not as complete as octave, at least not for my needs). Fedora does not appear to have scilab in its repositories (Ubuntu on the other hand does have it). A yum and kpackagekit search around “scilab” yields nothing, so I went to the official scilab Web site and downloaded the latest package from that nice Web site, then uncompressed it. This was not the end of it as far as Fedora was concerned because, due to it not being available in the repositories, dependencies could not be resolved, so I needed to also install java manually, then figure out that SELinux was standing in my way. This is the type of thing which would deter new users and as much as I would love to endorse Fedora 14, it is experiences like this which leads me to saying that Kubuntu is still a better choice. Here is a self-explanatory story:

[roy@blueberry scilab-5.2.2]$ ls
ACKNOWLEDGEMENTS  CHANGES_3.X    CHANGES_5.2.X  lib            RELEASE_NOTES_5.0.X  thirdparty
bin               CHANGES_4.X    COPYING        license.txt    RELEASE_NOTES_5.1.X
CHANGES           CHANGES_5.0.X  COPYING-FR     README_Unix    RELEASE_NOTES_5.2.X
CHANGES_2.X       CHANGES_5.1.X  include        RELEASE_NOTES  share
[roy@blueberry scilab-5.2.2]$ cd bin/
[roy@blueberry bin]$ ls
intersci  modelicac  scilab  scilab-adv-cli  scilab-bin  scilab-cli  scilab-cli-bin
[roy@blueberry bin]$ ./scilab

Could not load JVM dynamic library (libjava).
Error: libjvm.so: cannot enable executable stack as shared object requires: Permission denied
If you are using a binary version of Scilab, please report a bug http://bugzilla.scilab.org/.
If you are using a self-built version of Scilab, update the script bin/scilab to provide the path to the JVM.
The problem might be related to SELinux. Try to deactivate it.

Scilab cannot open JVM library.
[roy@blueberry bin]$ su
Password: 
[root@blueberry bin]# yum install libjava
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Install Process
No package libjava available.
Error: Nothing to do
[root@blueberry bin]# yum install java
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.6.0-openjdk.i686 1:1.6.0.0-44.1.9.1.fc14 set to be installed
--> Processing Dependency: jpackage-utils >= 1.7.3-1jpp.2 for package: 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.fc14.i686
--> Processing Dependency: rhino for package: 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.fc14.i686
--> Processing Dependency: tzdata-java for package: 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.fc14.i686
--> Running transaction check
---> Package jpackage-utils.noarch 0:1.7.5-3.11.fc14 set to be installed
---> Package rhino.noarch 0:1.7-0.7.r2.fc12 set to be installed
--> Processing Dependency: jline for package: rhino-1.7-0.7.r2.fc12.noarch
---> Package tzdata-java.noarch 0:2010o-1.fc14 set to be installed
--> Running transaction check
---> Package jline.noarch 0:0.9.94-0.6.fc14 set to be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                     Arch            Version                            Repository        Size
=======================================================================================================
Installing:
 java-1.6.0-openjdk          i686            1:1.6.0.0-44.1.9.1.fc14            fedora            27 M
Installing for dependencies:
 jline                       noarch          0.9.94-0.6.fc14                    fedora            88 k
 jpackage-utils              noarch          1.7.5-3.11.fc14                    fedora            60 k
 rhino                       noarch          1.7-0.7.r2.fc12                    fedora           775 k
 tzdata-java                 noarch          2010o-1.fc14                       updates          151 k

Transaction Summary
=======================================================================================================
Install       5 Package(s)

Total download size: 28 M
Installed size: 84 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
updates/prestodelta                                                             | 248 kB     00:00     
Processing delta metadata
Package(s) data still to download: 28 M
(1/5): java-1.6.0-openjdk-1.6.0.0-44.1.9.1.fc14.i686.rpm                        |  27 MB     00:10     
(2/5): jline-0.9.94-0.6.fc14.noarch.rpm                                         |  88 kB     00:00     
(3/5): jpackage-utils-1.7.5-3.11.fc14.noarch.rpm                                |  60 kB     00:00     
(4/5): rhino-1.7-0.7.r2.fc12.noarch.rpm                                         | 775 kB     00:00     
(5/5): tzdata-java-2010o-1.fc14.noarch.rpm                                      | 151 kB     00:00     
-------------------------------------------------------------------------------------------------------
Total                                                                  2.2 MB/s |  28 MB     00:12     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : jpackage-utils-1.7.5-3.11.fc14.noarch                                           1/5 
  Installing     : jline-0.9.94-0.6.fc14.noarch                                                    2/5 
  Installing     : rhino-1.7-0.7.r2.fc12.noarch                                                    3/5 
  Installing     : tzdata-java-2010o-1.fc14.noarch                                                 4/5 
  Installing     : 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.fc14.i686                                 5/5 

Installed:
  java-1.6.0-openjdk.i686 1:1.6.0.0-44.1.9.1.fc14                                                      

Dependency Installed:
  jline.noarch 0:0.9.94-0.6.fc14                jpackage-utils.noarch 0:1.7.5-3.11.fc14               
  rhino.noarch 0:1.7-0.7.r2.fc12                tzdata-java.noarch 0:2010o-1.fc14                     

Complete!
[root@blueberry bin]# ./scilab

Could not load JVM dynamic library (libjava).
Error: libjvm.so: cannot enable executable stack as shared object requires: Permission denied
If you are using a binary version of Scilab, please report a bug http://bugzilla.scilab.org/.
If you are using a self-built version of Scilab, update the script bin/scilab to provide the path to the JVM.
The problem might be related to SELinux. Try to deactivate it.

Scilab cannot open JVM library.
[root@blueberry bin]# killall selinux
selinux: no process found
[root@blueberry bin]# ./scilab

Could not load JVM dynamic library (libjava).
Error: libjvm.so: cannot enable executable stack as shared object requires: Permission denied
If you are using a binary version of Scilab, please report a bug http://bugzilla.scilab.org/.
If you are using a self-built version of Scilab, update the script bin/scilab to provide the path to the JVM.
The problem might be related to SELinux. Try to deactivate it.

Scilab cannot open JVM library.
[root@blueberry bin]# ./scilab

This worked the second time only because I made SELinux more permissive, but this could have many users give up. Here is what I then got:

Scilab

As expected, there is no support for some fairly basic functions in scilab, which is not a complete octave replacement.

-->imshow('in')
             !--error 4 
Undefined variable: imshow

 
 
-->imread('in')
             !--error 4 
Undefined variable: imread

I do not want to install MATLAB or Fedora (although we do have an academic licence), but experiences with Fedora so far may drive me towards installing proprietary software or simply working from another box which happens to be better equipped and work perfectly well with Octave. That box runs Kubuntu.

Retrieval statistics: 21 queries taking a total of 0.089 seconds • Please report low bandwidth using the feedback form
Original styles created by Ian Main (all acknowledgements) • PHP scripts and styles later modified by Roy Schestowitz • Help yourself to a GPL'd copy
|— Proudly powered by W o r d P r e s s — based on a heavily-hacked version 1.2.1 (Mingus) installation —|