Building a DICOM Library in C# v2

advertisement
DICOM INTERNATIONAL
CONFERENCE & SEMINAR
Oct 9-11, 2010
Rio de Janeiro, Brazil
Building a DICOM Library
in C#
Victor Derks
GE Healthcare
Contents
Introduction
Design Goals
Inception
Approach and Effort
Design Challenges
Character Encoding
DICOM C-STORE on a Wide Area Network (WAN)
DICOM Operations on a Wide Area Network
Conclusions
Recommendations
Introduction
Microsoft .NET Platform Group within GE Healthcare
– Provide Microsoft .NET components to applications
teams
– Internal DICOM library is a one of these components
– The preferred programming language of our group is C#
Design Goals
Requirements:
– DICOM File I/O
– DICOM Communication
Focus Areas:
– Internationalization
– Service Oriented Architecture
– Easy to use for C# programmers
Inception
Started in 2007 building prototypes:
– Wrap existing C++ internal implementation in .NET layer?
– Create new C# implementation?
Findings:
– .NET \ C++ Memory Management Models are conflicting
– Mixed solution doesn’t work well due to high interaction
between the layers
– No option to leverage new .NET patterns:
• Asynchronous Programming Model
• Thread pool
Approach and Effort
Test Driven Development (TDD):
– DICOM Standard defines expected behavior
– 50% of these unit tests check for bad cases
– About 2000 unit tests
Name
GE DICOM Library (C#)
Lines Of Code
34,637
Lines Of Test Code
33,707
Comparable Open Source:
ClearCanvas (C#)
87,738
Dcm4che 2.0.24 (Java)
40,954
PixelMed 20100912 (Java)
86,864
Note: Lines Of Code counted with CLOC 1.52. Average is 60 K Lines.
Design Challenge 1:
Character Encoding
DICOM Character Sets
• Originally only support for ASCII (IR-6)
• 1993: Latin 1\2\3\4\5, Arabic, Hebrew, Cyrillic,
Greek, Japanese,..
• 1999 \ 2000: Thai, Korean
• 2003: UTF8 (ISO_IR 192), but this is an option
• Most modern applications use internally UTF16
Unicode strings (C++ \ .NET \ Java)
• .NET provides standard text encoders:
– UTF8
– Many code page based encoders
Text Conversions
Input (decoding)
Read and convert DICOM text values to .NET strings.
DICOM
values
decode
.NET
Strings
encode
DICOM
values
Output (encode)
Many use cases require text updates to the DICOM data.
For example Patient Information Reconciliation.
Output would be easy if all DICOM systems would support
UTF8…
Legacy
Character Set Encoding
Steps needed to serialize DICOM text data to an
output device that doesn’t support UTF8
– Application needs to define encoding method
– Application needs to define allowed character sets and
preferred order
– Library needs to scan all characters
– Library computes required character sets and serialize
data
Recommendation: design / use systems that
support UTF8
Design Challenge 2:
DICOM C-STORE on a
Wide Area Network
C-STORE on a WAN: Intro
• Historically most DICOM communication
is on a local network
• Trend is to store images in regional and
national DICOM data centers
• Wide Area Network (WAN):
– Bandwidth: 1 Mbit/s up to 1 Gbit/s
– Round Trip Time (RTT) : 10 ms up to 1 s for satellite
connections
C-STORE Example
Example:
Sending a study of 2000 compressed instances of
125 Kbyte on a local network
– Bandwidth = 100 Mbit/s, Round Trip Time = 1 ms,
– N * (Tx + Trtt) = 27 seconds
Sending same study on a Wide Area Network
– Bandwidth = 100 Mbit/s, Round Trip Time = 200 ms,
– N * (Tx + Trtt) = 425 seconds
425 seconds vs 27 seconds: 15 times slower!
C-STORE on a WAN:
Root Cause
1
Local:
WAN:
92 %
1
6%
Solutions (within the Standard):
– Open more connections
– Supports DICOM Asynchronous Operations (PS 3.7
Annex D.3.3.3)
C-STORE on a WAN:
Solution
9
8
7
6
5
4
3
1
2
99 %
Transmission time: (N * Tx)+ Trtt = 25 seconds
• Both DICOM systems need to support
asynchronous operations
• Maximum number of pending requests is 65536
• Responses can arrive out of order
Design Challenge 3:
DICOM Operations on a
Wide Area Network
DICOM Operations
on a WAN
• Same WAN sample configuration:
– Round Trip Time = 200 ms
– Secure DICOM (TLS)
• Connection Establishment is slow
Name
Time
TCP / IP Handshake
200 ms
TLS / SSL Handshake
400 ms
DICOM Handshake
200 ms
DICOM Request \ Response
200 ms
• TCP / IP Protocol: slow start algorithm
DICOM Association pool
• Pooling is automatic
• Pool will reuse a suitable open association
• If no association available, pool will open a new
association
• Auto learning which presentation contexts are
required
• Number of open associations is managed
• Associations are closed after idle timeout
• Compatible with Asynchronous Operations
• CP-948: C-STORE sub operations (Std 2008)
Conclusions
• Conclusions
– Having a GE DICOM library in .NET allows us
to quickly adapt to changes in the Standard.
– We have seen good performance
– .NET provides a rich set of libraries which
makes it relatively easy to develop DICOM
applications
Recommendations
• Recommendations
– Use the Microsoft .NET Guidelines to ensure
a library is consistent with .NET (FxCop)
– Use UTF8 as the default character encoding
• Great if DICOM Standard would make this required
in the future (roadmap)
– To be Internet / Wide Area Network ready:
• Support Asynchronous Operations
• Support re-use of open DICOM associations
Questions \ Perguntas
Questions ?
Contact
victor.derks@ge.com
http://groups.google.com/group/comp.protocols.dicom
Download