/ xojo

Introducing DICOMKit

As a radiologist, I spend my working life interacting with medical images in the form of DICOM files through various software viewers. There are lots of improvements I’ve wanted to make to these viewers as well as other side project ideas I’ve had that would require reading / manipulating DICOMs. My favoured programming language is Xojo but this language provides no native way of reading DICOMs nor are there any available third party solutions to do so (at least at the time of writing). I decided that it would be a “good” idea to try to write my own module not only to achieve my goal of later using this module in future projects but also as a way to better understand the underlying software that powers my day-to-day life.

I call this module DICOMKit.

To say writing DICOMKit has been a challenge would be an understatement. The DICOM standard is very complex and the published documentation (whilst exhaustive) is not an easy read. There are a few open source projects out there in several languages (C, C++, Python, Javascript, to name but a few) but even perusing their source code is time consuming and, at times, infuriating. I have made sure that the source code for DICOMKit is extremely well (some might say excessively) commented throughout to allow others to learn from it.

At the time of writing, DICOMKit is capable of checking if a file is in the DICOM format, parsing it into its constituent elements and of extracting the image(s) stored within it as a Xojo Picture object. It currently only supports images stored in an uncompressed format although I do want to support other formats (mostly lossless JPEG and JPEG Baseline) in the future once I wrap my head around the decompression algorithms.

DICOMKit is 100% native Xojo code and does not require any third party dependencies, even though the project would progress faster with them. DICOMKit also compiles for all platforms supported by Xojo, including iOS and the Raspberry Pi.

It’s my intention to write a series of articles about the technical structure of DICOM files at some point in the future. I provide no time frame for this to happen.

Finally, whilst technically DICOMKit is open source, I’m not looking for it to be a truly collaborative project. I don’t mind you modifying or forking it and I do hope that you’ll find it useful and report bugs about them. At the same time I don’t plan on accepting patches for it. I prefer to keep things under my control and don’t have the time to worry about managing a burgeoning open source endeavour.

Of course, if there’s a patch or issue that needs to be fixed, as long as there is an understanding that I will re-implement any patch you send (which implies, among others, that you should explain what the patch’s code does) feel free to send it to me. However, I don’t promise that I’ll actually implement it. If I do decide to use it, it’ll be as a source of inspiration and a point of reference for the feature or bug fix that you need implemented.