<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Dear Kirsten,
<div class=""><br class="">
</div>
<div class="">These days I would not recommend the use of ft_megrealign to begin with. In our experience it often does more harm than that it improves results. In particular, if your subjects were relatively well-behaved, and well-positioned in the MEG. This
 might also be one of the reasons, why the code does not run through smoothly, because FieldTrip has evolved quite a bit over the past years. While we take the utmost care to keep the code internally consistent, rarely used functionality might have escaped
 our attention, which may have happened here.</div>
<div class=""><br class="">
</div>
<div class="">This being said, I am not sure whether I understand why the removal of the headshape option allows you to proceed deeper in the code. The second error you report is caused by a dimensionality mismatch, where matlab is asked to concatenate a row-vector
 (interp.label) with a column vector (rest.label). Given the code, it seems that the writer of the code assumed the interp.label to always be a column vector (which happens to be FieldTrip convention). I don’t know how interp.label ended up a row vector, but
 changing line 391 into interp.label = [interp.label(:);rest.label(:)];</div>
<div class="">should do the trick.</div>
<div class=""><br class="">
</div>
<div class="">You could try and fix this on your local copy of fieldtrip, but even better would be to contribute the fix to the release code-base, so that everyone can enjoy it.</div>
<div class="">The way to do this is documented here: <a href="http://www.fieldtriptoolbox.org/development/git" class="">http://www.fieldtriptoolbox.org/development/git</a></div>
<div class=""><br class="">
</div>
<div class="">I am looking forward to your suggested fix.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class=""><br class="">
</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
J.M.Schoffelen, MD PhD<br class="">
Senior Researcher, VIDI-fellow - PI, language in interaction<br class="">
Telephone: +31-24-3614793</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Physical location: room 00.028</div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands<br class="">
<br class="">
<br class="">
</div>
</div>
</div>
</div>
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 7 Nov 2017, at 12:16, Kirsten Herfurth <<a href="mailto:kirsten@carrot-village.de" class="">kirsten@carrot-village.de</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Dear all,<br class="">
<br class="">
I would like to apply the function ft_megrealign to my single subject meg data in order to do sensor level group analysis afterwards. I got stuck with the following error messages:<br class="">
<br class="">
Reference to non-existent field 'xgrid'.<br class="">
Error in ft_prepare_sourcemodel (line 709)<br class="">
 xmin_indx = find(grid.xgrid==xmin);<br class="">
Error in ft_megrealign (line 249)<br class="">
grid = ft_prepare_sourcemodel(tmpcfg);<br class="">
<br class="">
I used the following configuration:<br class="">
cfg=[];<br class="">
cfg.template = {MEGSubject1.grad; MEGSubject2.grad; MEGSubject3.grad, …}; <br class="">
cfg.headmodel = headmodel; <br class="">
cfg.headshape = strcat(Path2MEGData,'hs_file');<br class="">
cfg.inwardshift = 0.025; % in meters<br class="">
cfg.vol.r=headmodel.r;<br class="">
cfg.vol.o=headmodel.o;<br class="">
cfg.vol.label=headmodel.label;<br class="">
[MEGSubject1_realigned] = ft_megrealign(cfg, MEGSubject1) <br class="">
<br class="">
The headmodel was built using the following configuration:<br class="">
cfg =[];<br class="">
cfg.method  = 'localspheres';<br class="">
cfg.grad = MEGsingleSubjectData.grad;<br class="">
headmodel = ft_prepare_headmodel(cfg, headshape); <br class="">
<br class="">
<br class="">
There was a post with the same problem in the mailing list, with the suggestion to uncomment cfg.headshape:
<a href="https://mailman.science.ru.nl/pipermail/fieldtrip/2015-September/009633.html" class="">
https://mailman.science.ru.nl/pipermail/fieldtrip/2015-September/009633.html</a><br class="">
<br class="">
When uncommenting cfg.headshape, it works until I get the following error message:<br class="">
<br class="">
Error using vertcat<br class="">
Dimensions of matrices being concatenated are not consistent.<br class="">
Error in ft_megrealign (line 391)<br class="">
 interp.label = [interp.label; rest.label]; <br class="">
<br class="">
interpol.label is a 1x248 cell array, rest.label is 93x1 cell array.<br class="">
<br class="">
Did I miss something?<br class="">
Thanks a lot for your help in advance,<br class="">
<br class="">
Kirsten<br class="">
<br class="">
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" class="">fieldtrip@donders.ru.nl</a><br class="">
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</div>
</div>
</blockquote>
</div>
<br class="">
</div>
<br class="">
<br class="">
</body>
</html>