javadicomdcm4che

How can I create new/custom tags in DICOM using dcm4che?


I want to add some private data/information to DICOM data set. This data does not fit in any standard DICOM tags.

So, I want to add some specific new/custom tags in DICOM data set using dcm4che those are not in the DICOM library.

How can I create new/custom tags in DICOM using dcm4che?


Solution

  • You are looking for Private Data Element Tags; those are supported by DICOM. Any tag with odd group number (except 0001, 0003, 0005, 0007, FFFF) is Private Tag. So the tag (0x00310011) [DicomTag(49, 17)] becomes private tag.

    Private Data Elements have the same structure as Standard Data Elements specified earlier in Section 7.1 (i.e., Data Element Tag field, optional VR field, length field, and value field). The Group Number used in the Element Tag of Private Data Elements shall be an odd number. Private Data Elements shall be contained in the Data Set in increasing numeric order of Data Element Tag. The Value Field of a Private data element shall have one of the VRs specified by this standard in Section 6.2.

    The another guide explains it with block diagram:

    It is possible that multiple implementers may define Private Elements with the same (odd) group number. To avoid conflicts, Private Elements shall be assigned Private Data Element Tags according to the following rules.

    • Private Creator Data Elements numbered (gggg, 0010-00FF) (gggg is odd) shall be used to reserve a block of Elements with Group Number gggg for use by an individual implementer. The implementer shall insert an identification code in the first unused (unassigned) Element in this series to reserve a block of Private Elements. The VR of the private identification code shall be LO (Long String) and the VM shall be equal to 1.
    • Private Creator Data Element (gggg, 0010), is a Type 1 Data Element that identifies the implementer reserving element (gggg, 1000-10FF), Private Creator Data Element (gggg, 0011) identifies the implementer reserving elements (gggg, 1100-11FF), and so on, until Private Creator Data Element (gggg, 00FF) identifies the implementer reserving elements (gggg, FF00 -FFFF). The total number of blocks that can be reserved and later used within one group is thus 0XFF - 0X10 = 240.

    Source: Specifications

    Refer to other post that discusses about this.

    With dcm4che, you add it the same way you add any other tag; just specify the tag explicitly instead of using something like Tag.StudyTime.

    Attributes attribs = new Attributes();
    attribs.setString(0x00210011, VR.LO, "your data");