[Insight-users] python prototyping advice

Charles Moad cmoad at indiana.edu
Wed Aug 17 09:29:57 EDT 2005


> The approach in matlab is to generate coordinate images and operate on them e.g
> 
> dist = sqrt((xcoords - xcog).^2 + (ycoords - ycog).^2);
> 
> result = mask * dist
> 
> How do I do something equivalent in python? Is this where the numarray
> stuff comes in?
> 

Numarray is pretty much what you are wanting.  It would allow you to 
transparently perform simple ops on arrays like your sample line above.

Assuming xcoords, xcog, ycoords, etc. are arrays.

dist = sqrt((xcoords - xcog)**2 + (ycoords - ycog)**2)
result = mask * dist

- Charlie


More information about the Insight-users mailing list