15.12.2012 Views

Digital Imaging and Communications in Medicine (DICOM)

Digital Imaging and Communications in Medicine (DICOM)

Digital Imaging and Communications in Medicine (DICOM)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

326<br />

Chapter 16 <strong>DICOM</strong> Software Development<br />

but it clearly has noth<strong>in</strong>g to do with <strong>DICOM</strong> software design. And although<br />

need<strong>in</strong>g a <strong>DICOM</strong> file opener is the most common reason for start<strong>in</strong>g <strong>DICOM</strong><br />

development, it is also the worst one. You th<strong>in</strong>k small, you neglect the entire<br />

structure of the <strong>DICOM</strong> st<strong>and</strong>ard, <strong>and</strong> your partial success can create an illusion<br />

of do<strong>in</strong>g it right. I really hope that after read<strong>in</strong>g most of this book you<br />

realize that the <strong>DICOM</strong> st<strong>and</strong>ard exp<strong>and</strong>s much farther that your simple MR<br />

file viewer, even if the latter opens all files from your MR scanner. As a result,<br />

the more files you try to open, the more disappo<strong>in</strong>t<strong>in</strong>g surprises <strong>and</strong> failures<br />

you will experience, constantly runn<strong>in</strong>g <strong>in</strong>to unknown pixel representations,<br />

compressions, <strong>and</strong> IODs.<br />

In short, you will have to discover the <strong>DICOM</strong> st<strong>and</strong>ard empirically by<br />

learn<strong>in</strong>g from your own mistakes. This is the most <strong>in</strong>efficient way of master<strong>in</strong>g<br />

someth<strong>in</strong>g as complex <strong>and</strong> evolv<strong>in</strong>g as <strong>DICOM</strong>. In fact, by the time you make<br />

your next discovery, the actual items <strong>in</strong> <strong>DICOM</strong> <strong>and</strong> everywhere around you<br />

could change. You will never catch up.<br />

So, if you “just need to open this <strong>DICOM</strong> file”, use Matlab, Analyze, or some<br />

free <strong>DICOM</strong> file viewer to solve your problem <strong>in</strong> a matter of m<strong>in</strong>utes <strong>and</strong> not<br />

days. Be practical.<br />

16.3<br />

Implement<strong>in</strong>g <strong>DICOM</strong><br />

If you have decided to move forward <strong>and</strong> implement <strong>DICOM</strong> software, <strong>and</strong> not<br />

for a small transient need, I respectfully salute you. Go ahead <strong>and</strong> start from<br />

this book; it was written for you. Read Chap. 5, <strong>and</strong> while read<strong>in</strong>g it, try to<br />

build a clear object-oriented design of your <strong>DICOM</strong> implementation. If I were<br />

you, I would consider each of the follow<strong>in</strong>g guidel<strong>in</strong>es carefully:<br />

1. Implement a class for the b<strong>in</strong>ary buffer, pay<strong>in</strong>g particular attention to efficient<br />

memory allocation <strong>and</strong> cleanup. Remember, <strong>DICOM</strong> reads, writes, <strong>and</strong> processes<br />

all its data as sequences of b<strong>in</strong>ary bytes, <strong>and</strong> this class will be responsible<br />

for the efficient management of all your <strong>DICOM</strong> data (Fig. 94). Include<br />

functions such as Big/Little Endian byte swapp<strong>in</strong>g <strong>and</strong> read<strong>in</strong>g/writ<strong>in</strong>g to a<br />

file/socket. You can also use a buffer class to implement text str<strong>in</strong>gs; <strong>and</strong> if<br />

you choose to do so, implement <strong>DICOM</strong> wildcard str<strong>in</strong>g match<strong>in</strong>g.<br />

2. Implement VR as the ma<strong>in</strong> data type (class), as shown on Fig. 95. The ma<strong>in</strong><br />

work <strong>in</strong> a VR class is to code functions to read/write data <strong>in</strong> all possible <strong>and</strong><br />

popular formats. For example, time <strong>in</strong> various versions of <strong>DICOM</strong> can be<br />

written as HHMMSS, HH.MM.SS, or HHMM, <strong>and</strong> it is good to make your<br />

VR aware of all of this. Then add implicit/explicit VR encod<strong>in</strong>g as read<strong>in</strong>g/<br />

writ<strong>in</strong>g encoded VR data to b<strong>in</strong>ary buffers.<br />

3. Ensure that all <strong>DICOM</strong> attributes (data elements) become <strong>in</strong>stances of your<br />

VR class.<br />

4. Implement the <strong>DICOM</strong> Data Dictionary as a VR hash table. Pay special attention<br />

to its performance: search<strong>in</strong>g the dictionary by (group, element)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!