Introduction About Site Map

XML
RSS 2 Feed RSS 2 Feed
Navigation

Main Page | Blog Index

Archive for the ‘Programming’ Category

Search for Cardiac Analysis Code

During the holidays I decided to see what else is out there which is already free/libre software like my own work, which thus can be merged for comparative purposes. It would be valuable to have applied to my work some comparison to existing tracking algorithms which deal with cardiac images. A decade-old paper from Osman et al. covers the very popular HARP and states in its abstract that it offers an “image processing technique for rapid analysis of tagged cardiac magnetic resonance image sequences.[...] Results from the new method are shown to compare very well with a previously validated tracking algorithm.” It’s not easy to gain access even to code samples of complete frameworks that facilitate benchmarking, so the search ascended to SourceForge. I uploaded some projects of mine to SourceForge about 8.5 years ago and hoped that others would do the same. A search in SourceForge for “cardiac” yields about a dozen results (at the time of writing), but there are empty entries in the code repositories where there ought to be complete projects. The Cardiac MR toolbox for Matlab, for instance, is an empty project:

[roy@blueberry cmr-toolbox]$ svn co
https://cmr-toolbox.svn.sourceforge.net/svnroot/cmr-toolbox cmr-toolbox
Checked out revision 0.
[roy@blueberry cmr-toolbox]$ ls
cmr-toolbox
[roy@blueberry cmr-toolbox]$ cd cmr-toolbox/
[roy@blueberry cmr-toolbox]$ ls
[roy@blueberry cmr-toolbox]$

The same goes for Neonatal Rat Cardiac Action Potential, but the Evaluation of Cardiac MR Segmentation project (all of them written for MATLAB but ought to be compatible with Octave) contains some LGPL-licensed code. Repository access (SVN):

svn co https://cardiac-mr.svn.sourceforge.net/svnroot/cardiac-mr cardiac-mr

Looking at MATLAB Central for some more existing code I find an old BSD-licensed function but almost nothing else when searching for “Cardiac”. Since the literature review phase and the subsequent finding of some data [1, 2, 3] there has been almost no room for code reuse, so I had to code everything from scratch. I will soon publish the code (GPLv3-licensed), but in a more scientific society more code would have already been out there for others to collaborate and build upon the work of others.

Visual Tour of QtOctave

People who say that nothing can replace Photoshop and nothing can replace Microsoft Office simply forget that the functionality they must be implicily referring to is hardly used by anyone among the entire userbase. As pointed out in the previous post, two months with QtOctave and other free/libre software taught me that there is no reason to deny that ~90% of MATLAB’s users can abandon it and use free/libre software instead, maybe more happily in fact (stability, program weight, and cross-platform with access to the source code count, it’s not just a matter of cost). I have used some of the most advanced functionality in MATLAB, so I do know what I am talking about here.

Today I present free/libre software called QtOctave, which is a graphical front end to Octave and it uses Qt, as the name suggests. Qt is cross platform, so as expected it runs on Windows too. Without further ado, let’s take an overview of what QtOctave looks like. I typically put QtOctave on my eighth workspace in KDE, which helps me remember where to find it. Here is my workspace 8 (screenshot, click to magnify).

QtOctave

This picture may be daunting, but QtOctave does a good job hiding lot of the functionality under menus, which reduces clutter. QtOctave uses Octave (CLI) as its engine, but it provides a friendlier face to it. Let’s break down this picture and explain what each component does, in turn.

Menu

The main menu contains many of the basic functions one ought to expect. By “functions” what I mean is either functionality like opening files or mathematical functions that are commonly used. Many options there control the appearance of the GUI, whose core component of the command line containing the core, Octave. QtOctave wraps it up nicely and provides tools to work with/around it.

Menu in QtOctave

Variables

Octave exposes names and corresponding values of variables it holds, but only upon demand. How about having a GUI component to keep track of these and display this information all the time. You want it? You got it:

Variables

Commands and Dynamic Help

The command pane is a companion tool which helps keep track of recently-used commands and makes these conveniently available. In my case, I added the “Dynamic Help” component, to help show what commands are available as soon as I start typing. The contents in the example below show what appears in the window as soon as I began typing “plot”. The namespace of commands can be highly populated if many modules are used (in session’s path), so this is a good way to keep track without looking elsewhere. Bash has a similar functionality which it makes available via the “Tab” key.

Commands and Dynamic Help

Directories

Directories and files are sometimes easier to approach and navigate though when they are quickly accessible through the main GUI. This has use in all sorts of circumstances as drag-and-drop functionality is broadly supported.

Directories

Terminal

In the main body of the program there is the terminal section (or other components, if one chooses to make them available there). Show below is an example of basic interaction with Octave.

Terminal

CLI

The command-line interface is an integral part of the above and it supports up/down arrow key for use of commands history.

CLI

Editor Menu

This editor can be made part of the main windows, but it does not have to be. I personally choose to make it an external window on a second monitor where it offers a lot of viewing space. The menu has all one ought to expect to find in a standard text editor, but it also contains program-specific buttons like execution and debugging.

Editor Menu

Code

Here is a simple code example. The fonts that I use do not look good because I favour monospace, which helps indentation and other tasks where each character is treated as equal.

Code

Breakpoint

Here is another example of code (further down from the top). This helps show how breakpoints are represented in the editor. Together with the variables panel this provides an excellent environment for debugging, so the editor is definitely not detached from the core components; It’s custom-made for it.

Breakpoint

More Components

