Skip to content

Commit daaa2f9

Browse files
Exclude private content sequences from the original metadata table
The `getTags()` method still includes these sequences, but this just keeps the original metadata table a little easier to read. Private content sequences are detected by looking for a private content creator, then excluding any sequences with a matching high word. This corresponds to https://dicom.nema.org/dicom/2013/output/chtml/part05/sect_7.8.html
1 parent acd37a1 commit daaa2f9

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

components/formats-bsd/src/loci/formats/dicom/DicomTag.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,17 @@ else if (!(value instanceof long[])) {
719719
}
720720
}
721721

722+
/**
723+
* See https://dicom.nema.org/dicom/2013/output/chtml/part05/sect_7.8.html
724+
*
725+
* @return true if this is a private content creator tag
726+
*/
727+
public boolean isPrivateContentCreator() {
728+
int highWord = (tag >> 16) & 0xffff;
729+
int lowWord = tag & 0xffff;
730+
return highWord % 2 == 1 && lowWord == 0x0010;
731+
}
732+
722733
@Override
723734
public String toString() {
724735
if (key == null) {

components/formats-bsd/src/loci/formats/in/DicomReader.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
import java.util.ArrayList;
3838
import java.util.Arrays;
3939
import java.util.HashMap;
40+
import java.util.HashSet;
4041
import java.util.Iterator;
4142
import java.util.List;
4243
import java.util.Map;
44+
import java.util.Set;
4345

4446
import com.google.common.collect.ImmutableMap;
4547
import com.google.common.collect.ImmutableMap.Builder;
@@ -127,6 +129,8 @@ public class DicomReader extends SubResolutionFormatReader {
127129

128130
private List<DicomTag> tags;
129131

132+
private Set<Integer> privateContentHighWords = new HashSet<Integer>();
133+
130134
// -- Constructor --
131135

132136
/** Constructs a new DICOM reader. */
@@ -368,6 +372,7 @@ public void close(boolean fileOnly) throws IOException {
368372
concatenationNumber = null;
369373
edf = false;
370374
tags = null;
375+
privateContentHighWords.clear();
371376
}
372377
}
373378

@@ -1168,6 +1173,10 @@ else if (infoString.startsWith("MONOCHROME")) {
11681173
* rely upon the original metadata table.
11691174
*/
11701175
private void addOriginalMetadata(String key, DicomTag info) {
1176+
if (info.isPrivateContentCreator()) {
1177+
privateContentHighWords.add(info.tag >> 16);
1178+
}
1179+
11711180
if (info.value != null && !(info.value instanceof byte[]) &&
11721181
!(info.value instanceof short[]))
11731182
{
@@ -1179,7 +1188,8 @@ private void addOriginalMetadata(String key, DicomTag info) {
11791188
}
11801189
}
11811190
if (info.attribute != PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE &&
1182-
info.attribute != REFERENCED_IMAGE_NAVIGATION_SEQUENCE)
1191+
info.attribute != REFERENCED_IMAGE_NAVIGATION_SEQUENCE &&
1192+
!privateContentHighWords.contains(info.tag >> 16))
11831193
{
11841194
for (DicomTag child : info.children) {
11851195
String childKey = DicomAttribute.formatTag(child.tag);

0 commit comments

Comments
 (0)