Enet4 / dicom-rs

Rust implementation of the DICOM standard
https://dicom-rs.github.io
Apache License 2.0
416 stars 81 forks source link

Why element_by_name cannot get SourceApplicationEntityTitle #329

Open liaohongxing opened 1 year ago

liaohongxing commented 1 year ago

Why element_by_name cannot get SourceApplicationEntityTitle

sample code:

use dicom::object::{open_file};

fn main() {
    let obj = open_file("./dcm/ct-0.dcm").unwrap();

    let source_application_entity_title = obj.element_by_name("SourceApplicationEntityTitle").unwrap();

    println!("============={:?}", source_application_entity_title);
}

print:

oSuchDataElementAlias { tag: Tag(0x0002, 0x0016), alias: "SourceApplicationEntityTitle", backtrace: Backtrace(()) }

dcm file:

ct-0.zip

Enet4 commented 1 year ago

Thank you for reaching out. As Source Application Entity Title is in the file meta information group, it is currently not reachable directly through element* methods. You can call meta() to reach the file meta table and retrieve source_application_entity_title from there.

if let Some(source_application_entity_title) = obj.meta().source_application_entity_title.as_ref() {
    println!("> {source_application_entity_title}");
} else {
    println!("No source application entity title");
} 
liaohongxing commented 1 year ago

code test is available, thanks

Enet4 commented 2 months ago

Just leaving a note that per the plans for the upcoming generic object API (#524), it will be possible to retrieve Source Application Entity Title and other attributes in the meta file group using the same methods as the ones for retrieving attributes from the main data set.