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

Home » Public Forums » archive » Re: ROI stack
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: ROI stack [message #60815 is a reply to message #60814] Thu, 12 June 2008 17:01 Go to previous message
Chris[5] is currently offline  Chris[5]
Messages: 16
Registered: May 2008
Junior Member
On Jun 12, 11:45 am, mega...@phas.ubc.ca wrote:
> Hello,
> Can anyone see where I'm going wrong here? I'm trying to generate a
> binary mask of a multislice MRI image. When I run this at the
> command line it works, but when I put it in a loop, it fails to return
> anything. i.e. all variables of interest are "undefined"
> Any help/tips would be appreciated!
> Thanks,
> Megan
> AT COMMAND LINE:
> xroi, img[*,*,i], regions_out = roi, /Block
> mask = roi -> ComputeMask(Dimensions = dims, Mask_Rule=2)
> masks[*,*,i] = mask
> LOOP:
> pro twodmask
> img = read_nifti(dialog_pickfile())
> dims = size(img[*,*,3], /dimensions)
> s = size(img, /dimensions)
> n_slices = 2 ;s[2]
> masks = fltarr(dims[0], dims[1], s[2])
> for i = 0,n_slices-1 do begin
> xroi, img[*,*,i], regions_out = roi, /Block
> mask = roi -> ComputeMask(Dimensions = dims, Mask_Rule=2)
> masks[*,*,i] = mask
> endfor
>
> end


When you run a procedure (something that starts with pro), all of the
variables defined within the main body are local in scope. That is,
when you get to the "end" statement, all of the variables within the
program are discarded. Try this:

Change the first line from "PRO twodmask" to "function twodmask." Add
the line "return, mask" on the line before "end." Call the function by
typing in "mask=twodmask()." This now feeds the variable mask to you
upon completion.

chris
[Message index]
 
Read Message
Read Message
Previous Topic: ROI stack
Next Topic: Filtering File Names with Dialog_Pickfile

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

Current Time: Fri Oct 10 07:28:48 PDT 2025

Total time taken to generate the page: 0.00704 seconds