Re: WHERE and pointers [message #33526] |
Thu, 09 January 2003 19:45  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Sheryn Gillin (sheryn.gillin@cmr.uq.edu.au) writes:
> I don't have my full code here at work, but it basically looks like:
>
> dicomdir = OBJ_NEW('IDLffDICOM', 'D:\dicomdir')
> PatientName = dicomdir->GetValue('0010'x, '0010'x)
>
> So PatientName is an array of 'PtrHeapVariables', which I want to
> compare with a user entered parameter to determine where to start
> reading the images/filenames.
>
> What I tried was various combinations of:
> StartOffset = WHERE(*PatientName EQ 'blah');
> StartOffset = WHERE((*PatientName) EQ 'blah');
> StartOffset = WHERE(*PatientName[*] EQ 'blah'); etc.
> however, I only get error messages, so end up having to use a FOR loop
> to find the starting location.
Ah, well. What apparently gets returns is an array
of pointers. In the DICOM file I just opened there
is only a single pointer in the array:
IDL> PatientName = dicomdir->GetValue('0010'x, '0010'x)
IDL> help, patientname
PATIENTNAME POINTER = Array[1]
IDL> help, *patientname
% Expression must be a scalar in this context: PATIENTNAME
I thought at first it was a pointer to an array, too. But that
has a slightly different syntax:
IDL> ptr = Ptr_New([ 3,4,5])
IDL> help, ptr
PTR POINTER = <PtrHeapVar99>
What I really want is dereference syntax like this:
IDL> help, *(patientname)[0]
<PtrHeapVar98> STRING = '3D KNEE '
In this case, the pointer only points to one thing, so there
is not much point in a WHERE function. In your case, the
pointer might point to several things, so a WHERE function
might be appropriate. Or, you might have to dereference all
your points into a large array, and *then* use the WHERE
function. But, in any case, *something* ought to be possible. :-)
How did that ComputeMesh suggestion pan out for your stack
of ROIs?
I put up a tip just the other day on my web page, by the way.
The proper way to delete all these pointers when you are done
with them (and you may not know at all how many you have!), is
like this:
Heap_Free, dicomdir
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|