Back to the main page.

Bug 3404 - ft_apply_montage makes up (missing) channels

Status ASSIGNED
Reported 2018-01-28 06:34:00 +0100
Modified 2018-02-11 22:56:06 +0100
Product: FieldTrip
Component: preproc
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 critical
Assigned to: Arjen Stolk
URL:
Tags:
Depends on:
Blocks:
See also:

Arjen Stolk - 2018-01-28 06:34:43 +0100

It seems that using ft_apply_montage in combination with ft_preprocessing can lead to the creation of spurious and incorrect data channels. The problem can be simulated as below. The expected behavior is that since there is no channel 3 in the data, the output after applying the montage (bipolar re-referencing) should not contain channel combinations with channel 3. Thus, only channel '1-2' should be in the output. In reality, we see all channels in the output including combinations involving channel 3. Moreover, channel '1-2' does not seem to reflect the combination of channel 1 and 2 given that this should produce a vector of 1.5s (average of 1 and 2). The entire issue can obviously be avoided by not incorrectly specifying cfg.montage.labelold in the first place. But shouldn't ft_preprocessing check for matching labels between data.label and those in cfg.montage, and ideally prune the montage structure accordingly? Current behavior is, as epitomized by the simulation below, that entirely incorrect output is given without any indication of a problem. This error could easily sneak into an analysis and go unnoticed if people are not actively aware of a missing channel while using cfg.montage. % create data data.label = {'1';'2';'4'}; % note chan 3 is missing data.time{1,1} = 1:10; data.trial{1,1} = [ones(1,10);ones(1,10)*2;ones(1,10)*3]; data.trial{1,1}: 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 % create and apply montage cfg = []; cfg.montage.labelold = {'1';'2';'3';'4'}; % note the non-existing chan 3 cfg.montage.labelnew = {'1-2';'2-3';'3-4'}; cfg.montage.tra = zeros(3,4); cfg.montage.tra(1,1:2) = [-1 1]; cfg.montage.tra(2,2:3) = [-1 1]; cfg.montage.tra(3,3:4) = [-1 1]; data2 = ft_preprocessing(cfg, data) data2: fsample: 1 sampleinfo: [1 10] trial: {[3×10 double]} time: {[1 2 3 4 5 6 7 8 9 10]} label: {3×1 cell} cfg: [1×1 struct] data2.label: {'1-2'} {'2-3'} {'3-4'} data2.trial{1}: 1 1 1 1 1 1 1 1 1 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 3 3 3 3 3 3 3 3 3 3


Arjen Stolk - 2018-01-28 06:39:37 +0100

Addendum, output channel '1-2' is actually correct. I was confused by how ft_apply_montage spatially _averages_ channels, rather than how ft_apply_montage _subtracts_ channels. For clarity, the main and remaining problem is the creation of non-existing channels.