<div dir="ltr">
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">Dear Jörn,</span></p><p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US"><br></span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">thank you
very much for your helpful answer! I did not want to answer before running the
function. First I got an error message with the notice that separate structures
of the cfg.template could not be translated into a variable of the type double
(template variable).<span style="mso-spacerun:yes"> </span>Hence I defined the
template variable as a cell-array: </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">Ntemplate = length(cfg.template);</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">template = cell(Ntemplate, 1);</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">and at the end
did this: </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">j = 1;</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:blue" lang="EN-US">for</span><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"> i=1:length(template)</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span>eval([</span><span style="font-size:10pt;font-family:"Courier New";color:rgb(160,32,240)" lang="EN-US">'tp'</span><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">, num2str(j), </span><span style="font-size:10pt;font-family:"Courier New";color:rgb(160,32,240)" lang="EN-US">' = template{1};'</span><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">])<span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span>j = j+1;</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:blue" lang="EN-US">end</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:blue" lang="EN-US"><span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">template_new = ([tp1, tp2]);</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US"><span style="mso-spacerun:yes"> </span></span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal"><span style="font-size:10pt;font-family:"Courier New";color:black" lang="EN-US">grad = ft_average_sens(template_new);</span><span style="font-size:12pt;font-family:"Courier New"" lang="EN-US"></span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">Now it
works fine, then I leave out the cfg.headshape = ‘hs_file’. <span style="mso-spacerun:yes"> </span>Using this command is leading to the following
error message: Reference to non-existent field 'xgrid'. I understand the
message, but could not fix the problem till now. I could swear, it worked some
time ago :). </span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">I’m sorry
to bother you with this, but I would appreciate, if you or someone else could
give me a further tip, how to solve the problem.</span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">Many thank
in advance!</span></p><p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US"><br></span></p>
<p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">Best, <br></span></p><p class="MsoNormal"><span style="mso-ansi-language:EN-US" lang="EN-US">Daria</span></p>
</div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-10 10:52 GMT+02:00 Jörn M. Horschig <span dir="ltr"><<a href="mailto:jorn@artinis.com" target="_blank">jorn@artinis.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="#0563C1" vlink="#954F72" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Dear Daria,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">try initializing </span><span style="font-family:"Arial",sans-serif">tp_avg </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">just before the for-loop, e.g. by set tp_avg = []<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The error message you got means that you have a function called template somewhere in your path. In the command line, you can type <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">>> which template<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">to find out where function is located. Afaik it’s not a FieldTrip function. Anyway, to fix this, the template variable should have been initialized in the same vein as I described above. I’ll quickly fix this so that this does not happen anymore in the new version (from tomorrow onwards). <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">This means, also for you the fix would have been just to initialize the template variable rather than renaming the variable, but your solution also works fine after initializing the variable ;)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Best,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Jörn<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264">--<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255a9e"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255a9e">Jörn M. Horschig, PhD</span></b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264">, Software Engineer</span><b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:black"><u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264" lang="NL"><a href="http://www.artinis.com/" target="_blank"><span style="color:#626264" lang="EN-US">Artinis Medical Systems</span></a></span><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264"> | <a href="tel:%2B31%20481%20350%20980" value="+31481350980" target="_blank">+31 481 350 980</a> </span><b><span style="font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255a9e"><u></u><u></u></span></b></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> <a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a> [mailto:<a href="mailto:fieldtrip-bounces@science.ru.nl" target="_blank">fieldtrip-bounces@science.ru.nl</a>] <b>On Behalf Of </b>Daria Laptinskaya<br><b>Sent:</b> Thursday, September 10, 2015 10:39 AM<br><b>To:</b> FieldTrip discussion list <<a href="mailto:fieldtrip@science.ru.nl" target="_blank">fieldtrip@science.ru.nl</a>><br><b>Subject:</b> [FieldTrip] Problem with ft_megrealign<u></u><u></u></span></p></div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Dear all,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">I would like to apply the ft_megrealign function to MEG data.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">First I tried this:</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg = [];</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.vol.r = 12;</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.vol.o = [0, 0, 4];</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.template = allsens;</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.channel = {</span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'MEG'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">};</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.inwardshift = 1;</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> cfg.headshape = </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'hs_file'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">;</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">new_data = ft_megrealign(cfg, old_data);</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><u></u><u></u></p><p class="MsoNormal" style="text-align:justify"><span style="font-family:"Arial",sans-serif;color:black">Then I got the following error message:</span><u></u><u></u></p><p class="MsoNormal" style="text-align:justify"><span style="font-family:"Arial",sans-serif">At compilation, "template" was determined to be a variable and this variable is<br>uninitialized. "template" is also a function name and previous versions of MATLAB would<br>have called the function. However, MATLAB 7 forbids the use of the same name in the same<br>context as both a function and a variable.</span><u></u><u></u></p><p class="MsoNormal" style="text-align:justify"><span style="font-family:"Arial",sans-serif"> </span><u></u><u></u></p><p class="MsoNormal" style="text-align:justify"><span style="font-family:"Arial",sans-serif">I thought that renaming the variable “template” would solve the problem and did the following within the original function (replaced the template-variable with the Ntp_avg variable):</span><u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black">Ntp_avg = length(cfg.template);</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">for</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> i=1:Ntp_avg</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.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"> ischar(cfg.template{i}),</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> fprintf(</span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'reading template sensor position from %s\n'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">, cfg.template{i});</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> tp_avg(i) = ft_read_sens(cfg.template{i});</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:blue">elseif</span><span style="font-size:10.0pt;font-family:"Courier New";color:black"> isstruct(cfg.template{i}) && isfield(cfg.template{i}, </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'coilpos'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">) && isfield(cfg.template{i}, </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'coilori'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">) && isfield(cfg.template{i}, </span><span style="font-size:10.0pt;font-family:"Courier New";color:#a020f0">'tra'</span><span style="font-size:10.0pt;font-family:"Courier New";color:black">),</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> tp_avg(i) = cfg.template{i};</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:black"> </span><span style="font-size:10.0pt;font-family:"Courier New";color:blue">end</span><u></u><u></u></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">end</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">No I get an error message, that “the variable tp_avg is not defined”.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Do I forget something? Or do anyone have an other solution for the problem?</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">I would appreciate any help / ideas!</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Thanks in advance!</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Best,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Daria </span><u></u><u></u></p></div></div></div></div></div></div><br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>