Thursday, March 26, 2009

SAMUCS Web DICOM Viewer

Hello Visitors,

I present you the Samucs Web DICOM Viewer approach. This is a software designed for DICOM image visualization. Since it's a web based program it runs entirely inside your web browser and also makes use of the power of Ajax and Java technologies that increase performance and portability, enhancing flawlessly the user experience.

It's the result of several days of hard work. Here I post the first version of the application for testing and feedback. In addition this software uses the powerful dcm4che toolkit - a collection of open source applications and utilities for the healthcare enterprise. These applications have been also developed in the Java programming, supporting deployment on JDK 1.4 and up.

Features included in this version:
- Remote AE title setup (PACS communication);
- Perform queries on Study, Series and Instance levels;
- Query by filter;
- Query and retrieve images for visualization (C-GET, C-MOVE);
- DICOM header viewer;
- Tools for zooming and image adjustments;
- Different layout views;

To start viewing images right now, first download Samucs Web DICOM Viewer. Then extract the samucs-web.rar to get a WAR file that must be deployed to a Web Server. So download the great Web Server Apache Tomcat. Also, the Java Runtime Environment (JRE) should be running properly on your computer. This application was tested only on Windows Vista environment using Internet Explorer 7 and Firefox 3.0, JRE 6 and Tomcat 6. I strongly recommend Firefox. Linux users I'll try this OS soon :)

The Tomcat install is quite intuitive, just follow the instructions and be sure to set port 8080 for Http. In the end you'll be asked to run Tomcat. Then open your web browser and access http://localhost:8080. If everything is ok you'll see the Tomcat management page. Then click the link Tomcat Manager on the top left corner below the Cat and enter the username and password saved during the installation. Now you are able to deploy the Web application to the server. Scroll down the page until you find the box WAR file to deploy and then select the downloaded WAR file. Finally click the button Deploy. It may be necessary to restart Tomcat before running the application.

That's it! Access http://localhost:8080/samucs-web to begin the new DICOM visualization experience. The default username and password is samucs/samucs. I appreciate your feedback.

Screenshots:






Enjoy :)

Kindly regards,

Samuel.

Tuesday, March 17, 2009

Listing DICOM Header information with dcm4che 2

Hi All,

Some readers have asked me questions regarding how to access DICOM header information by DICOM Tag parameters. On this post I present you a quick tutorial on how to list all header information, including the Tag value, VR (value representation), Tag description, and the values of each field using the great dcm4che 2 toolkit.

(0008,0005) [CS] Specific Character Set [ISO_IR 100]
(0008,0008) [CS] Image Type [ORIGINAL]
(0008,0016) [UI] SOP Class UID [1.2.840.10008.5.1.4.1.1.2]
(0008,0020) [DA] Study Date [20040827]
(0008,0021) [DA] Series Date [20040827]
(0008,0022) [DA] Acquisition Date [20040827]
(0008,0023) [DA] Content Date [20040827]
(0008,0030) [TM] Study Time [100357.953000]
(0008,0031) [TM] Series Time [100607.062000]
(0008,0032) [TM] Acquisition Time [100622.688476]
(0008,0033) [TM] Content Time [100622.688476]
(0008,0050) [SH] Accession Number [null]
(0008,0060) [CS] Modality [CT]
(0008,0070) [LO] Manufacturer [SIEMENS]

Like the previous posts, we start coding a simple class with the default constructor. Let's name it ListDicomHeader.


public class ListDicomHeader {

public ListDicomHeader() {
// TODO Auto-generated method stub
}

public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

The next step is to code the method responsible for extracting the header info. Note that this method is recursive. This is done because some DICOM files bring encoded Items that may hold other DICOM objects denoted by de value representation SQ. So, we are handling also sequence information with this code. The method is written as follows:


public void listHeader(DicomObject object) {
Iterator iter = object.datasetIterator();
while(iter.hasNext()) {
DicomElement element = iter.next();
int tag = element.tag();
try {
String tagName = object.nameOf(tag);
String tagAddr = TagUtils.toString(tag);
String tagVR = object.vrOf(tag).toString();
if (tagVR.equals("SQ")) {
if (element.hasItems()) {
System.out.println(tagAddr +" ["+ tagVR +"] "+ tagName);
listHeader(element.getDicomObject());
continue;
}
}
String tagValue = object.getString(tag);
System.out.println(tagAddr +" ["+ tagVR +"] "+ tagName +" ["+ tagValue+"]");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Looking at the code, first we get an iterator to go through our DICOM dataset. Then we code a while loop to get each DICOM element present in the header. At each iteration a new DicomElement is kept so we can access its values. The tag variable holds the current Tag value. From then on there are some useful functions that may help us a lot. We can use the nameOf method from DicomObject class to get the Tag description as a String. I also suggest you to have a look at the TagUtils class for other great functions. The vrOf function will return the value representation to the current element.

Then comes the recursive part. We test the VR to see if it's a sequence (SQ), if so then we check if this element has any Items. Then if the answer is true we get the new object and call the listHeader function again, starting the recursive loop. Each iteration then prints out the desired information.

Finally, to test this program we must a main method for this class. The method may be written as follows:


public static void main(String[] args) {
DicomObject object = null;
try {
DicomInputStream dis = new DicomInputStream(new File("c:/image.dcm"));
object = dis.readDicomObject();
dis.close();
} catch (Exception e) {
System.out.println(e.getMessage());
System.exit(0);
}
ListDicomHeader list = new ListDicomHeader();
list.listHeader(object);
}


That's it! Now we have a lot of information from our DICOM file header! Enjoy :)

Best regards,

Samuel.