comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Reading Multiple DICOM Files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Reading Multiple DICOM Files [message #65544] Tue, 10 March 2009 04:56 Go to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Mon, 9 Mar 2009, rtk wrote:

> On Mar 8, 6:17 pm, Jye <jye.sm...@gmail.com> wrote:
>> if i eq 0 then All_Images = image_slice else All_Images =
>> [[[All_Images]], [[image_slice]]]
>
> Forget too much Java, which, I agree, is a bad thing. I'd say you
> have been doing too much Matlab programming. The vast majority of
> your problem lies with the line above. If I run this code on my box:
>
> pro ttt0
> s = systime(1)
> for i=0,899 do begin
> im = fix(dist(256))
> if (i eq 0) then begin
> all = im
> endif else begin
> all = [[[all]], [[im]]]
> endelse
> endfor
> print, 'runtime = ', systime(1)-s
> help, all
> end
>
> It takes 93 seconds. However, if I run this code:
>
> pro ttt2
> all = intarr(256,256,900)
> s = systime(1)
> for i=0,899 do begin
> im = fix(dist(256))
> all[*,*,i] = im
> endfor
> print, 'runtime = ', systime(1)-s
> help, all
> end
>
> it takes 1.6 seconds. The only difference is that the output array is
> allocated once, instead of 900 times with 899 ever-increasing array
> copies to boot. Since you know the number of file in advance,
> allocate All_Images and just assign into it.
>
> Ron

You can get some more speedup by replacing 'all[*,*,i] = im' with
'all[0,0,i] = im':

; cut here, ttt2.pro
pro ttt2
all = intarr(256,256,900)
im = fix(dist(256))

s = systime(1)
for i=0,899 do begin
all[*,*,i] = im
endfor
print, 'runtime = ', systime(1)-s

s = systime(1)
for i=0,899 do begin
all[0,0,i] = im
endfor
print, 'runtime = ', systime(1)-s
end
; cut here

IDL> ttt2
% Compiled module: TTT2.
% Compiled module: DIST.
runtime = 0.20675302
runtime = 0.047688007

(This is not the bottleneck for the original problem, though.)

regards,
lajos
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Changing color of composite objects
Next Topic: Re: starting point of dashed lines

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:34:36 PDT 2025

Total time taken to generate the page: 0.00454 seconds