Wednesday, March 30, 2011

DICOM and Silverlight

Since I would like to provide DICOM functionality in a Silverlight environment, I have examined whether there are any obvious libraries or tools available that would facilitate. Leadtools provide a DICOM Silverlight software development kit as a component in some of their commercial products, but so far I have not been able to identify any open source DICOM toolkit for Silverlight.

I have been using Colby Dillion's C# DICOM library mdcm for a while. This library provides all the DICOM functionality I have had the need for, but it has only been available for desktop applications until now.

However, I have started exploring whether the mdcm library can be sufficiently migrated to Silverlight. My continuous efforts can be followed here. At this stage I have made all shortcuts necessary to make the Silverlight class library build at all, and I have only included the most central parts of the original library. In due time I will fine tune the shortcuts to mimic the original library as much as possible, and I will try to add as many missing parts as I can.

It will be exciting to see if this effort can eventually result in a true open source alternative for DICOM functionality in Silverlight!

Tuesday, March 1, 2011

Units of Measure in C#: Introduction

F# provides the feature Units of Measure for sufficiently handling measurable entities of different units and quantities. Unfortunately this functionality is not accessible from the other .NET languages.

I have searched the internet for a similar solution in C#, but the approaches I have found so far have been relatively heavy-weight and not easily extendable. In particular, the measure type is generally implemented as a class with several members.

I would prefer a more light-weight solution where the measure type is implemented as a struct, preferably with a single member representing the measured amount in some reference unit for each specific quantity. At the same time I would like to have quantity type safety during compile-time, and it should the library should be easily extendable with new quantities and units without affecting the implementation of the measure type.

Based on these requirements, I have now implemented a compact C# Units of Measure library. I have implemented the library using the .NET 3.5 profile, and I have verified that it is possible to build under Mono (2.8 or later) as well. As far as I can tell, there is nothing preventing use of this library from other .NET languages either.

To facilitate feedback from other developers with similar requests, I have made the library available as open source (under the Eclipse Public License). The library is denoted csunits and is available on Github. A quick introduction to the API and instructions for extending the library are also provided on this web site.

I plan to continuously extend the library with new quantities and units, as well as add more functionality to it. In particular, I plan to implement a measure array type for efficient numerical handling of large number of measures in the same unit.

Any feedback on the library is more than welcome. Issues are preferably reported on the Github project web site, but comments to this blog post are perfectly OK as well :-) And ideas on how to further extend the library are of course very much appreciated.

Tuesday, October 5, 2010

IPOPT and F#

Theoretically, the C# interface that I developed for IPOPT should make it possible to access IPOPT from all .NET languages. To illustrate this, I recently implemented the basic HS071 example in C# and VB.NET versions.

As a proof-of-concept and as a first attempt to learn F#, I have now also implemented the HS071 example in F#. The F# source code can be found here. This is my first F# program ever, so I am sure it can be substantially improved. Nonetheless, it did compile and efficiently solved the HS071 example. Needless to say, I am pleased to have reached this far :-)

I have not yet packaged the F# example in a regular csipopt release, but the latest revision of the source code can be downloaded via a Subversion client. For further instructions, see this page.

Wednesday, May 26, 2010

IPOPT C# interface - now on Google code!

To make the C# interface to IPOPT more easily accessible, I have now created a code hosting project on Google Code, called csipopt.

After uploading the code, I also managed to solve one of the issues that I listed in the previous post, namely the inaccessibility of the log file.

Remains to be seen if the code hosting will enable further interest in the interface.

Thursday, May 20, 2010

IPOPT revisited

Why complicate things? In a few recent posts I outlined a way to use IPOPT from C#. To begin with, I created a DLL using MinGW and MSYS (described here), and I then called this DLL from C# using P/Invoke (here and here).

However, there is no need to build your own DLL, the considerate IPOPT maintainers have already done this for us! Pre-compiled DLL libraries (and include files for C/C++ users) are found here.

The binaries of the most recent IPOPT version (3.8.1), have been compiled with Visual Studio 2008 (C/C++) and Intel Fortran 8, if I understand correctly. As a test, I have taken the release version of Ipopt38.dll from the 32-bit distribution instead of the csipopt.dll I recently built, and called it from my C# interface. The new DLL works just fine, only faster...

I have noticed two issues, which I am yet to investigate further:

1. When using the debug DLL, I get an exception regarding the callback delegates. When using the release library, I do not encounter this problem. As far as I have been able to tell, data is consistently maintained throughout the optimization when using the release version.

2. The output file from IPOPT is inaccessible to other C# code, even after I have completed the optimization. I have not yet been able to determine if this is purely a timing issue, or if I am not releasing resources correctly in my C# interface.

Finally, I want to direct a sincere thank you to Ramnadh, who commented upon my first post on this matter, asking whether I had managed to build a corresponding DLL in Visual Studio. This comment lead me to looking at the pre-compiled binaries, which in the end turned out to be so successful. Thanks, Ramnadh!

Saturday, May 15, 2010

VODCA

When I participated in the Swedish Radiotherapy Physicists' meeting in Kalmar earlier this year, Alan Nahum talked about a software for collecting and analyzing large amounts of radiotherapy treatment and response data, which has been developed by former colleagues to Alan.

The software is denoted VODCA, and more information can be found here. Very interesting project, I will try to keep a close eye on this one.

Open source radiotherapy optimization

I have recently spotted an open source attempt on radiotherapy optimization, namely the PheonixRT project. Source code is available here, and a wiki page is available here.

In particular, I find the approach of using differential dose-volume histograms in the objective function interesting. I am not convinced that this approach is easily extended to pure dose-volume objectives (e.g. maximum 30% of the volume should receive 40 Gy or more). Nonetheless, I think it is worth to explore this approach further to see if it can lead to smoother objective function formulations.

The optimization method is patented. How well does this rhyme with providing the code as open source?