trilinear interpolation from regular grid in R

603 views
Skip to first unread message

Sinead English

unread,
Oct 17, 2012, 6:48:37 AM10/17/12
to egi-progra...@googlegroups.com
Hi all

(Not sure if this list is still active but desperation calls!) 

Does anyone know of a R function that conducts trilinear interpolation from a 3D array in R - something like interp3 in Matlab? I've written a function myself but it would be nice to use an inbuilt function if it exists. I've searched high and low on various R help lists to no avail. 

Thanks!
Sinead

Cam Allen

unread,
Oct 17, 2012, 7:21:08 AM10/17/12
to egi-progra...@googlegroups.com
Sinead, 

The list exists - but i wouldn't say it is active!

A quick googling shows that no R function exists to do this, perhaps there are C/C++ libs out there that you can use to do this, perhaps, http://www.matpack.de/ ?


You should be able to link into C++ libs from R to call this stuff.

I hope this helps.
cam



Sinead

--
You received this message because you are subscribed to the Google Groups "EGI programming and R" group.
To post to this group, send email to egi-progra...@googlegroups.com.
To unsubscribe from this group, send email to egi-programming-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/egi-programming-and-r?hl=en.

Sinead English

unread,
Oct 17, 2012, 7:57:11 AM10/17/12
to egi-progra...@googlegroups.com
Thanks Cam! Looks like I'll have to bite the bullet and learn about calling C++ from R, it will probably make life easier in the long-run anyway...
Sinead

Cam Allen

unread,
Oct 17, 2012, 8:00:23 AM10/17/12
to egi-progra...@googlegroups.com
Looks like google has some good refs...

Give me a shout if you need.
cam

Sinead English

unread,
Oct 23, 2012, 7:56:17 AM10/23/12
to egi-progra...@googlegroups.com
Hi all - quick update, in the extremely unlikely event anyone wants to interpolate data across a 3-D array (which I ended up not needing to do after all), here's a potential solution:

On 18 October 2012 18:18, Dr Gregory Jefferis <gsx...@cam.ac.uk> wrote:
Dear Sinead,

I'm afraid I never found a good solution in R. In the end, I just treated this as image data and did smoothing/resampling in 3rd party software, either ImageJ/Fiji, or my preferred solution with a command line tool called unu:


For this I wrote some routines to save my 3D data blocks in an image format called nrrd and call the unu tool and particularly the 

unu resample command

The R code is available along with a load of other code here


NrrdResample is the function that I use from within R that does this in one go. You do have to build teem/unu from source so this may be a disincentive but I have subsequently used that tool for a wide variety of 3d image processing problems so it was worthwhile.

If you want to export 3d image data from R and export it eg for use in imagej, then the most mature packages (read those you can install straight from cran without any mucking around) are those by medical imaging people built around the nifti image format.



Best wishes,

Greg.

(and yes amusing that you are at zoo.ox.ac.uk and I was at zoo.cam.ac.uk!)

On 17 Oct 2012, at 11:22, Sinead English wrote:

Dear Dr Jefferis

Apologies for contacting you out of the blue: I have been searching for a function in R to conduct trilinear interpolation from a regular 3D array and I noticed you had a very similar query about six years ago (!) 

As there were no responses online to your question, I was wondering if you ever found a solution? If you could point me toward a relevant R library, I'd be most grateful. So far I've only managed to find 2D interpolation functions (e.g. interp.surface.grid from the fields library). 

Thank you in advance and best wishes, 
Sinead

--
Dr Sinead English
Postdoctoral Research Associate
Edward Grey Institute, Department of Zoology
University of Oxford, OX1 3PS
Tel: +44 (0)1865 271203
http://www.zoo.ox.ac.uk/egi/members/sinead-english/
Reply all
Reply to author
Forward
0 new messages