[FieldTrip] Problem with ft_megrealign

Jörn M. Horschig jorn at artinis.com
Thu Sep 10 10:52:46 CEST 2015


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

 <http://www.artinis.com/> Artinis Medical Systems  |  +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     

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150910/16dfc9c3/attachment-0002.html>


More information about the fieldtrip mailing list