Wednesday, December 2, 2009

Research systems with free software

I want to share with you research systems I have built using free and open-source software. My research is in analyzing magnetic resonance imaging (MRI) brain images. Your research will be different than mine but I think many of you can benefit from the same tools and systems.

My main research system is composed of the image processing tool ImageJ (, the relational database management system MySQL (, and the statistics and plotting tool R ( Additional software connects these tools into a system. The MySQL JDBC Connector ( allows ImageJ to store and retrieve data from MySQL. RMySQL ( allows R to access and display data stored in MySQL. Next I will demonstrate how this system works in my research and hopefully how they can help in yours.

ImageJ is an image processing graphical user interface (GUI) with many built in tools for reading, writing and manipulating images (Figure 1). ImageJ can handle the medical image DICOM format. In addition ImageJ provides a macro scripting tool for automating repetitive tasks and a Java programming library accessing all of ImageJ's features. New applications written using the ImageJ application programming interface (API) can either be plug-ins to ImageJ appearing in the ImageJ plug-in menu or they can be separate programs using only the parts of ImageJ needed. ImageJ provides image processing tools from easy to use GUI tools to an application programming library depending on your needs. This allows you to start using ImageJ for simple uses, write macros to automate task and then write your own programs as your research needs grow.

Figure 1. ImageJ image processing graphical user interface.

In my experiments I try image manipulations with many parameters. The parameters and experiment results and measurements are import to save for optimization. This normally means copying or typing them into a spreadsheet. ImageJ enables you to write plug-in dialog boxes to input the extensive parameters (Figure 2). The JDBC connector saves all the parameters to the MySQL relational database. The relation database allows you to query out just the parameters you want to see as seen in Figure 3. Querying data with the structured query language (SQL) provided by MySQL lets you see and focus on only the data you need and ask and answer questions on your data such as your subjects' average age, number of males and females or any other information recorded. Unfortunately if the data wasn't put in the database you cannot query the information out. So when developing a database application I try to record everything including things such as where the mouse was clicked on images. I will talk more on this level of detailed record keeping later.

Figure 2. Program parameters

Figure 3. Querying only the desired parameters from the database.

With ImageJ I was able to develop plug-ins that interact with the images. The ends of white line in the image below (Figure 4) were selected on the image with mouse clicks. The ImageJ plug-ins measures the twistedness of the line and radius of the artery at each point along the white line (Figure 5). I want to save the end points of the white measurement line and data on every point in the white line. The important point to take home is there is a vast amount of data to save per study subject and the database keeps all the data in an accessible format.

Figure 4. Image measurements.

Figure 5. Measurements are recorded to the database.

The database and SQL make it easy to get all the recorded data back in endless columns of data. To make sense of the data, I import the data into the into the statistics tool called R. R provides full statistical analysis tools and publication quality graph and plot production tools. Some examples are shown below (Figure 6). The RMyQSL package to R directly connects R to MySQL and R scripts can create plots like those in the images below in one step getting the latest data from the database.

Figure 6. Statistical analysis plotting and graphing with R.

The free software tools ImageJ, MySQL and R can be chained into a research data recording and graphical analysis system. There are several advantages to the system being built with free software. First it's free, you don't have to pay from the software. This becomes even more important than at first thought when you want to run the software on multiple computers. These software packages are also open-source. This is important because they have been compiled to run on almost every operating system and hardware platform including Microsoft Windows, Mac and Linux. This means you can have the same system on a Windows desktop computer, a Mac laptop for demonstrating your systems and research and multi-processor node Linux servers in high performance computing centers for heavy duty computation. You can distribute your system to users without them having to buy a license or run on multiple processors to speed processing times without worrying about having enough licenses.