Expand description
DICOM data model and file I/O.
Four constraints shape this crate:
- Stored as-is: element values are kept as the raw bytes defined by the standard; number and text interpretation is deferred until read time. Data under any transfer syntax (explicit/implicit VR, big endian, and whatever is added later) can therefore be written back byte for byte, and the parser never has to guess.
- Explicit endianness: numeric decoding always takes an
Endian; there is no hidden global byte-order state. - Lean dependencies: character set decoding uses
encoding_rs; JPEG decoding useszune-jpegbehind the defaultpixel-jpegfeature, JPEG-LS usescharlsbehind thepixel-jpeglsfeature, JPEG 2000 usesjpeg2k(with the pure-Rustopenjp2port) behindpixel-j2k, JPEG XL usesjxl-oxidebehindpixel-jxl, and further codecs stay feature-gated, sodcm4rsstays embeddable in long-lived products such as a PACS. - Canonical writing: sequences are written with defined lengths and group length elements are dropped, so a data set read from an undefined-length file comes back canonicalized while decoded content stays identical.
use dcm4rs::{DataSet, Tag, Value, Vr};
let mut ds = DataSet::new();
ds.set(Tag::new(0x0010, 0x0010), Vr::Pn, Value::from_str("Doe^John"));
ds.set(Tag::new(0x0028, 0x0010), Vr::Us, Value::from_u16s(&[512]));
assert_eq!(ds.string(Tag::new(0x0010, 0x0010)).unwrap(), "Doe^John");
assert_eq!(ds.u16(Tag::new(0x0028, 0x0010)).unwrap(), 512);
let syntax = dcm4rs::TransferSyntax::ExplicitVrLittleEndian;
let bytes = ds.write(syntax).unwrap();
assert_eq!(DataSet::read(&bytes, syntax).unwrap(), ds);Re-exports§
pub use pixels::PhotometricInterpretation;pub use pixels::PixelDescriptor;pub use pixels::PixelRepresentation;pub use pixels::PlanarConfiguration;pub use uid::Uid;pub use valuerep::Date;pub use valuerep::DateTime;pub use valuerep::DecimalString;pub use valuerep::IntegerString;pub use valuerep::PersonName;pub use valuerep::Time;
Modules§
- dictionary
- DICOM data dictionary (PS3.6 Chapter 6, Registry of DICOM Data Elements).
- encaps
- Encapsulated pixel data: fragments, items and the offset tables.
- mpeg
- MPEG-2 sequence headers, and nothing beyond them.
- pixels
- Pixel data decoding: descriptors, frame extraction and codecs.
- uid
- DICOM unique identifiers: validation and the PS3.6 registry.
- valuerep
- Typed views over the values this crate stores as bytes.
- waveform
- Waveform decoding: the multiplex groups of
(5400,0100)(PS3.3 C.10.9.1).
Structs§
- DataSet
- An ordered collection of data elements, corresponding to one DICOM Data Set or one Item.
- Deferred
Element - An element whose value a read skipped because it reached
ReadOptions::defer_size. - Dicom
Dir - A media storage directory: the File-set attributes plus the directory records.
- Dicom
File - A DICOM Part 10 file: the file meta information plus the main data set.
- Directory
Record - A directory record and the records below it.
- Element
- A DICOM data element: tag, VR and value.
- Private
Block - The elements one private creator owns in one group.
- Private
Dictionary - A mapping from private creators and element offsets to value representations.
- Read
Options - Reading behaviour for files written by implementations that depart from the standard.
- Tag
- A DICOM data element tag: a 16-bit group number plus a 16-bit element number.
Enums§
- Charset
- The character set a data set declares for its text values.
- Endian
- Byte order.
- Error
- Errors the data model and the encoders can produce.
- Transfer
Syntax - A DICOM transfer syntax.
- Value
- The raw value of an element.
- Vr
- DICOM Value Representation: the 34 VRs defined by PS3.5.
Type Aliases§
- Result
- Convenience result alias.