PDA

View Full Version : Dicom Associated Array changes do not persist



JZ
08-13-2007, 02:39 PM
Folks,

I have used image_read to read a Dicom CT object from a file on disk. The resulting Associated Array has a 128x128 pixel image array, with x_resolution and y_resolution = 144.0. Of course the width and height fields are also 128.

I upsampled the pixels array using congrid and reassigned back to the original Associated Array. I also changed the width and height fields to 256L. I changed the x_ and y_resolutions to 144.0. Then I wrote the associated array back to disk with image_write, again using File_type='dicm'. I can read the resulting file back fine with image_read and a 'dicm' File_type, HOWEVER, the pixel array, width, height, and resolutions snap back to their old values.

I have tried re-creating the associated array with asarr using the keys and most values taken from the original, unresampled associated array, but no luck. The same thing happens.

Can anyone tell me how to change the pixels array in a dicom associated array and write it out so I can reread it as intended?

JZ

rwagner
08-14-2007, 10:21 AM
Hi,
Thank you for reporting this issue. I've tested out the IMAGE_WRITE procedure and it appears to be a bug with how the procedure writes DICOM headers. There is no known workaround as yet other than to use a different file format. I've filed a defect report and will update this thread once we find a solution.

-Ryan

rwagner
08-14-2007, 01:55 PM
I was able to devote some time to fixing this today. Please let me know that it works for you.

The problem was that the DICOM writer was writing out the new pixel array from your image variable, but carrying over the DICOM header tag from the old file which specifies the width and height of the pixel array. This patch looks at the height and width tags of the image variable when writing a new DICOM file. (The x and y resolution in the header will still be carried over from the old file, however, so changing these values in the image variable will not do anything...)

So for an example:




8.51> i = image_read("OT-MONO2-8-hip", FILE_TYPE="dicm")
8.51> info, /full, i
I AS. ARR = Associative Array(22)
label STRING = ''
file_type STRING = 'dicm'
height LONG = 512
units LONG = 2
img_num LONG = 0
y_resolution FLOAT = 72.0000
pixels BYTE = Array(512, 512)
color_model LONG = 0
n_colors LONG = 0
file_name STRING = 'OT-MONO2-8-hip'
width LONG = 512
cmap_type LONG = 0
x_resolution FLOAT = 72.0000
status LONG = 0
img_count LONG = 1
nr_cc LONG = 1
depth LONG = 8
colormap INT = 0
cmap_dtype LONG = 1
comments STRING = '0800000004000000B0000000080008002E0000004F524'...
pixel_dtype LONG = 1
interleave LONG = 3

8.51> p = i("pixels")
8.51> p2 = congrid(p, 1024, 1024)
8.51> i("pixels") = p2
8.51> i("height") = 1024L
8.51> i("width") = 1024L
8.51> s = image_write("test", i)
8.51> i2 = image_read("test", FILE_TYPE="dicm")
8.51> info, /full, i2
I2 AS. ARR = Associative Array(22)
label STRING = ''
file_type STRING = 'dicm'
height LONG = 1024
units LONG = 2
img_num LONG = 0
y_resolution FLOAT = 72.0000
pixels BYTE = Array(1024, 1024)
color_model LONG = 0
n_colors LONG = 0
file_name STRING = 'test'
width LONG = 1024
cmap_type LONG = 0
x_resolution FLOAT = 72.0000
status LONG = 0
img_count LONG = 1
nr_cc LONG = 1
depth LONG = 8
colormap INT = 0
cmap_dtype LONG = 1
comments STRING = '0800000004000000B0000000080008002E0000004F524'...
pixel_dtype LONG = 1
interleave LONG = 3

8.51> image_display, i2
8.51> ;The image displays correctly as well...



:)



To install this patch:

I've attached a .zip file which contains two files...

image_write.cpr
image_write.pro

Unzip these files and use them to replace your existing files residing in

<VNI_DIR>/image-1_0/lib

A future release of PV-WAVE will include this patch.



-Ryan Wagner
Technical Support Engineer
Visual Numerics Inc.