Gridding Functions

Brian Hargreaves and Philip Beatty


This is a work-in-progress. Please check back for updates, and check software carefully before using!

Gridding is a method of interpolating data from an arbitrary 2D sampling pattern to a uniform grid. In MRI, this allows rapid image reconstruction. There are numerous publications on MR gridding reconstruction - I'll try to add these soon!

Included on this site are some Matlab gridding functions that will help you get started with gridding reconstructions. I have avoided making generalizations about what method is best(!)

Functions Included

The tar file includes numerous .m scripts, and C code that can be compiled to a .mex function.

Useful Matlab Functions:

  • gridkb.m -- Matlab gridding function that does most of what you need. (Requires other functions!)
  • plotgridkb.m -- Nice utility to plot the grid samples, and the convolution of samples with the kernel to check your parameters.
  • plotgridkbkernel.m -- Utility to plot the convolution kernel used by gridkb.m finely.
  • plotlutkernel.m -- Similar Utility to plot the kernel passed to gridlut.m kernel finely.
  • calcdcflut.m -- Calculate the density compensation factors using a lookup-table. (We still need a "calcdcfkb.m" ).

Support Functions:

  • gridlut.m -- Gridding, using an arbitrary kernel-lookup. (Calls gridlut_mex, which is a compiled MEX function whose extension depends on the operating system used.)
  • kb.m -- Calculate the Kaiser-Bessel function used in gridding kernel calculation. (Called by calckbkernel.m)
  • calckbkernel.m -- Calculate the Kaiser-Bessel kernel.

C and MEX functions:

  • gridlut_mex.c -- MEX interface to C function for gridding.
  • calcdcflut_mex.c -- MEX interface to C function for calculating the density compensation factors for gridding.
  • gridroutines.c -- General C functions for gridding.

This is a sample illustrating how gridding convolves arbitrary sample points (in this case a spiral) with a kernel. The convolved data are then sampled onto a uniform grid (shown by small dots) so that they can be Fourier transformed using the FFT.

Download Instructions

Save the tar file, gridding.tar to your computer. To extract the files, execute "tar -xvf gridding.tar" from the directory where you have saved the file.

You will need to compile the MEX functions - in Matlab try "mex gridlut_mex.c" and "mex calcdcflut_mex.c" These should result in files gridlut_mex.mex??? and calcdcflut_mex.mex??? where ??? depends on your operating system. It is unlikely that I can help you with Mex compiles!


This is a fairly low-resolution example use of the gridding function here.
  1. Download the grid functions described above.
  2. If you don't have them, download spiralexampledata.mat and spiralexample.m
  3. Run the function spiralexample.m in Matlab.
Your results should look something like the picture below, which you can click to enlarge:

I'll put a higher resolution example here soon!


Please report comments/bugs with this code to Brian Hargreaves.

Last updated Sept 27, 2004