Thursday, February 19, 2009

Multiframe DICOM to Flash video

Following with the series of articles dealing with web based visualization of DICOM images, we are going to ilustrate a way of viewing multiframe ultrasound DICOM images.

As in the previous article, we have used just open source software for every action or transformation carried out.

This solution appeared in one ocasion when we were looking for a quick solution to share some cardiology studies among cardiologists. We wanted a solution with minimal software requirements, and fully multiplatform, in order to ease and promote the migration to open source workstations in public healthcare organizations.

One of the goals was to preserve the original quality of the contents, so we should preserve the original frame rate of the sequence as well as the original image quality (lossless transformations).



1.- The first step is to extract individual frames of the multiframe object. This step can be done using the dcmtk tools.

$ dcmj2pnm +Fa +ob multiframe.dcm /tmp/multiframe_


Use the +o modifier to indicate the output format. +ob to generate BMP, +on to generate PNG (You can test other available formats, but be careful to avoid loosy formats, such as Jpeg)

2.- Optional step: Obtain the frame-rate if you want to maintain the original values. I am not sure if the video format used (.flv) has a maximum allowed frame rate (59.94 is mentioned in some sites). O the other side, you will need a powerfull machine if you want to display the output at such high framerates. Anyway, you can alway create a slow motion version of the original content using lower framerates. If you choose this option, you must inform the user about the variation with respect to the original content.

$ dcmdump +P "0018,0040" multiframe.dcm


3.- Once you have done the extraction of the frames, you should convert the set of images to the desired video format (.flv in this example). We have tested with ffmpeg and mencoder. Both of them have their own advantages and limitations. Be sure to have the necessary codecs (flv) installed on your system.

Example 1: Assuming a framerate of 30 fps, bmp frames, and maintaining the original size (800x564 in our case).

$ ffmpeg -r 30 -i /tmp/multiframe_.%d.bmp -f flv -s 800x564 -sameq -an -r 30 multiframe.flv


Example 2: If you prefer to try with mencoder (png frames, 30 fps):
$ mencoder "mf:///tmp/multiframe_.%d.png" -mf fps=30:type=png -ovc lavc -lavcopts vcodec=flv -o multiframe.flv


Below, there is just an illustrative video, but you can see the full quality DICOM multiframe ultrasound video.

Saturday, February 14, 2009

Flash DICOM viewer

Some days ago, I passed the mark of seven years working in the field of healthcare related software. Due to the fact of working in this area, I have had the opportunity to learn about some topics and concepts that otherwise could remain just unknown for me. One of the topics that I find of particular interest is that related to medical imaging.

There has been a huge work during many years in order to create a standard for medical imaging. The result of such work is DICOM. At the begining most manufacturers preferred to tie their clients by the use of propietary and closed formats. Fortunately, in the last years most manufactures have chosen to follow the standards (with more or less success) opening a very interesting field for software development related to medical imaging.

One of the difficulties when dealing with DICOM imaging is the fact of having many differences compared to other image formats. In general, we can not use tools intended for other kind of images (such as those coming from digital cameras) to work with DICOM medical images.

The manufacturers of hardware equipment for medical imaging acquisition do usually provide their own diagnostic stations with specialized software, so the doctor (radiologist, cardiologist) can interpret the images.

Apart from the main diagnostics stage, it is often interesting to distribute images along with the medical report. If a doctor has derived a patient to radiology, the doctor would appreciate the inform with the results being attached to some key images. Given the fact that the medical data is evolving in order to replace the traditional paper by electronic reports, it becomes a necessity to provide remote access to medical imaging.

So, we can distinguish two kind of viewers: Diagnostic viewers, intended for those practicians that should emit a diagnostics from the examination of the image, and simplified viewers, intended just to allow the possibility of viewing the relevant imaging data, acting as a complement to the medical report.



If we want to achieve a fast and efficient deployment of an imaging viewing solution, we must consider a web based DICOM viewer. Since we are not dealing with simple imaging formats, we must consider environments able to act as RIAs (Rich Internet Applications), and that narrows a lot the available options.

For the development of a web based DICOM viewer, we can consider the following frameworks:
  1. DHTML: javascript, DOM, ...
  2. ActiveX
  3. Silverlight / Moonlight
  4. Java: In the form of Java Applet (browser embedded), Java Web Start applications or the new Java FX platform.
  5. Flash based viewer
Let us see the advantages and limitations of every possible option:
  1. The first option may have limitations in order to manage and being able to perform some tasks in DICOM images, such as lightning or darkening images.
  2. The second option (still adopted by many manufactures) has not ever been considered in our case, since one of the goals is to achieve a real multiplatform solution. That is a real must if we consider the fact that many public administrations and healthcare departments are migrating their systems to Linux based stations.
  3. The third one is something that deserves to be tested. If it is a real multiplatform environment, that can be an option for development of a web DICOM viewer in the form of a RIA.
  4. The option number four sounds really good. In fact a Java Web Start DICOM viewer would be a killer app in this field.
  5. The fifth option sounds good, but Flash (Actionscript) has many differences compared to Java: May be it is more limited as a programming language, but has many possibilities regarding the user interface and to present information to the user. We have chosen to start working in Flash, just to test what we can achieve.
Our first development was Stratos-viewer, a simple flash based DICOM viewer, but powerful enough in the cases where no advanced utilities were necessary. An online demo of the viewer is available.



Addendum (2009/02/18):
References to other flash based DICOM viewers: