Back to the main page.

Bug 1890 - ft_channelrepair does not seem to handle the new sens fields well

Status CLOSED FIXED
Reported 2012-12-13 17:18:00 +0100
Modified 2014-03-12 12:21:40 +0100
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2012-12-13 17:18:18 +0100

e.g. there is the following code around line 301 % move missing channels to the end missidx = find(ismember(sens.label, cfg.missingchannel)); sens.label(end+1:end+numel(missidx)) = sens.label(missidx); sens.label(missidx) = []; sens.chanpos(end+1:end+numel(missidx), :) = sens.chanpos(missidx, :); sens.chanpos(missidx, :) = []; Here channels are moved, but labels are not updated. Why? Also chanori, chanunit and chantype are not moved along. This suggest that the output sens might be completely messed up. -> write a script in which this can be tested. E.g. use neuromag 306 channel data with really different types and units per channel.


Jörn M. Horschig - 2013-01-07 11:16:39 +0100

assigned to me, cause it seems like I did this ;) labels are updated though, and chanoir, -unit and -type are not used by the method, so they are not ignored. what is happening here is that channels which are missing in the data are moved in the sens so that any interpolation ends up having them as the last channels. sens.chanpos is used by the interpolation algorithm that Jason wrote, sens.labels is used for the output argument (which is a data-structure not a sens-structure) There is a test_ft_channelrepair that verifies that the data-output of this moving around is correct. A badchannel will not be moved to the end of the list, a missingchannel will be. The testscript checks whether interpolation of the same channel yields the same results when regarded as a badchannel (i.e. stays in the same position) and as a missingchannel (i.e. when moved to the end). I don't see how someone can interpolate missing channels based on different channel types, can that be (correctly) done in FT?


Robert Oostenveld - 2013-01-07 11:25:29 +0100

(In reply to comment #1) Do I understand it correctly that this sens is not in the output? If it is not and if you only use label and chanpos, I suggest that you don't use the whole sens but rather do something like label = data.grad.label; chanpos = data.grad.chanpos; and start changing those two in the subsequent code. That prevents future code updates from assuming that sens is correct (which it is not after the updates).


Jörn M. Horschig - 2013-01-07 11:28:07 +0100

yes, that is correct and it is a good idea to make clear that this sens-structure is not valid anymore.


Robert Oostenveld - 2013-01-07 11:34:29 +0100

(In reply to comment #1) > I don't see how someone can interpolate missing channels based on different > channel types, can that be (correctly) done in FT? I would not know how to do it perfectly, but this function currently does the interpolation potentially incorrect. Now neuromag306 users might expect that their magnetometer channel is correctly interpolated from the planars, which of course would never work (unless you use the inward-ourward projection in megrealign). If we know that the code does not work in a specific case, we should share that knowledge with a user, e.g. by if ft_senstype(sens, 'eeg') % ok on EEG data elseif ft_senstype(sens, 'meg') && strcmp(ft_senstype(sens), {'...'}) % ok on MEG ctf151, 275 and bti148 and 248 systems else error('not supported on %s', ft_senstype(sens)); end Of course it could be made to work for more cases by adding mode code, e.g. for a nm306 magnetometers I would interpolate using all other nm306 magnetometers (the interpolated value would be in T). For planars I would interpolate the T/cm value from the corresponding planars (either the dV or dH for synthetic, but the same holds for neuromag122 and 306).


Jörn M. Horschig - 2013-01-31 11:23:04 +0100

I now implemented a warning rather than an error, because it depends on the neighbour structure whether it makes sense to interpolate channels on a neuromag system: warning('be careful when using %s - mixing of sensor types (e.g. magnetometers and gradiometers) can lead to wrong data. Check your neighbour-structure thoroughly', ft_senstype(sens)); Do all other MEG systems apart CTF and BTI have mixed sensors? svn ci ft_channelrepair.m -m "enhancement #1890 - temporary sens changed names, warning thrown if sensor types might be mixed (e.g mag&grads)" Sending ft_channelrepair.m Transmitting file data . Committed revision 7427.