简体   繁体   中英

Evil Dicom hw to check if a tag exists

I am working with DICOM RT data sets and the Frame of reference UID is common across all files except the RT structure file where it is called referenced frame of reference.

What I would like to do is to read each DICOM file and check if the file has the tag FrameOfReferenceUID or ReferencedFrameOfReferenceUID and act accordingly.

var dcm = DICOMFileReader.Read(file);
var sel = new DICOMSelector(dcm);

var refFOR = sel.ReferencedFrameOfReferenceUID.Data;

This las line throws an error when a file does not contain the tag FrameOfReferenceUID . Need to check if it exists first, can't seem to figure out how to do this.

var dcm = DICOMObject.Read(@"MyDICOMFile.dcm");
var genericName = dcm.FindFirst(TagHelper.PATIENT_NAME) as AbstractElement<string>;
if(genericName != null)
    var genValue = genericName.Data;

Above code is copied from here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM