# [FieldTrip] triple triangulation in ft_prepare_neighbours

Jörn M. Horschig jorn at artinis.com
Mon Jul 6 15:01:45 CEST 2015

```Hi Thomas,

back then, I implemented this because of various reasons. The most important one is that a triangulation essentially wants to do what the name implies, i.e. it creates triangles. Another important characteristic of the Delaunay triangulation is that triangles may not cross. However, when it comes to defining neighbouring EEG electrodes, it does not make much sense to stick to these notions - why should there only be triangular shapes? And why may neighbor-lines not cross? Imagine e.g. four electrodes at (-1, -1), (-1, 0), (0, -1) and (0, 0), intuitively one would define all these as neighbours to each other:
o-o
|x|
o-o

A proper triangulation, however, would need to choose one out of these options:
o-o
|\|
o-o

or:

o-o
|/|
o-o

Neither the one nor the other seems better than the other, and neither of these two seems better than the intuitive, crossing example.

Having identified this problem, and being faced with the fact that I cannot change how the algorithm works, I decided to take the pragmatic route by changing the input parameters to the algorithm rather than the algorithm itself. By these scaling factors, the algorithm ends up with slightly different solutions, which combined can include above mentioned crossings. This solution was designed with having more or less regular grids in mind. I am not sure how this will perform with irregular grids, but I would be curious to know what issue you are running into.

In order to resolve your problem, you might want to have a look at the ft_neighbourplot function, which allows you to manually adjust the neighbours (currently not working for Matlab >2014a). Maybe that one helps for a proper definition of your sensors? I did this for all these neighbor templates that are in FieldTrip. Best would be to then to make your individual template and use that consistently for your experiment.

Hope that helps in understanding why these lines of code are in there and in getting you where you want ;)

Best,
Jörn

--

Jörn M. Horschig, PhD, Software Engineer
Artinis Medical Systems  |  +31 481 350 980

> -----Original Message-----
> From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-
> bounces at science.ru.nl] On Behalf Of Thomas Hartmann
> Sent: Thursday, July 2, 2015 2:08 PM
> To: fieldtrip at science.ru.nl
> Subject: [FieldTrip] triple triangulation in ft_prepare_neighbours
>
> hi,
> if i use the triangulation method to define my neighbours, it does essentially
> this:
>
>        tri = delaunay(prj(:,1), prj(:,2));
>        tri_x = delaunay(prj(:,1)./2, prj(:,2));
>        tri_y = delaunay(prj(:,1), prj(:,2)./2);
>        tri = [tri; tri_x; tri_y];
>        neighbours = compneighbstructfromtri(chanpos, label, tri);
>
> where prj is a 2d projection of the 3d sensor positions. i wonder why the two
> extra triangulations (those resulting in tri_x and tri_y) are in there? they
> compress the data once in the x and the other time in the y dimension and
> repeat the triangulation. the results are mostly redundant but there are
> some extra neighbors that do not seem to make any sense to me.....
>
> best,
> thomas
>
> --
> Dr. Thomas Hartmann
>
> CIMeC - Center for Mind/Brain Sciences
> Università degli Studi di Trento
> via delle Regole, 101
> 38123 Mattarello (TN)
> ITALY
>
> Tel: +39 0461 28 2779
> Fax: +39 0461 28 3066
> Email: thomas.hartmann at th-ht.de
>
> "I am a brain, Watson. The rest of me is a mere appendix. " (Arthur Conan
> Doyle)
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

```