DICOM-rs

repository·master·Indexed 20 days ago

https://github.com/enet4/dicom-rs

A pure Rust implementation of the DICOM standard providing libraries and tools for reading, writing, and interacting with DICOM objects. The ecosystem includes the foundational dicom-core and dicom-encoding crates, the dicom-dictionary-std standard dictionary, and various CLI tools such as dicom-dump for file inspection, dicom-echoscu for node verification, dicom-findscu for archive searching, and dicom-fromimage for creating DICOM files from images.

Tokens
106.1K
Snippets
319
Records
436
Agent score
66%

What's inside dicom-rs

  1. Overview of the DICOM upper layer (dicom-ul) crate

    master

    The dicom-ul crate provides an implementation of the DICOM upper layer protocol. It contains the necessary types and methods to interact with DICOM nodes. Developers can use this crate as a foundation for building finite-state machines and higher-level helpers to create concrete Service Class Users (SCUs) and Service Class Providers (SCPs).

    Key features include:

    • Support for DICOM upper layer protocol interactions.
    • TLS support for secure transport connections via rustls.
    • It is available as a standalone crate (dicom-ul) or contained within the parent dicom crate for convenience.
  2. Use the DICOM-rs `parser` for token-based DICOM processing

    master

    The dicom-parser crate provides a middle-level abstraction for parsing and printing DICOM data sets. Unlike the higher-level dicom-object API, dicom-parser works through a sequence of tokens. This makes it suitable for low-level manipulation or streaming-style processing where you need to traverse the DICOM structure via tokens rather than working with a fully materialized object model.

    If you require a higher-level, object-oriented API for interacting with DICOM data sets, use the dicom-object crate instead.

  3. Use the dicom-dictionary-builder CLI

    master

    The dicom-dictionary-builder is a command-line tool used to generate machine-readable attribute dictionaries (tags and UIDs) from the DICOM standard. It currently supports parsing .dic files from the DCMTK project.

    Available commands:

    • data-element: Fetch and build a dictionary of DICOM data elements (tags).
    • uids: Fetch and build a dictionary of DICOM unique identifiers.
    • help: Print help information.
    DICOM dictionary builder
    
    Usage: dicom-dictionary-builder <COMMAND>
    
    Commands:
      data-element  Fetch and build a dictionary of DICOM data elements (tags)
      uids          Fetch and build a dictionary of DICOM unique identifiers
      help          Print this message or the help of the given subcommand(s)
    
    Options:
      -h, --help  Print help
  4. Use DICOM-rs `encoding` for data encoding and decoding

    master
    The dicom-encoding crate provides the fundamental primitives required for encoding and decoding DICOM data. It is a sub-project of the main dicom crate. To use these primitives, you should include the parent crate dicom in your dependencies, which contains dicom-encoding.
  5. Use `dicom-findscu` to search DICOM archives

    master

    The dicom-findscu tool is an implementation of the DICOM Find SCU (C-FIND) used to search for study and patient records in a DICOM archive.

    It supports three Query/Retrieve Information Models:

    • -S: Study Root Query/Retrieve Information Model – FIND (default)
    • -P: Patient Root Query/Retrieve Information Model - FIND
    • -W: Modality Worklist Information Model – FIND (or --mwl)

    To use the tool, you must specify the Application Entity (AE) and its address in the format AE_TITLE@hostname:port (e.g., PACS@pacs.example.com:1045).

    dicom-findscu PACS@pacs.example.com:1045 --patient
  6. Use the DICOM-rs standard dictionary

    master
    The dicom-dictionary-std crate provides the standard DICOM data dictionary. It is built using entries generated by the dictionary_builder crate. This crate is a sub-project of the main dicom crate and is used to provide standard DICOM tag information and metadata within the DICOM-rs ecosystem.
  7. Use the `dicom-object` crate for high-level DICOM manipulation

    master
    The dicom-object crate (contained within the parent dicom crate) provides a high-level abstraction for working with DICOM objects. It allows you to retrieve DICOM objects from files or any type implementing the std::io::Read trait. Once loaded, DICOM objects can be analyzed and navigated as a tree of attributes.
  8. Understand the role of the dicom-core crate

    master

    The dicom-core crate is the foundational sub-project of the DICOM-rs ecosystem. It implements the essential data structures and mechanisms required for handling DICOM information and communication formats. It serves as the central dependency for other crates within the DICOM-rs project.

    Note that dicom-core is contained within the parent crate dicom. If you are looking for a unified entry point to the library, you should use the dicom crate.

  9. Use the `dicom-fromimage` CLI tool

    master

    The dicom-fromimage command-line tool allows you to create a new DICOM file by taking a base DICOM file (which serves as a template for metadata/attributes) and replacing its image data with the contents of a different image file (e.g., PNG, JPG).

    Important Note: The --transfer-syntax option is a UID override only. It does not automatically transcode the pixel data to match the specified transfer syntax. For transcoding, use dicom-transcode instead.

    dicom-fromimage base.dcm image.png -o image.dcm
  10. Use the `dicom-dump` CLI to inspect DICOM files

    master

    The dicom-dump command-line utility allows you to inspect the contents of DICOM files by printing them in a human-readable format. You can pass one or more file paths as arguments to the command.

    dicom-dump [FLAGS] [OPTIONS] <files>...
  11. Convert DICOM files to images with `dicom-toimage`

    master

    The dicom-toimage command-line utility converts DICOM image files into general-purpose image formats like PNG. You can provide individual file paths or directories as arguments.

    dicom-toimage [OPTIONS] <FILES>...