GDCM (Grassroots DICOM)

repository·master·Indexed 16 days ago

https://github.com/malaterre/gdcm

A robust, cross-platform library and set of tools for handling DICOM files. It includes command-line utilities such as gdcmdump, gdcminfo, and gdcmconv, as well as support for DICOM Media Storage, UL protocol PDUs, and vendor-specific data dictionaries. The project provides a Python-based WADO server called CherryWado and a PHP extension, utilizing CMake for builds and Doxygen for documentation.

Tokens
6.7K
Snippets
15
Records
46
Agent score
62%

What's inside GDCM

  1. Overview of the gdcmcharls subset

    master

    The gdcmcharls directory contains a subset of the CharLS project, specifically optimized for the JPEG-LS standard (ISO-14495-1/ITU-T.87). CharLS provides an optimized implementation for lossless and near-lossless image compression, designed to match JPEG 2000 compression ratios while maintaining low complexity and high speed.

    Note that this directory only includes the src/ subdirectory and the original cmakelists.txt required to build the CharLS library. Windows-specific compilation files have been removed.

  2. Overview of gdcmzlib

    master

    The gdcmzlib directory contains a customized subset of the zlib library (version 1.3.2). It includes only the specific functionalities required by GDCM. This version includes custom modifications to the original zlib code to support GDCM's requirements.

    To identify specific modifications made to the original zlib source, search the codebase for the string GDCM_ZLIB_CHANGE.

  3. Overview of the gdcmopenjpeg utility

    master

    The gdcmopenjpeg directory contains a subset of the OpenJPEG project, specifically the components required to build the openjp2 library. OpenJPEG is an open-source JPEG 2000 codec written in C, recognized by ISO/IEC and ITU-T as JPEG 2000 Reference Software.

    GDCM includes a modified version of the OpenJPEG distribution to ensure compatibility within the GDCM build system, including:

    • A subset of the original source focused on the openjp2 library.
    • Modified CMake configurations to resolve directory issues.
    • A symbols mangling mechanism to prevent naming conflicts.
  4. Overview of gdcmjpeg (libjpeg subset)

    master

    The gdcmjpeg directory contains a specialized subset of the Independent JPEG Group's (IJG) libjpeg version 6b. It is specifically modified to support the various JPEG compression types found in DICOM implementations, including support for 8-bit, 12-bit, and 16-bit data precision.

    Key characteristics:

    • Build System: Uses CMake instead of the standard libjpeg build process.
    • No Standard Executables: Unlike a standard libjpeg distribution, this does not include cjpeg, djpeg, etc.
    • Bit-Depth Support: Supports 8, 12, and 16-bit libraries through build-time modifications.
    • Name Mangling: Uses specific header files (gdcm_mangle_8bits.h, gdcm_mangle_12bits.h, and gdcm_mangle_16bits.h) to allow multiple bit-depth versions of the library to coexist.
  5. Overview of GDCM Applications

    master

    GDCM includes several command-line applications for inspecting and manipulating DICOM files. These tools follow a naming convention similar to TIFF utilities (e.g., tiffinfo, tiffdump).

    Key applications include:

    • gdcmdump: Used for dumping the contents of a DICOM file.
    • gdcminfo: Used for retrieving information about a DICOM file.
    • gdcmconv: Used for converting DICOM files (e.g., handling specific modalities or file formats to ensure compatibility with other viewers like dciodvfy).
  6. Understand the GDCM Data Dictionary XML structure

    master

    The GDCM Data Dictionary is implemented using XML files that define DICOM attributes and vendor-specific private dictionaries. The dictionary includes standard DICOM definitions (dicom3.xml) and various vendor-specific dictionaries (e.g., acuson.xml, siemens.xml, philips.xml).

    Key Design Constraints for XML Attributes:

    • The name attribute in a public or private element must be a single line. It cannot contain whitespace characters such as \t, \n, or \r.
    • This constraint ensures compatibility with GUIs and prevents the need for complex multi-line string traversal when reading attribute names.
  7. Understand DICOM Media Storage and File Format concepts

    master

    The DICOM Media Storage Model defines how data is organized and exchanged across different layers to ensure interoperability. Key abstractions include:

    • DICOM File: A file containing a mandatory File Meta Information header followed by a properly formatted Data Set.
    • File-set: A collection of DICOM Files (and potentially non-DICOM files) sharing a common naming space where File IDs are unique.
    • DICOMDIR File: A mandatory file within a File-set that contains the Media Storage Directory SOP Class. It is identified by the File ID DICOMDIR.
    • Application Profiles: Specific selections of choices at various layers of the Media Storage Model intended for specific interchange contexts.
    • Media Storage Services: Operations defined to facilitate the storage and retrieval of DICOM SOP Instances from media.
    • Secure DICOM File: A DICOM File encapsulated using Cryptographic Message Syntax (RFC 2630).
  8. Identify File-set roles (Creator, Reader, Updater)

    master

    In the context of a DICOM File-set, different Application Entities (AE) perform specific roles:

    • File-set Creator (FSC): An AE that creates the DICOMDIR file and zero or more DICOM Files.
    • File-set Reader (FSR): An AE that accesses one or more files within a File-set.
    • File-set Updater (FSU): An AE that accesses files, creates new files, or deletes existing files. An FSU is responsible for updating the DICOMDIR file to reflect any additions or deletions in the File-set.
  9. Understand the DICOM UL protocol PDUs

    master

    The DICOM Upper Layer (UL) protocol is composed of seven distinct Protocol Data Units (PDUs) used for message exchange. These PDUs manage association requests, data transfer, and release/abort procedures.

    The seven PDU types are:

    • A-ASSOCIATE-RQ: Association Request
    • A-ASSOCIATE-AC: Association Accept
    • A-ASSOCIATE-RJ: Association Reject
    • P-DATA-TF: Protocol Data Unit (Data Transfer)
    • A-RELEASE-RQ: Release Request
    • A-RELEASE-RP: Release Response
    • A-ABORT: Abort
  10. DICOM UL PDU encoding and byte ordering

    master

    DICOM UL PDU headers use Big Endian byte ordering for consistency with OSI and TCP/IP environments.

    Important distinction: While the PDU headers follow Big Endian ordering, the encoding of the actual PDV (Protocol Data Value) message fragments is determined by the Transfer Syntax negotiated during the association establishment.

    Encoding rules for PDUs:

    • Byte numbering: Bytes are numbered sequentially starting from 1 (lowest byte number).
    • Bit numbering: Bits within a byte are numbered 7 to 0, where bit 0 is the low order bit.
    • Strings: In consecutive bytes representing characters, the lowest byte number represents the first character.
    • Binary numbers: In consecutive bytes representing binary numbers, the lower byte number holds the most significant value.
    • Transport order: The lowest byte number is placed first in the transport service data flow.
  11. Configure bit depth for gdcmjpeg

    master

    The bit depth of the generated JPEG library is controlled during the build process via the jmorecfg.h file. The placeholder @GDCM_BITS_IN_JSAMPLE@ is automatically replaced during the build to define the precision.

    To generate a specific library, the build system modifies jmorecfg.h to set the BITS_IN_JSAMPLE macro to either 8, 12, or 16.

    /* From jmorecfg.h */
    #define BITS_IN_JSAMPLE @GDCM_BITS_IN_JSAMPLE@
  12. Build GDCM using CMake

    master

    GDCM uses CMake as its build system. This allows for transparent generation of build files for various platforms and IDEs, including:

    • Unix Makefiles
    • NMake Makefiles
    • Visual Studio (VS8/9/10) Solutions
    • Xcode projects

    To ensure stability when using the bleeding edge of the source code, you can check the GDCM CDash dashboard to see if your specific platform is 'green' (passing all tests) before compiling.

    # Note: The README mentions CMake is used for the build process, but does not provide a specific command-line sequence. Typically, this involves:
    cmake .
    cmake --build .