Is there a reason why some specific arrangement of scattered grid points would yield bad RBF (Obtuse package) interpolation results?

I have an arrangement of grid points given by the figure below (the datagrid data is posted below at the end of the post):

They correspond to electrode positions of an EEG signal. I am interpolating the field of points using the RBF method in the Obtuse package (the data in data3dznobp is copied at the end of the post).

fun = Interpolation[data3dznobp, Method -> "RBF",
DistanceFunction -> EuclideanDistance,


Running a contour plot of the data yields strange results:

Show[ContourPlot[
fun[x, y], {x, Min[Transpose[datagrid[[Range[63]]]][[1]]],
Max[Transpose[datagrid[[Range[63]]]][[1]]]}, {y,
Min[Transpose[datagrid[[Range[63]]]][[2]]],
Max[Transpose[datagrid[[Range[63]]]][[2]]]},
ColorFunction -> "PigeonTones"],
ListPlot[datagrid, PlotMarkers -> {\[FilledCircle], 7},
PlotStyle -> {Black}]]


A simple ListContourPlot gives an idea of what the data should look like:

ListContourPlot[Transpose[Partition[Flatten[data3dznobp], 3]],
ColorFunction -> "PigeonTones"]


The data is as follows:

datagrid={{-18, 255.55}, {0, 127.8}, {-39, 166.665}, {-54, 255.555}, {-72,
319.445}, {-69, 197.22}, {-45, 88.89}, {-90, 127.78}, {-90,
255.555}, {-108, 319.445}, {-111, 197.22}, {-135, 88.89}, {180,
127.78}, {-141, 166.665}, {-126, 255.555}, {-162, 255.555}, {180,
255.555}, {162, 255.555}, {141, 166.665}, {126, 255.555}, {108,
319.445}, {111, 197.22}, {135, 88.89}, {90, 127.78}, {90,
255.555}, {72, 319.445}, {69, 197.22}, {45, 88.89}, {39,
166.665}, {54, 255.555}, {18, 255.555}, {-38, 255.555}, {-23,
205.555}, {0, 191.665}, {-22, 138.89}, {-49, 208.335}, {-72,
255.555}, {-62, 138.89}, {0, 63.89}, {-90, 63.89}, {-90,
191.666}, {-108, 255.555}, {-118, 138.89}, {-158, 138.89}, {-131,
208.335}, {-144, 255.555}, {-157, 205.555}, {180, 191.665}, {157,
205.555}, {144, 255.555}, {131, 208.335}, {158, 138.89}, {180,
63.89}, {118, 138.89}, {108, 255.555}, {90, 191.665}, {90,
63.89}, {62, 138.89}, {72, 255.555}, {49, 208.335}, {22,
138.89}, {23, 205.555}, {38, 255.555}}

data3dznobp = {{{-18, 255.55}, -6.5739}, {{0, 127.8}, -6.2363}, {{-39,
166.665}, -3.5378}, {{-54, 255.555}, -5.0099}, {{-72,
319.445}, -0.0989}, {{-69, 197.22},
1.7936}, {{-45, 88.89}, -5.4844}, {{-90, 127.78}, -8.0216}, {{-90,
255.555}, -1.4105}, {{-108, 319.445}, -14.113}, {{-111,
197.22}, -1.6699}, {{-135, 88.89},
32.775}, {{180, 127.78}, -11.329}, {{-141,
166.665}, -2.9397}, {{-126, 255.555}, -15.252}, {{-162,
255.555}, -27.238}, {{180, 255.555}, -20.285}, {{162,
255.555}, -15.96}, {{141, 166.665}, -5.817}, {{126,
255.555}, -7.7154}, {{108, 319.445}, -6.8306}, {{111,
197.22}, -6.4974}, {{135, 88.89}, -5.9639}, {{90,
127.78}, -1.4527}, {{90, 255.555}, 0.0393}, {{72, 319.445},
2.0624}, {{69, 197.22}, -1.3429}, {{45, 88.89}, -2.615}, {{39,
166.665}, -2.3825}, {{54, 255.555}, -0.5267}, {{18,
255.555}, -8.0669}, {{-38, 255.555}, -6.5788}, {{-23,
205.555}, -0.8235}, {{0, 191.665}, -0.0289}, {{-22,
138.89}, -7.5299}, {{-49, 208.335}, -4.4647}, {{-72, 255.555},
0.4955}, {{-62, 138.89}, -5.9479}, {{0, 63.89},
0.9733}, {{-90, 63.89}, -0.3306}, {{-90, 191.666}, -5.5189}, {{-108,
255.555}, 6.2573}, {{-118, 138.89},
0.2364}, {{-158, 138.89}, -1.4894}, {{-131,
208.335}, -2.488}, {{-144, 255.555}, -31.974}, {{-157,
205.555}, -19.144}, {{180, 191.665}, -11.368}, {{157,
205.555}, -15.279}, {{144, 255.555}, -14.626}, {{131,
208.335}, -7.4315}, {{158, 138.89},
0.4834}, {{180, 63.89}, -5.1433}, {{118, 138.89}, -11.177}, {{108,
255.555}, -6.7141}, {{90, 191.665}, -3.6082}, {{90,
63.89}, -0.5016}, {{62, 138.89}, -2.5683}, {{72,
255.555}, -1.4882}, {{49, 208.335}, -2.9735}, {{22,
138.89}, -5.4577}, {{23, 205.555}, -7.9206}, {{38,
255.555}, -1.2869}}

• The ContourPlot works perfectly fine for me on Mathematica 10. What version are you using?
– paw
Aug 29, 2014 at 21:11
• I am using Mathematica 8 and 10. Aug 29, 2014 at 21:27
• Could you show a scatter plot of $\{x_i,y_i,z_i\}$?
– rych
Sep 26, 2014 at 4:56
• Could you try different RBF kernels, and different values of $r_0$?
– rych
Sep 26, 2014 at 4:59

I'm not sure about why Obtuse fails here; to present an alternative, use the implementation of thin plate splines in this answer:

data3dznobp = Append @@@ data3dznobp;
d[x_, y_] = polyharmonicSpline[data3dznobp, x, y];

{ListContourPlot[data3dznobp, ColorFunction -> "ThermometerColors"],
ContourPlot[d[x, y], {x, -162, 180}, {y, 63, 320},
ColorFunction -> "ThermometerColors",
Epilog -> {Directive[AbsolutePointSize[5], ColorData[97, 3]],
Point[data3dznobp[[All, {1, 2}]]]}]} // GraphicsRow


If you want to try other RBF kernels, it is a simple matter to replace Φ in the definition of polyharmonicSpline[] with a different kernel.