Thursday, July 06, 2006

Array Handling in Dicom Conversion Calculator - Part 1

Arrays are useful in analysing data set. Dicom statistical functions use arrays as parameters.

Dicom is unique in its ability to handle array. Array can be named or unnamed. The array elements can be with unit or unit-less. Array can be single or multi-dimensional. With dicom you can deal with one-dimensional list, two-dimensional table, and three-dimensional pages of table.

Function Description with Examples

There are 6 Array handling functions in dicom as described below.

1. To create single or multidimensional array use:
Dim( columns [, rows [,pages]] )

Dim (3) - list of 3 values.
Dim (3, 4) - a 3 columns by 4 rows table
Dim (3, 4, 100) - 100 pages of 3x4 table

Note that index of Dicom array elements starts with 1.
Assigning an array to a name is convenient.

arX = Dim(3)
arY = Dim(3, 4)

In the above example, arX and arY are two named arrays.

2. To append array elements use:
ArAdd( arg1, arg2, …[, array] )

arX = Dim(5) - an array of five values
ArAdd(10,20,30,40,50,arX) - add all 5 values to the array in one go.

Alternately yo can append one by one or any number of values at a time.

arX = Dim(5) - an array of five values
ArAdd(10,20,30,arX) - add first 3 values to the array.
ArAdd(40,50,arX) - add next 2 values to the array.

3. To set an array element use:
ArSet( pos, [array,] value )

ArSet(2, arX, 20.5) - change the value of the second element to 20.5

4. To get an array element use:
ArGet( pos [,array] )

ArGet(2, arX) = 20.5

5. To delete an array use:
ArDel( [array] )


6. To reference an unnamed array use:
Res( )

ArAdd(100,200,300, Res())
ArGet(2,Res()) - will return 200

However, you can omit the array parameter (as it is optional in all of the array handling functions) if you want to deal with the unnamed array.


As you may rightly guessed, you can deal with only one unnamed array at a time. But of course, there is no limit for the number of named arrays one can use.

Before concluding, please recall that Dicom arrays can deal with unit too.

ArAdd(5ft, 60 kg, 35 yr)
ArGet(1) to inch : will return 60 inch (inches)
ArGet(2) to lb : will return 132.27 lb (pound)
ArGet(3) to d : will return 12783.47 d (days)

In the next part "Array Handling in Dicom Conversion Calculator - Part 2" we will see some use of arrays in Dicom conversion calculator. Happy computing!

Dicom unit conversion calculator is available here for free download.