[FieldTrip] Problem with ft_megrealign

Daria Laptinskaya daria.laptinskaya at googlemail.com
Fri Sep 18 11:40:13 CEST 2015


Dear Jörn,


yes, I tried the latest version of FT – thank you for the advice!

The function works fine, when I leave out the cfg.headshape:



    cfg = [];

    cfg.headmodel.r = 12;

    cfg.headmodel.o = [0, 0, 4];

    cfg.template    = sens_m;

    cfg.channel     = {'MEG'};

    cfg.inwardshift =  2.5;

   % cfg.headshape   = 'hs_file';



    realigned_data= ft_megrealign(cfg, input_data);



Unfortunately,I still get the following error message, after including the
cfg.headshape.

Reference to non-existent field 'xgrid'.

Error in ft_prepare_sourcemodel (line 665)

  xmin_indx = find(grid.xgrid==xmin);



I thought, that something must be wrong with my headshape-file and tried
the ft_prepare_sourcemodel-function and it’s fine:



shape = ft_read_headshape('hs_file');



cfg = [];

cfg.grid.pos = shape.pnt;

cfg.grid.xgrid  = 'auto';

cfg.grid.ygrid  = 'auto';

cfg.grid.zgrid  = 'auto';

grid = ft_prepare_sourcemodel(cfg, input_data);



My shape/grid-variable looks like this:

 [image: Inline-Bild 1]


Till now I could not find the solution for the problem.

Do someone have an idea?



Thank you very much in advance for your time!



Best,

Daria





2015-09-18 10:12 GMT+02:00 Jörn M. Horschig <jorn at artinis.com>:

> Dear Daria,
>
>
>
> have you tried the most recent version of FT? This should have been
> resolved there.
>
>
>
> Best,
>
> Jörn
>
>
>
> *--*
>
>
>
> *Jörn M. Horschig, PhD*, Software Engineer
>
> Artinis Medical Systems <http://www.artinis.com/>  |  +31 481 350 980
>
>
>
> *From:* fieldtrip-bounces at science.ru.nl [mailto:
> fieldtrip-bounces at science.ru.nl] *On Behalf Of *Daria Laptinskaya
> *Sent:* Tuesday, September 15, 2015 11:36 AM
> *To:* FieldTrip discussion list <fieldtrip at science.ru.nl>
> *Subject:* Re: [FieldTrip] Problem with ft_megrealign
>
>
>
> Dear Jörn,
>
>
>
> 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).  Hence I defined the
> template variable as a cell-array:
>
> Ntemplate = length(cfg.template);
>
> template = cell(Ntemplate, 1);
>
>
>
> and at the end did this:
>
> j = 1;
>
> for i=1:length(template)
>
>
>
>     eval(['tp', num2str(j), ' = template{1};'])
>
>
>
>     j = j+1;
>
> end
>
> template_new = ([tp1, tp2]);
>
> grad = ft_average_sens(template_new);
>
>
>
> Now it works fine, then I leave out the cfg.headshape = ‘hs_file’.  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 :).
>
> 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.
>
> Many thank in advance!
>
>
>
> Best,
>
> Daria
>
>
>
> 2015-09-10 10:52 GMT+02:00 Jörn M. Horschig <jorn at artinis.com>:
>
> Dear Daria,
>
>
>
> try initializing tp_avg just before the for-loop, e.g. by set tp_avg = []
>
>
>
> The error message you got means that you have a function called template
> somewhere in your path. In the command line, you can type
>
> >> which template
>
> 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).
>
> 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 ;)
>
>
>
> Best,
>
> Jörn
>
>
>
>
>
>
>
> *--*
>
>
>
> *Jörn M. Horschig, PhD*, Software Engineer
>
> Artinis Medical Systems <http://www.artinis.com/>  |  +31 481 350 980
>
>
>
> *From:* fieldtrip-bounces at science.ru.nl [mailto:
> fieldtrip-bounces at science.ru.nl] *On Behalf Of *Daria Laptinskaya
> *Sent:* Thursday, September 10, 2015 10:39 AM
> *To:* FieldTrip discussion list <fieldtrip at science.ru.nl>
> *Subject:* [FieldTrip] Problem with ft_megrealign
>
>
>
> Dear all,
>
> I would like to apply the ft_megrealign function to MEG data.
>
> First I tried this:
>
>     cfg             = [];
>
>     cfg.vol.r       = 12;
>
>     cfg.vol.o       = [0, 0, 4];
>
>     cfg.template    = allsens;
>
>     cfg.channel     = {'MEG'};
>
>     cfg.inwardshift =  1;
>
>     cfg.headshape   = 'hs_file';
>
>
>
> new_data = ft_megrealign(cfg, old_data);
>
>
>
> Then I got the following error message:
>
> At compilation, "template" was determined to be a variable and this
> variable is
> uninitialized. "template" is also a function name and previous versions of
> MATLAB would
> have called the function. However, MATLAB 7 forbids the use of the same
> name in the same
> context as both a function and a variable.
>
>
>
> 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):
>
>
>
> Ntp_avg = length(cfg.template);
>
> for i=1:Ntp_avg
>
>   if ischar(cfg.template{i}),
>
>     fprintf('reading template sensor position from %s\n',
> cfg.template{i});
>
>     tp_avg(i) = ft_read_sens(cfg.template{i});
>
>   elseif isstruct(cfg.template{i}) && isfield(cfg.template{i}, 'coilpos')
> && isfield(cfg.template{i}, 'coilori') && isfield(cfg.template{i}, 'tra'),
>
>     tp_avg(i) = cfg.template{i};
>
>   end
>
> end
>
>
>
> No I get an error message, that “the variable tp_avg is not defined”.
>
> Do I forget something? Or do anyone have an other solution for the problem?
>
>
>
> I would appreciate any help / ideas!
>
>
>
> Thanks in advance!
>
>
>
> Best,
>
> Daria
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150918/5acbab94/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7263 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150918/5acbab94/attachment-0001.png>


More information about the fieldtrip mailing list