[FieldTrip] Problem with ft_megrealign

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Tue Nov 7 21:46:49 CET 2017


Dear Kirsten,

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.

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(:)];
should do the trick.

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.
The way to do this is documented here: http://www.fieldtriptoolbox.org/development/git

I am looking forward to your suggested fix.

Best wishes,

Jan-Mathijs


J.M.Schoffelen, MD PhD
Senior Researcher, VIDI-fellow - PI, language in interaction
Telephone: +31-24-3614793
Physical location: room 00.028
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands




On 7 Nov 2017, at 12:16, Kirsten Herfurth <kirsten at carrot-village.de<mailto:kirsten at carrot-village.de>> wrote:

Dear all,

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:

Reference to non-existent field 'xgrid'.
Error in ft_prepare_sourcemodel (line 709)
 xmin_indx = find(grid.xgrid==xmin);
Error in ft_megrealign (line 249)
grid = ft_prepare_sourcemodel(tmpcfg);

I used the following configuration:
cfg=[];
cfg.template = {MEGSubject1.grad; MEGSubject2.grad; MEGSubject3.grad, …};
cfg.headmodel = headmodel;
cfg.headshape = strcat(Path2MEGData,'hs_file');
cfg.inwardshift = 0.025; % in meters
cfg.vol.r=headmodel.r;
cfg.vol.o=headmodel.o;
cfg.vol.label=headmodel.label;
[MEGSubject1_realigned] = ft_megrealign(cfg, MEGSubject1)

The headmodel was built using the following configuration:
cfg =[];
cfg.method  = 'localspheres';
cfg.grad = MEGsingleSubjectData.grad;
headmodel = ft_prepare_headmodel(cfg, headshape);


There was a post with the same problem in the mailing list, with the suggestion to uncomment cfg.headshape: https://mailman.science.ru.nl/pipermail/fieldtrip/2015-September/009633.html

When uncommenting cfg.headshape, it works until I get the following error message:

Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in ft_megrealign (line 391)
 interp.label = [interp.label; rest.label];

interpol.label is a 1x248 cell array, rest.label is 93x1 cell array.

Did I miss something?
Thanks a lot for your help in advance,

Kirsten

_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto: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/20171107/6c61db5d/attachment-0002.html>


More information about the fieldtrip mailing list