#dicom #elements #part #data #standard #dictionary #access

dicom_dictionary_parser

Library that parses the data dictionary (part 6) of the DICOM standard and provides access to all data elements

2 unstable releases

Uses old Rust 2015

0.2.0 Oct 31, 2018
0.1.0 Oct 24, 2018

#30 in #dicom

MIT license

1MB
296 lines

dicom_dictionary_parser

Build Status Crates.io Documentation Crates.io

A Rust library that allows to parse the various elements defined in DICOM standard part 6.

Full documentation can be found here.

Usage

Add this to your 'Cargo.toml':

[dependencies]
dicom_dictionary_parser = "0.1.0"

and this to your crate root:

extern crate dicom_dictionary_parser;

lib.rs:

Library providing acess to the elements defined in the various tables of DICOM part 6. Currently, access to the following tables is provided:

  • "Registry of DICOM Data Elements"
  • "Registry of DICOM File Meta Elements"
  • "Registry of DICOM Directory Structuring Elements"
  • "Registry of DICOM Unique Identifiers (UIDs)"

Example - Writing data elements to file

extern crate dicom_dictionary_parser as dict_parser;

use std::fs::File;
use std::io::BufWriter;
use std::io::Write;

fn main() -> Result<(), Box<::std::error::Error>> {
    let parser = dict_parser::Parser::new()?;
    let data_elements = parser.parse_data_element_registry()?;
    let file = File::create("dictionary.rs")?;
    let mut buf_writer = BufWriter::new(file);
    for data_element in data_elements {
        let upper_case_keyword = data_element
            .keyword
            .replace("\u{200b}", "")
            .replace("__", "_")
            .to_uppercase();

        buf_writer.write_all(
            format!(
                "const {}: Tag = Tag(0x{}, 0x{});\n",
                upper_case_keyword,
                &data_element.tag[1..5],
                &data_element.tag[6..10])
            .as_bytes())?;
    }

    Ok(())
}

Dependencies

~22MB
~460K SLoC