dicom-rs icon indicating copy to clipboard operation
dicom-rs copied to clipboard

Why element_by_name cannot get SourceApplicationEntityTitle

Open liaohongxing opened this issue 2 years ago • 3 comments

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

liaohongxing avatar Feb 22 '23 07:02 liaohongxing

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");
} 

Enet4 avatar Feb 22 '23 09:02 Enet4

code test is available, thanks

liaohongxing avatar Feb 22 '23 10:02 liaohongxing

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.

Enet4 avatar Jul 21 '24 11:07 Enet4