[FieldTrip] Problem with ft_megrealign

Daria Laptinskaya daria.laptinskaya at googlemail.com
Tue Sep 15 11:36:15 CEST 2015


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150915/923298df/attachment-0002.html>


More information about the fieldtrip mailing list