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

Home » Public Forums » archive » Re: VECTOR_FIELD trouble
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: VECTOR_FIELD trouble [message #49843] Wed, 23 August 2006 07:26
Jo Klein is currently offline  Jo Klein
Messages: 54
Registered: January 2006
Member
Thanks for your insights. I've been able to narrow down the problem with
your code, first problem was that I hadn't set up my plot window
correctly (d'uh). Then I realised that PLOTS will connect all of the
data points, which is not what I need. Of course, I can use a loop to
draw my vectors:
for i=0,10000 do plots,outvert[*,2*i:2*i+1]
but that is quite inefficient. I was playing with IVector a bit, which
does a good job at displaying my vectors, and can draw line segments
when I set the head length to 0.
The direct graphics equivalent, VELOVECT, is painfully slow though, and
judging from the source code, uses the same loop approach that I've tried.
I wonder if there's a more intelligent way to plot my line segments,
i.e. avoiding the loop? Alternating between plotting and not plotting
line segments in some way?
Thanks everyone,
Jo
Re: VECTOR_FIELD trouble [message #49854 is a reply to message #49843] Tue, 22 August 2006 10:28 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Jo Klein wrote:
> Dear IDL wizards,
> Has anyone got experience with the use of VECTOR_FIELD? The data I have
> is quite simple: It's a volume of vectors, where for each spatial
> position of a 3D regular grid I've got x, y and z as the projections of
> a unit-length vector centred on those grid locations. It's volume data
> from diffusion tensor MRI, and the vectors describe apparent diffusion
> directions at any given point in the object studied (a brain, in this
> case). So, to visualise the vectors, I browsed the docs and thought
> VECTOR_FIELD should do the job, but I can't figure out how to use it.
> One slice extracted from the data looks like this (z dimension of the
> vectors dropped):
> IDL> help,myslice
> MYSLICE FLOAT = Array[2, 128, 104]
> IDL> print,myslice[*,60:62,50]
> -0.393992 0.305778
> -0.353878 0.368543
> -0.505301 0.394556
> I set up my vectors like this:
> IDL> vector_field,myslice,outverts,outconn
> IDL> plots,outverts
> .. and the result is a window with just a wobbly looking vertical line,
> instead of lots of little vectors on a rectangular region.
> IDL> print,outverts[*,10000:10002]
> 8.00000 39.0000
> 8.00000 39.0000
> 9.00000 39.0000
>
> I suppose I'm misinterpreting how IDL would like my input data to be
> formatted, but as there are no examples in the VECTOR_FIELD docs, I'm a
> bit at a loss here.
> I'd appreciate any help you can give.
> Thanks a lot everyone,

What's probably happening here is that some of the vectors you're
displaying are much longer than the spacing between the elements of
your array, probably in the vertical direction. For example, I put
together a test case as follows:

IDL> x = indgen(20)#replicate(1,30)
IDL> y = replicate(1,20)#indgen(30)
IDL> field = fltarr(2,20,30)
IDL> field[0,*,*] = (x+y)*(x-y)
IDL> field[1,*,*] = (x*x+y*y)
IDL> VECTOR_FIELD,field,outverts,outconn
% Compiled module: VECTOR_FIELD.
IDL> plots,outverts[0,*],outverts[1,*],psym=3

The results looked pretty wierd. However, if you restrict the range, it
gets clearer:

IDL> plot,outverts[0,*],outverts[1,*],psym=3,xrange=[-10,40]

The problem was the following:
IDL> print,max(field),min(field)
361.000 -841.000

The solution is scale the vectors to make them fit between the grid
points:

IDL> VECTOR_FIELD,field,outverts,outconn,SCALE=0.0005
IDL> plot,outverts[0,*],outverts[1,*],psym=3
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: jpeg text field
Next Topic: Re: reduce the size of eps

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

Current Time: Wed Oct 08 17:47:57 PDT 2025

Total time taken to generate the page: 0.00520 seconds