Re: GE PET DICOM format [message #37980] |
Wed, 11 February 2004 14:19 |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
>>>> > "karin" == karin knesaurek <karin.knesaurek@mssm.edu> writes:
> Can somebody help me with GE PET DICOM format. A set of
> corronal or sagittal slices are all placed in one
> directory. I can read all files but I don't know how to put
> them in order because GE names them by using bed position,
> rather than order, first, second, etc.
Here's a fragment showing how I assemble dicom files into a
volume. It doesn't do much error checking, but does order slices
according to the slice locations. If you try to read from a
directory with a mixture of studies in it, this will happily mix
them and give you scrambled results.
Mike
--
Michael A. Miller mmiller3@iupui.edu
Imaging Sciences, Department of Radiology, IU School of Medicine
function read_dicom, dirname
filelist = findfile( dirname+'/*' )
print, 'Loading the ', N_Elements(filelist), $
' DICOM files from the directory ', dirname
nFiles = N_Elements(filelist)
zdim = nFiles
slice_locations = fltarr(nFiles)
slice_thicknesses = fltarr(nFiles)
dcm = Obj_New('IDLffDICOM')
for i = 0, nFiles-1 do begin
;; Read DICOM tags from the file
dcm->Reset
;;print, 'trying ', filelist[i]
var = dcm->Read(filelist[i])
;; check if its really a DICOM format file
if (var eq 0) then $
begin
error = 'not a DICOM directory'
return, error
endif
image_type = *(dcm->GetValue('0008'x,'0008'x))[0]
slice_locations[i] = *(dcm->GetValue('0020'x,'1041'x))[0]
slice_thickness = *(dcm->GetValue('0018'x,'0050'x))[0]
xdim = *(dcm->GetValue('0028'x,'0010'x))[0]
ydim = *(dcm->GetValue('0028'x,'0011'x))[0]
pixel_size = *(dcm->GetValue('0028'x,'0030'x))[0]
endfor
sorted_indeces = sort(slice_locations)
sorted_slice_locations = slice_locations[sort(slice_locations)]
slice_intervals = fltarr(N_Elements(sorted_slice_locations)-1)
slice_intervals = sorted_slice_locations[0:N_Elements(slice_locations)-2] $
- sorted_slice_locations[1:N_Elements(slice_locations)-1]
mean_slice_interval = abs(mean(slice_intervals))
data = intarr(xdim, ydim, nFiles)
for i = 0, nFiles-1 do begin
data(*,*,i) = read_dicom(filelist[sorted_indeces[i]])
endfor
flt_image = float(data)
xsize = float(strmid(pixel_size, 0, strpos(pixel_size, '\')))
ysize = float(strmid(pixel_size, strpos(pixel_size, '\')+1))
zsize = mean_slice_interval
return, data
end
|
|
|