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
|
|
|
|
Re: WHERE and pointers [message #33549 is a reply to message #33531] |
Wed, 08 January 2003 22:16   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Sheryn Gillin (sheryn.gillin@cmr.uq.edu.au) writes:
> Hoping someone may be able to help. I know the beauty of the WHERE
> function, and the importance of pointers, however, I can't get the two
> to work together. For example...I use the ->GetValue('0000'x,
> '0000'x) to read a value from the DICOM header, and the result returns
> is a PtrHeap, but when I try to loop through this array using WHERE I
> get an error. Any hints?
Presumably the return value is a pointer to an array of
values. The syntax would then be something like this:
indices = Where( *ptr GT 5) ; or whatever
Is this what you are doing?
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
|
|
|
Re: WHERE and pointers [message #33642 is a reply to message #33526] |
Sun, 12 January 2003 16:23  |
sheryn.gillin
Messages: 6 Registered: January 2003
|
Junior Member |
|
|
> % Expression must be a scalar in this context: PATIENTNAME
That's exacty the error message I get when trying to use WHERE. :(
> 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. :-)
Guess my FOR loop isn't looking so bad after all. :) Think I'll just
stick to that method, for this instance.
> How did that ComputeMesh suggestion pan out for your stack
> of ROIs?
Absolutely fantastic. Thank you. Sent the 'displays' off to my
supervisors this morning, and I hope they are as pleased/happy as me.
:)
> 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
Definitely cleaner than my multiple lines, destroying each object
seperately. I'll update my code tonight.
Thanks & Cheers
Sheryn
|
|
|