Back to the main page.

Bug 1986 - wrong channel alignment by ft_combineplanar and ft_xxxgrandaverage when interpolated channels are present

Status CLOSED FIXED
Reported 2013-02-14 11:52:00 +0100
Modified 2015-07-15 13:27:25 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 major
Assigned to: Jim Herring
URL:
Tags:
Depends on:
Blocks:
See also:

Philipp Ruhnau - 2013-02-14 11:52:24 +0100

Created attachment 423 exemplary data file one subject Dear fieldtrip developers, I noticed some peculiar results in some current tf data. this bug might be related to http://bugzilla.fcdonders.nl/show_bug.cgi?id=1607 , but i think it is even more than just plotting issues. basics: here at CIMeC (Trento) we have a Neuromag machine with 306 sensors (102magnetometers, 204 gradiometers). this what i did: first i identify bad channels, which are unfortunately different across subjects, and then i remove them and do standard preprocessing and compute time frequency representations on the good channels. to look at sensor space data, i interpolate the missing channels using ft_channelrepair, this appends the interpolated channels at the end of the powsctrm and the label field. when i now compute the planar gradient using ft_combineplanar the result for individual subjects looks weird, e.g., alpha power is not just present at parietal sensors but also at one or two sensor at the front (non-adjacent) whereas not on other sensors (see figure non_reordered). I was first thinking that this might be a bad channel or an artifact (eye movement…) the magnetometer topographies, however, seemed right. i get similarly looking results when computing the grand average. again not only dominant alpha at the back of the head but also at two or three non-adjacent sensors frontally/temporally. after some digging in the respective functions i think i found the reason. it is the result of wrong channel matching across gradiometers (within a subject) and all sensors (across subjects, always considering different appended channels in different subjects). it seems that appending interpolated data messes up the correct pairing in combineplanar (so indeed wrong pairs are combined)- only the gradiometers but not the magnetometers are odd within a subject. similarly but for all sensors the grand average is affected (again wrong pairing of channels but over subjects). what happens is that the corresponding match_str function checks only if a channel is present but not for its position in the cell array, thus the result is a vector of 1:n, n being number of channels present. thus, the channels are chosen in the order of the input for averaging and combination, not by their label (as done for plotting) my current solution is to reorder the data and label as in the default layout. the results look way more reasonable to me (figure 'reordered'). this has now been tested on at least 4 different study sets and reordering improves data quality a lot. if the matching is really off, i wonder how many studies are affected. i attached an example containing tf data of one subject (chan_freq_time), my reordering function and an example script that reproduces the results i described in regard to the planar gradient. with that you should be able to reproduce what i am talking about. i did not put anything together for the grand average, but the result is similar (well the channel selection is done in a similar way...) just to be thorough: i reproduced the same results with the most recent fieldtrip version and on MAC/Linux/Windows (good that different people in the lab use different machines). and talked to other people in our MEG lab, we think this might be really a major problem for sensor space data. best philipp


Jörn M. Horschig - 2013-02-19 12:18:40 +0100

Hi Philipp, thanks for reporting this. We had some trouble with that in the past but thought to have resolved such problems. Good that you point us to the possible source of this misbehaviour. Someone of us will look into that quite soon, we'll discuss it in the FT-meeting tomorrow. So, from what I can see there might be two problems: 1) ft_combineplanar does not combine the correct pairs or the relabeling goes wrong after succesful combination. 2) ft_XXXgrandaverage does not take channel order into account. thanks also for the example code, this should make things easy for any of us to check this (I say this because I probably don't have time to look into this myself this week)


Jim Herring - 2013-02-20 16:55:29 +0100

(In reply to comment #1) Thanks Philip for your helpful comments and test script! Indeed ft_combineplanar did not take care of different ordering in the horizontal and vertical channels. I changed the function to take care of this (rev. 7510). I will also check ft_XXXgrandaverage for this.


Philipp Ruhnau - 2013-02-20 17:35:29 +0100

(In reply to comment #2) thanks.


Jim Herring - 2013-02-21 15:41:32 +0100

(In reply to comment #3) Fixed and committed in rev. 7519. ft_xxxgrandaverage indeed did not take different channel ordering across subjects into account. This could happen, for example, when interpolation of bad channels causes a change in the ordering.