The IDLffDicomEx::CopyTags procedure method copies all the tags from the source object to the destination object beginning with the DICOM attribute tag specified by the Start_Tag and copying up to the Stop_Tag. This method does a deep copy of a tag, which means it copies all sub-items, even sequences that contain nested sequences and multiple repeating groups.
This method is intended to copy small blocks of tags from one DICOM file to another DICOM file. This method is not intended to be used to copy entire DICOM files. To clone an existing DICOM file, use the IDLffDicomEx::Init method with the CLONE keyword set to copy an entire DICOM file.
If you are copying non-standard tags to a destination object (as defined by its SOP Class definition), open the destination object with the IDLffDicomEx::Init method NON_CONFORMING keyword to avoid errors.
In rare instances the values of copied tags are changed when they are added to the destination file. If you are copying multiple private block code tags that are not numbered sequentially by 1, they will be numbered in this manner when they are copied into the destination file.
Specifying Start and Stop Tags
The Start_Tag and Stop_Tag do not have to be precise tags. For example, suppose you provide '0010,0000' as the Start_Tag or Stop_Tag argument. If the specified tag does not exist in the file, copying will start with the next element after that one or stop on the element right before that one. While the Start_Tag and Stop_Tag arguments can be loosely defined, the definitions must adhere to the following guidelines:
- The DICOM attributes specified for the start and stop tags must be root level tags. These tags can be sequence tags as long as they exist at the root level, but they cannot be tags contained inside a sequence.
- When copying private DICOM attributes (those with an odd group number) it is necessary to start at the beginning of a private block. An error will be issued if you attempt to copy tags from the middle of a private sequence or private group. For example 0055,0010 is a tag that starts a new private block of tags. Attempting to copy tags beginning with 0055,1013, which exists inside a private block, would generate an error.
Note: If you are copying a block of tags that includes multiple private blocks, each block must be copied independently as shown in the following “Example” section.
- The DICOM attributes specified for the start and stop tags cannot be set to ‘0000,0000’.
Note: Tags 0002,0003 (Media Storage SOP Instance tag) and 0008,0018 (SOP Instance tag) are not copied from one file to another. This avoids overwriting the unique instance identifiers for a file and prevents identical identifiers from existing in two unique files.
Note: Use the IDLffDicomEx::EnumerateTags method to view all attributes in a DICOM file.
Syntax
Obj->[IDLffDicomEx::]CopyTags, DestinationObject, Start_Tag, Stop_Tag
Arguments
DestinationObject
An IDLffDicomEx object reference to the file to which the specified tags will be copied.
Start_Tag
A string identifying a DICOM attribute in the form 'XXXX,XXXX' that specifies the first tag to be copied. A Start_Tag value of '0000,0000' is not valid. See Specifying Start and Stop Tags for more information. See DICOM Attributes for a list of tags.
Stop_Tag
A string identifying a DICOM attribute in the form 'XXXX,XXXX' that specifies the last tag to be copied. A Stop_Tag value of '0000,0000' is not valid. See Specifying Start and Stop Tags for more information. See DICOM Attributes for a list of tags.
Keywords
None
Example
The following example adds a number of private tags to a clone of the first selected image and then copies these blocks of private tags to a clone of the second selected file using the CopyTags method. The new tags and copied tags are displayed in the Output Log window.
If you are copying a block of tags that include multiple private blocks, each block must be copied independently as shown in the following example.
To avoid errors encountered when attempting to overwrite an existing file, neither cloned image is saved to disk. To do so, call the IDLffDicomEx::Commit method.
PRO print_tags_doc, vTags, vTagCnt
PRINT, FORMAT= $
'(%"%3s, %2s, %-12s, %3s, %5s, %12s, %15s")', $
'IDX', 'LVL', 'TAG', 'VR', 'SEQID', $
'DESCRIPTION', 'VALUE'
FOR xx = 0, vTagCnt-1 DO BEGIN
IF (vTags[xx].Level GT 0) THEN BEGIN
vLvl = STRJOIN(REPLICATE('>',vTags[xx].Level))
vtg = vLvl + vTags[xx].Tag
ENDIF ELSE BEGIN
vtg = vTags[xx].Tag
ENDELSE
IF (vTags[xx].GroupNum GT 0) THEN BEGIN
PRINT, FORMAT='(%"%15s, %1d")', 'Group', vTags[xx].GroupNum
ENDIF
PRINT, FORMAT = $
'(%"%3d, %2d, %-12s, %3s, %5s, %12s, %15s")', $
xx, vTags[xx].Level, vtg, vTags[xx].VR, $
vTags[xx].SeqId, vTags[xx].Description, $
vTags[xx].Value
ENDFOR
END
PRO dicom_tagcopyexample_doc
sFile = DIALOG_PICKFILE( $
PATH=FILEPATH('',SUBDIRECTORY=['examples','data']), $
TITLE='Select DICOM Patient File', FILTER='*.dcm', $
GET_PATH=path)
oCloneImg= OBJ_NEW('IDLffDicomEx', path + 'aImgClone.dcm', $
CLONE=sfile, /NON_CONFORMING)
arr = [1, 2, 3, 4]
oCloneImg->SetPrivateValue, 'Private Test', '0053', '00', 'SS', $
arr
vSeqId = oCloneImg->AddPrivateSequence('VOI Min,Max', '0055', $
'12')
oCloneImg->SetPrivateValue, 'VOI Min,Max', '0055', '13', 'IS', $
'215', SEQID=vSeqID
oCloneImg->SetPrivateValue, 'VOI Min,Max', '0055', '14', 'IS', $
'234', SEQID=vSeqID
vTags = oCloneImg->EnumerateTags(COUNT=vTagCnt, $
START_TAG='0053,0000', STOP_TAG='0057,0000')
print_tags_doc, vTags, vTagCnt
sFile1 = DIALOG_PICKFILE( $
PATH=FILEPATH('',SUBDIRECTORY=['examples','data']), $
TITLE='Select DICOM Patient File', FILTER='*.dcm', $
GET_PATH=path)
oDestImg = OBJ_NEW('IDLffDicomEx', path + 'aDestImg.dcm', $
CLONE=sfile1, /NON_CONFORMING)
oCloneImg->CopyTags, oDestImg, '0053,0000', '0055,0000'
oCloneImg->CopyTags, oDestImg, '0055,0000', '0057,0000'
PRINT, 'Tags copied to aDestImg file.'
vTags = oDestImg->EnumerateTags(COUNT=vTagCnt, $
START_TAG='0053,0000', STOP_TAG='0057,0000')
print_tags_doc, vTags, vTagCnt
OBJ_DESTROY, [oCloneImg, oDestImg]
END
Version History