<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Dear Fieldtrippers,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am a PhD student with at UC Louvain and am currently working on source-space analysis of 256 channel EEG data.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am having troubles using ft_electroderealign as follows to project my electrodes to the surface of the scalp. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">cfg = [];</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">cfg.method =
</span><span style="font-size:13.0pt;font-family:"Courier New";color:#A020F0">'headshape'</span><span style="font-size:13.0pt;font-family:"Courier New";color:black">;</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">cfg.elec = elec_prealigned;
</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">cfg.warp =
</span><span style="font-size:13.0pt;font-family:"Courier New";color:#A020F0">'rigidbody'</span><span style="font-size:13.0pt;font-family:"Courier New";color:black">;
</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">cfg.headshape = mesh;</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">elec_aligned = ft_electroderealign(cfg);</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt">This fails with the following error message:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><i>Reference to non-existent field 'pos'.<o:p></o:p></i></p>
<p class="MsoNormal"><i>Error in ft_warp_error (line 57)<o:p></o:p></i></p>
<p class="MsoNormal"><i> el = project_elec(input, target.pos, target.tri);<o:p></o:p></i></p>
<p class="MsoNormal"><i>Error in fminunc (line 253)<o:p></o:p></i></p>
<p class="MsoNormal"><i> f = feval(funfcn{3},x,varargin{:});<o:p></o:p></i></p>
<p class="MsoNormal"><i>Error in ft_warp_optim (line 129)<o:p></o:p></i></p>
<p class="MsoNormal"><i> rf = optimfun(errorfun, ri, options, pos1, pos2, 'rigidbody');<o:p></o:p></i></p>
<p class="MsoNormal"><i>Error in ft_electroderealign (line 361)<o:p></o:p></i></p>
<p class="MsoNormal"><i> [norm.chanpos, norm.m] = ft_warp_optim(elec.chanpos, headshape, cfg.warp);<o:p></o:p></i></p>
<p class="MsoNormal"><i>Caused by:<o:p></o:p></i></p>
<p class="MsoNormal"><i> Failure in initial user-supplied objective function evaluation. FMINUNC cannot<o:p></o:p></i></p>
<p class="MsoNormal"><i> continue.<o:p></o:p></i></p>
<p class="MsoNormal"><i><o:p> </o:p></i></p>
<p class="MsoNormal"><span style="font-size:12.0pt">The electrode-positions come in the format of the EGI template, however, the coordinates have been exchanged for the actual coordinates on the individual participant (done manually from the MRI).
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">The Fid positions have been removed.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">So the struct looks like this:<o:p></o:p></span></p>
<p class="MsoNormal">>> disp (elec_prealigned)<o:p></o:p></p>
<p class="MsoNormal"> chanpos: [256x3 double]<o:p></o:p></p>
<p class="MsoNormal"> elecpos: [256x3 double]<o:p></o:p></p>
<p class="MsoNormal"> homogeneous: [4x4 double]<o:p></o:p></p>
<p class="MsoNormal"> label: {256x1 cell}<o:p></o:p></p>
<p class="MsoNormal"> type: 'egi256'<o:p></o:p></p>
<p class="MsoNormal"> unit: 'cm'<o:p></o:p></p>
<p class="MsoNormal"> cfg: [1x1 struct]<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt">Mesh is the following structure:<o:p></o:p></span></p>
<p class="MsoNormal"> <span lang="FR">hex: [4794932x8 double]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> pnt: [4940731x3 double]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> labels: [4794932x1 double]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> tissue: [4794932x1 double]<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"> </span>tissuelabel: {'air' 'csf' 'gray' 'scalp' 'skull' 'white'}<o:p></o:p></p>
<p class="MsoNormal"> unit: 'mm'<o:p></o:p></p>
<p class="MsoNormal"> cfg: [1x1 struct]<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">At the point where it crashes, ‘target’ looks like this:<o:p></o:p></p>
<p class="MsoNormal"> disp(target)<o:p></o:p></p>
<p class="MsoNormal"> pnt: [4940731x3 double]<o:p></o:p></p>
<p class="MsoNormal"> poly: [291320x4 double]<o:p></o:p></p>
<p class="MsoNormal"> unit: 'cm'<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It looks like the headshape created in ft_electroderealign lines 249-259<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black">(
</span><span style="font-size:10.0pt;font-family:"Courier New";color:blue">if</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> isstruct(cfg.headshape) && isfield(cfg.headshape,
</span><span style="font-size:10.0pt;font-family:"Courier New";color:#A020F0">'hex'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">)</span><span style="font-size:10.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.headshape = fixpos(cfg.headshape);</span><span style="font-size:10.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> headshape = mesh2edge(cfg.headshape);</span><span style="font-size:13.0pt;font-family:"Courier New";color:black"> )</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:13.0pt;font-family:"Courier New";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none">is used as the ‘target’ input for
<span style="font-size:13.0pt;font-family:"Courier New";color:black"> ft_warp_optim(elec.chanpos, headshape, cfg.warp);</span><span style="font-size:12.0pt;font-family:"Courier New""><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none">in line 361.<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">I tried replacing the input by cfg.headshape, but then the .tri field is still missing…<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">Would anyone have a suggestion as to what I am doing wrong here?<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">Thanks a lot!<o:p></o:p></p>
<p class="MsoNormal" style="text-autospace:none"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none">Kirsten<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>