### Array Handling in Dicom Conversion Calculator - Part 2

In part-1 we discussed six functions related to array handling in Dicom. The functions ArSet() and ArGet() are used to set and get array elements as the name implies. However, Array elements in Dicom can also be assigned and retrived in a much easier way.

Example:

arX=Dim(3)

ArSet(1,10,arX) is equivalent to arX(1)=10

arX(2)=20

arX(3)=30

Similarly ArGet(1,arX) is equivalent to simply arX(1)

Array and Aggregate Functions

Following aggregate functions in Dicom apply to an array elements or a series of values or quantities. The functions are used respectively to determine Maximum, Minimum, Average, Sum, Count, and Standard Deviation of the values supplied.

Max( array | qty1 , qty2 [ , qty3…] )

Min( array | qty1 , qty2 [ , qty3…] )

Avg( array | qty1 , qty2 [ , qty3…] )

Sum( array | qty1 , qty2 [ , qty3…] )

Count( array | qty1 , qty2 [ , qty3…] )

Stdev( array | qty1 , qty2 [ , qty3…] )

Example of aggregate functions with list of values

Max(1,2,3) = 3

Max(1 ft, 6 inch, 250 mm) to ft = 1.00 ft

Min(1,2,3) = 1

Min(1 ft, 6 inch, 250 mm) to ft = 0.50 ft

Avg(1,2,3) = 2

Avg(1 ft, 6 inch, 250 mm) to ft = 0.77 ft

Sum(1,2,3) = 6

Sum(1 ft, 6 inch, 250 mm) to ft = 2.32 ft

Count(1,2,3) = 3

Count(1 ft, 6 inch, 250 mm) = 3

Stdev(1,2,3) = 0.81649

Stdev(1 ft, 6 inch, 250 mm) to ft = 0.2068 ft

Example of aggregate functions with Array

Note that there is no limit to the number of comma separated list of values. And as you noticed already, the list of values can be with or without units. However, for long list of values instead of using comma separated list you can use an array.

Above Examples are re-written below using array, just cut and paste the following code in a Dicom document and press [f8] to execute.

['

arX=Dim(3);

ArAdd(1,2,3,arX);

arY=Dim(3);

ArAdd(1 ft, 6 inch, 250 {mm.}, arY);

Max(arX); Max(arY);

Min(arX); Min(arY);

Avg(arX); Avg(arY);

Sum(arX); Avg(arY);

Count(arX); Count(arY);

Stdev(arX); Stdev(arY);

']

Note

- [' and '] are used in a Dicom document to distinguish the expressions to be evaluated from the rest of the document text. These are so called expresson tags.
- Multiple expressions in Dicom are separated with semicolon (;)

Dicom unit conversion calculator is available here for free download.

<< Home