2

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

Scattered Grid Point Positions

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, 
  RadialBasisFunction -> Automatic]

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}]]

RBF interpolation: visibly wrong

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

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

List Contour Plot

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}}
Kuba
  • 136,707
  • 13
  • 279
  • 740
user13675
  • 947
  • 1
  • 6
  • 15

1 Answers1

4

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

raw data with thin plate spline interpolant

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574