>  Docs Center  >  IDL Reference  >  DICOM Toolkit  >  IDLffDicomEx::GetPrivateValueCount



DicomEx and DICOM Network Services require a separate license and installer. Contact your Harris Geospatial Solutions sales representative or technical support for more information.

The IDLffDicomEx::GetPrivateValueCount function method returns the number of values contained in the value field of a private DICOM attribute. This method uses a private code defined by the author of the private tag, a group number, and part of the element tag instead of a standard DICOM attribute tag to identify the DICOM attribute.

GetPrivateValueCount will fail if you attempt to return a value for an attribute that does not exist or an attribute that has been removed. If you are not sure if an attribute exists use IDLffDicomEx::QueryPrivateValue before calling GetPrivateValueCount.


Result = Obj->[IDLffDicomEx::]GetPrivateValueCount(PrivateCode, Group, Element [, SEQID=integer] )

Return Value

Returns an unsigned long value indicating the number of values in the value field of the specified attribute as follows:

  • A value of 0 indicates the tag had no value
  • A value greater than 0 (n) indicates the number of values in the value field



A string identification code that identifies the private block of data. Within a given private group PrivateCode labels are stored sequentially in the element addresses ranging from '0010' to '00FF'. For example, the string value stored at DICOM tag address '0029,0010' is the PrivateCode for the block of data tagged at '0029,1000' ‑ '0029,10FF'. The label stored at '0029,0011' would be the PrivateCode for the data in tags '0029,1100' - '0029,11 FF'.


A string identifying the group tag number of the private attribute (the first four digits of a DICOM tag). This must be an odd number and in the form 'XXXX'.


A string identifying the last two digits of the element associated with the private attribute. This must be in the form 'XX'. Valid values are 10 - FF.

Note: The first two digits of the Element are implicit in the PrivateCode argument.



Set this keyword only if the private attribute exists within a sequence. Use this keyword to specify sequence identifier as follows:

  • Set to a non-zero value (a sequence identifier) indicating the sequence in which the value is contained. This sequence identifier may have been returned via a previous call to the GetPrivateValue method.
  • Set to 0 or do not specify this keyword to indicate the private attribute exists at the root level of the DICOM file. This is the default.


The following example uses GetPrivateValueCount to cycle through a multi-valued private attribute that has been added to a file. To avoid errors arising from attempting to write to an existing file, the cloned image is not saved to the database. To save the changes, call the IDLffDicomEx::Commit method.

PRO dicom_getprivate_value_doc
; Select a DICOM file.
    PATH=FILEPATH('',SUBDIRECTORY=['examples','data']), $
    TITLE='Select DICOM Patient File', FILTER='*.dcm', $
; Create a clone (aImgClone.dcm) of the selected file (sfile).
 oImg = OBJ_NEW('IDLffDicomEx', path + 'aImgClone.dcm', $
; Add private tags. The following are hypothetical.
; Create a multi-valued tag at the root level.
arr = [11, 12, 13, 14]
oImg->SetPrivateValue, 'Private Test', '0053', '10', 'SS', arr
; Create a sequence at the root level.
vSeqId = oImg->AddPrivateSequence('VOI Min,Max', '0055', '12')
; Add items to the sequence, specifying SQ identifier returned by
; AddPrivateSequence.
oImg->SetPrivateValue, 'VOI Min,Max', '0055', '13', 'IS', '215', $
oImg->SetPrivateValue, 'VOI Min,Max', '0055', '14', 'IS', '234', $
; Get the value of a multi-valued root-level private attribute.
vValue = oImg->GetPrivateValue('Private Test', '0053', '10')
; Get the VR.
vVR = oImg->GetPrivateVR('Private Test', '0053', '10')
; Get the nubmer of items in the multi-valued attribute. Use either
; the COUNT keyword to GetPrivateValue or GetPrivateValueCount. 
vCount = oImg->GetPrivateValueCount('Private Test', '0053', '10')  
FOR i = 1, vCount DO BEGIN
   Print, 'Value number', i, + ' is ', vValue[i-1], + $
      ' and VR is ', vVR
; Clean up references.

The following appears in the Output Log window.

Value number       1 is       11 and VR is SS
Value number       2 is       12 and VR is SS
Value number       3 is       13 and VR is SS
Value number       4 is       14 and VR is SS

Version History



© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us