Back to the main page.

Bug 2858 - ft_sourcegrandaverage error due to .pos field

Status CLOSED WORKSFORME
Reported 2015-02-24 19:15:00 +0100
Modified 2016-06-14 16:18:22 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Rodolfo - 2015-02-24 19:15:02 +0100

Hi everyone, I´m trying to do the grand average of two source files, but I receive the following error: the input sources vary in the field pos I´m pretty sure I assigned the same .pos structure to both files from a template grid, I checked and they are identical. Below is the code, and the link for the cell array with the two source structures and the template grid is here: https://www.dropbox.com/sh/3ckvvwommnsznl7/AABHeddj6Nv4hmV0g03RTRI6a?dl=0 cfg = []; cfg.keepindividual = 'no'; for ifq = 1%:numel(freq) for icontr = 1%:numel(contrast_name) grandsource = ft_sourcegrandaverage(cfg,grand{:,ifq,icontr}); end end Thanks! Rodolfo


Robert Oostenveld - 2015-02-26 13:24:02 +0100

I have downloaded the data to /home/common/matlab/fieldtrip/data/test/bug2858 and can confirm the problem. Inside ft_sourcegrandaverage after ft_checkdata the grid positions somehow seem to have changed from the regular (integer) values to the warped-to-individual slightly irregular values. The latter are (of course) different between the subjects. But it remains a mystery sofa where and why the conversions happens.


Robert Oostenveld - 2015-02-26 13:42:55 +0100

ah, found it. If I do load grand source = grand{1}; changed = ft_checkdata(source); it passes through ft_datatype_source. So in changed = ft_datatype_source(source); the output pos is already changed. in lines 135-... in ft_datatype_source there is for i=1:length(fn) dat = source.avg.(fn{i}); if isequal(size(dat), [1 size(source.pos,1)]) source.(fn{i}) = dat'; else source.(fn{i}) = dat; end clear dat end % j which copies all fields over from source.avg. Now note that >> source source = freq: 9.9448 dim: [17 20 17] filter: {1x5780 cell} inside: [5780x1 logical] pos: [5780x3 double] method: 'average' avg: [1x1 struct] cfg: [1x1 struct] >> source.avg ans = pow: [1x5780 double] noise: [1x5780 double] filter: {1x5780 cell} inside: [5780x1 logical] pos: [5780x3 double] so source.avg.pos contains positions which are copied OVER source.pos. The source.avg.pos positions are the individualised ones, whereas source.pos is the regular grid in MNI space. Now the question is: how did source.avg.pos get there in the first place? FieldTrip should not put it there, but recent changes to the handing of source data may have caused this to happen for a short window of time. Right now I cannot reproduce ft_sourceanalysis resulting in source.avg.pos any more, so to me it seems that it has been resolved already. I recommend you rerun your source analysis, or that you remove source.avg.pos from your existing data structures.


Robert Oostenveld - 2016-06-14 16:18:22 +0200

Hereby I am closing several bugs that have been resolved for some time (WONTFIX, WORKSFORME, etc.). If you disagree, please reopen and explain.