Skip to content

Commit

Permalink
Add VR lookup
Browse files Browse the repository at this point in the history
If a VR is not defined, the default is used.
If a VR other than the default is defined, a warning will be shown
but the user-defined VR will be used.
  • Loading branch information
melissalinkert committed Aug 31, 2023
1 parent 2159cd4 commit afcce2b
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public void readTagSource(String location) throws IOException {

for (String tagKey : root.keySet()) {
JSONObject tag = root.getJSONObject(tagKey);
String vr = tag.getString("VR");
String value = tag.has("Value") ? tag.getString("Value") : null;

Integer intTagCode = null;
Expand All @@ -117,10 +116,22 @@ public void readTagSource(String location) throws IOException {
}
}

DicomVR vrEnum = DicomVR.valueOf(DicomVR.class, vr);
DicomVR vrEnum = DicomAttribute.getDefaultVR(intTagCode);
if (tag.has("VR")) {
DicomVR userEnum = DicomVR.valueOf(DicomVR.class, tag.getString("VR"));
if (!vrEnum.equals(userEnum)) {
LOGGER.warn("User-defined VR ({}) for {} does not match expected VR ({})",
userEnum, DicomAttribute.formatTag(intTagCode), vrEnum);
if (userEnum != null) {
vrEnum = userEnum;
}
}
}

DicomTag dicomTag = new DicomTag(intTagCode, vrEnum);
dicomTag.value = value;
LOGGER.debug("Adding tag: {}, VR: {}, value: {}", intTagCode, vrEnum, value);
LOGGER.debug("Adding tag: {}, VR: {}, value: {}",
DicomAttribute.formatTag(intTagCode), vrEnum, value);
dicomTag.validateValue();

if (vrEnum == DicomVR.SQ && tag.has("Sequence")) {
Expand Down

0 comments on commit afcce2b

Please sign in to comment.