[FieldTrip] headmovement - circumcenter function

Arjen Stolk a.stolk8 at gmail.com
Wed Jun 21 18:01:20 CEST 2017


Hi Conny,

You're right in that the circumcenter function is missing from the
fieldtrip suite itself, but fortunately it's there at the bottom of the
same wiki page. ;) Just copy it into your editor and save it out to a
preferred matlab path (so it gets prioritized over any version of
cicumcenter that may be in matlab).

Best,
Arjen

On Wed, Jun 21, 2017 at 1:10 AM, Conny Quaedflieg <
cornelia.quaedflieg at uni-hamburg.de> wrote:

> Dear Fieldtrip users,
>
>
>
> I would like to add / regress out headmovement in my MEG data.
>
> I found the nice wiki tutorial from fieldtrip:
>
> http://www.fieldtriptoolbox.org/example/how_to_
> incorporate_head_movements_in_meg_analysis
>
>
>
> However, when running the code I get the following error message:
>
> Undefined function 'circumcenter' for input arguments of type 'double'.
>
>
>
> I checked my paths and circumcenter is in it. Though if I open it, I see
> the following code.
>
> %circumcenter  Circumcenter of triangle or tetrahedron
>
> % CC = circumcenter(TR, TI) returns the coordinates of the circumcenter
>
> %     of each triangle or tetrahedron in TI.
>
> %     TI is a column vector of triangle or tetrahedron IDs corresponding to
>
> %     the row numbers of the triangulation connectivity matrix
> TR.ConnectivityList.
>
> %     CC is an m-by-n matrix, where m is of length(TI), the number of
> specified
>
> %     triangles/tetrahedra, and n is the spatial dimension 2 <= n <= 3.
>
> %     Each row CC(i,:) represents the coordinates of the circumcenter
>
> %     of TI(i). If TI is not specified the circumcenter information for
>
> %     the entire triangulation is returned, where the circumcenter
> associated
>
> %     with triangle/tetrahedron i is the i'th row of CC.
>
> %
>
> %     [CC RCC] = circumcenter(TR, TI) returns in addition, the
> corresponding
>
> %     radius of the circumscribed circle/sphere. RCC is a vector of length
>
> %     length(TI), the number of specified triangles/tetrahedra.
>
> %
>
> %   Example 1: Load a 2D triangulation and use the triangulation to
> compute the
>
> %              circumcenters.
>
> %       load trimesh2d
>
> %       % This loads triangulation tri and vertex coordinates  x, y
>
> %       trep = triangulation(tri, x,y)
>
> %       cc = circumcenter(trep);
>
> %       triplot(trep);
>
> %       axis([-50 350 -50 350]);
>
> %       axis equal;
>
> %       hold on; plot(cc(:,1),cc(:,2),'*r'); hold off;
>
> %       % The circumcenters represent points on the medial axis of the
> polygon.
>
> %
>
> %   Example 2: Direct query of a 3D triangulation created using
> delaunayTriangulation
>
> %              Compute the circumcenters of the first five tetrahedra.
>
> %       X = rand(10,3);
>
> %       dt = delaunayTriangulation(X);
>
> %       [cc rcc] = circumcenter(dt, [1:5]')
>
> %
>
> %   See also triangulation, triangulation.incenter, delaunayTriangulation.
>
> %   Copyright 2008-2012 The MathWorks, Inc.
>
> %   Built-in function.
>
>
>
> It seems to me that the real function is missing. Is this normal? Could
> this be the problem?
>
> I googled circumcenter and found the function, though I am not sure
> whether this is doing what it should do. Besides it also doesn’t run when
> including the 3 coil variables (error messages: Error using circumcenter2
> Too many input arguments.)
>
> Help is really appreciated J
>
> Best
>
> Dr. C. Quaedflieg, Hamburg University
>
>
>
>
>
> The code that I Found for circumcenter
>
>
>
> function [ pc, r ] = circumcenter ( p, t )
>
>
>
> %***********************************************************
> ******************80
>
> %
>
> %% CIRCUMCENTER computes the circumcenters of a set of triangles.
>
> %
>
> %  Discussion:
>
> %
>
> %    The circumcenter of a triangle is the circle which passes through
>
> %    all three vertices of the triangle.
>
> %
>
> %  Licensing:
>
> %
>
> %    (C) 2004 Per-Olof Persson.
>
> %    See COPYRIGHT.TXT for details.
>
> %
>
> %  Reference:
>
> %
>
> %    Per-Olof Persson and Gilbert Strang,
>
> %    A Simple Mesh Generator in MATLAB,
>
> %    SIAM Review,
>
> %    Volume 46, Number 2, June 2004, pages 329-345.
>
> %
>
> %  Modified:
>
> %
>
> %    11 June 2004
>
> %
>
> %  Parameters:
>
> %
>
> %    Input, real P(NP,2), the coordinates of a set of nodes.
>
> %
>
> %    Input, integer T(NT,1:3), a list of the nodes which make up each
> triangle
>
> %    of a triangulation of the nodes in P.
>
> %
>
> %    Output, real PC(NT,2), the centers of the circumcircles.
>
> %
>
> %    Output, real R(NT,1), the radii of the circumcircles.
>
> %
>
>   nt = size ( t, 1 );
>
>
>
>   pc = zeros ( nt, 2 );
>
>   r  = zeros ( nt, 1 );
>
>
>
>   for it = 1 : nt
>
>
>
>     ct = t(it,:);
>
>     dp1 = p(ct(2),:) - p(ct(1),:);
>
>     dp2 = p(ct(3),:) - p(ct(1),:);
>
>
>
>     mid1 = ( p(ct(2),:) + p(ct(1),:) ) / 2;
>
>     mid2 = ( p(ct(3),:) + p(ct(1),:) ) / 2;
>
>
>
>     s = [ -dp1(2), dp2(2); dp1(1), -dp2(1) ] \ [ -mid1 + mid2 ]';
>
>
>
>     cpc = mid1 + s(1) * [ -dp1(2), dp1(1) ];
>
>     cr = norm ( p(ct(1),:) - cpc );
>
>
>
>     pc(it,:) = cpc;
>
>     r(it,1) = cr;
>
>
>
>   end
>
>
>
>   return
>
> end
>
>
>
>
>
> Mit freundlichen Grüßen,
>
>
>
>
>
> [image: Unbenannt-1]
>
> *E-Mail*: cornelia.quaedflieg at uni-hamburg.de
>
> *Tel.*: +49 40 42838-5448 <+49%2040%2042838-5448>   *Website*: Hyperlink
> <https://www.psy.uni-hamburg.de/arbeitsbereiche/kognitionspsychologie/personen/quaedflieg-conny.html>
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170621/2d23da2b/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 5394 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170621/2d23da2b/attachment-0002.jpg>


More information about the fieldtrip mailing list