There is a lot more under the menus, e.g. package management (see the image below). But that’s a subject for another day.

Octave packages

If you like what you see in QtOctave, then consider giving Octave a look. Both Octave and QtOctave are in the *Ubuntu and Fedora repositories, so they only take a moment to install.

Heart Image Contouring

Today I implemented circular arrangement of landmark points for the algorithm to identify something approximate/similar to the shape of the heart and then place a given number of points around there. In addition, a boundary is shown by sampling between those points, which gives a contour, with or without arrows on top of it. I will upload the code shortly (needs tidying up).

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.

My Professional Focus and Goals in a Nutshell

Digital Control

I am not always a pessimist, but I do believe that in order to make positive progress we must concentrare on the illnesses and try to cure them. This is why most of my work at present revolves around advancing collaborative platforms like GNU/Linux (no tyranny on people’s desktops and servers). Sure, companies like Google and IBM make a lot of money out of the platform, but it does not take away from anyone else’s ability to use the same code. Overall, it leads to solidarity. Just watch how many companies jointly develop Linux (kernel space), including giants like AMD, Intel, and NVIDIA, which must play nice with the free graphics stack. A decade ago it was hardly conceivable, but here we are today with some truly powerful applications for GNU/Linux (some are still proprietary, especially games). It is exciting to see desktop environments like the K Desktop Environment (KDE SC) and GNOME desktop becoming highly competitive with whatever else is out there, proprietary included. LXDE and Xfce continue to serve an important role, especially in less capable PCs that rely on light-weight distributions. New releases of GNU/Linux come at a pace of about one per day and diversity continues to exist, with popular branches like the Mandrake/Mandriva family (with several derivatives), the Red Hat family (including Fedora), and the Debian family, which notably includes Ubuntu for the desktops (it has a huge number of variants).

The devices/embedded space is an area of considerable strength for Linux and sometimes GNU too. Phones are increasingly running Linux (with the industry’s leader, Nokia, among its biggest embracers, but Google’s Android is getting a lot more attention). Then we have sub-notebooks and tablets, many of which run Linux/Android. This is a triumph that almost nobody talks about. It also helped eliminate Microsoft’s margins in this area and got Apple so nervous that it decided to pathetically sue with software patents.

Sharing, Not Hoarding

Free software/Open Source is an even broader area where companies like Mozilla and projects like the Apache Web server show that technical merit is found in licences that encourage sharing. SaaS is increasingly a threat to software freedom, but it relies heavily on this software (databases, CMSs, etc.). Businesses increasingly adopt Free software, even though they typically call it “open source” (they are just allergic to the notion of “free”, perhaps still not realising that it’s about freedom, not cost). Funding for Free software continues to come as projects prove their worth to the market (MySQL for example) and BSD continues to evolve nicely along with GNU/Linux. Establishments like FSF/FSFE/SFLC provide a centre of power that is not driven by shareholders and GNU accommodates many important projects that are used by many millions (e.g. GRUB). Governments increasingly realise the importance of Free software licensing and openness of their data, which prevents perceptions of secrecy and thus corruption. Programmers increasingly teach themselves how to use languages and frameworks that put them in control, rather than put them in the hands of some ‘masters’ of a platform and an SDK/IDE. Applications that are free make up the ‘network effect’ that’s so crucial to the success of GNU/Linux and BSD. Almost anyone can now use a Free desktop without trouble (except for re-learning). Standards are promoted and made more prevalent as a result of Free software proliferation.

Addressing the Negatives

The revolution of Free software has wide-ranging effects on many other aspects of our lives. Science is enriched by it (increased sharing speeds up development), security is improved and surveillance gets reduced, the environment benefits from increased reuse of hardware components, and the financial market becomes more honest and transparent (e.g. for scrutiny before disaster strikes). The culture of AstroTurfing/lobbying is impeded by this culture of honesty and ethics; also, censorship is reduced, privacy honoured, and civil rights held up as more important and simpler to defend (no secrecy or conspiracy like ACTA or the Digital Economy Bill). The Internet becomes a more valuable resource (Wikipedia and Google are examples of valuable services), net neutrality is easier to defend (wireless meshes come to mind), and DRM becomes a relic from the past, much to the regret of the intellectual monopolies and copyrights cartel (which should not be allowed to exist in the first place).

In Defense of Sun Microsystems

I’ve given Sun a lot of pain because of their attempt to steal Linux’s thunder, but let’s never forget all the wonderful things they have given us — from OpenOffice.org to Java, which is now Free as in “free speech”.

Hopping on the “Open Source” Wave, Even If You Are Proprietary

Quanta Plus

THERE is an increasing number of companies which try to play the “source code” card when it fact they give nothing but binaries. This trend is worrisome. It is also disturbing because it adds ‘noise’ and makes it difficult to identify projects that are truly about collaborative development.

Here are some projects that thrives in Open Source status that is not truly deserved:

  • Coverity – brags detection of defects in Open Source code, but proprietary nonetheless.
  • Krugle – searches and indexes Open Source code, but if you talk the talk, you ought to walk the walk.
  • Google – Thrives in the use of Open Source software, but lacks transparency (APIs are no code).
  • Black Duck – verifies license compliance in open source projects, but still proprietary.

What does it all come down to? It’s nice when you speak about opening and sharing, but if your company only exploits this “Open Source” aura, then you can do more harm than good. Software opens up because it makes it better and development is sped up. Companies whose focus are other open source projects ought to realise this.

Retrieval statistics: 21 queries taking a total of 0.246 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 —|