Back to the main page.

Bug 2575 - Setting channel types based on labels

Reported 2014-05-12 20:37:00 +0200
Modified 2014-07-15 17:25:12 +0200
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Robert Oostenveld
Depends on:
See also:

Vladimir Litvak - 2014-05-12 20:37:52 +0200

I noticed that ft_chantype only works for 1020 EEG labels (not sure if it's always been the case, I don't think so because in SPM automatic channel type setting also worked for Biosemi). Looking around line 544 in ft_chantype I see that it checks 1020 labels 3 times which I think is redundant, it's enough to only compare with 1005. But instead I suggest to have: type(match_str(label, ft_senslabel(ft_senstype(input)))) = {'eeg'}; This will work for any EEG label set. I tried it and it seems to work well. Do you see any problems with it? Vladimir

Robert Oostenveld - 2014-05-13 09:40:48 +0200

I suspect that it works for Biosemi because of lines 86 and further: if isfield(input, 'chantype') % start with the provided channel types type = input.chantype(:); else % start with unknown type for all channels type = repmat({'unknown'}, numchan, 1); end This only has effect if the input is a header or grad structure, not if it only channel labels. The 1005 system indeed includes all 1010 and 1020 labels, also the M, A and T channels, so the 3 calls could be changed by a single one. I am not sure whether your suggestion will always work. ft_senstype is not so robust, due to unusual combinations of channel labels, e.g. a mix of system specific labels (like EGI or Biosemi) with a subset of 1020 labels. How about changing line 544 it into elseif ft_senstype(input, 'eeg') && islabel % use an external helper function to define the list with EEG channel names type(match_str(label, ft_senslabel('eeg1005'))) = {'eeg'}; % this includes all channels from the 1010 and 1020 arrangement type(match_str(label, ft_senslabel(ft_senstype(input)))) = {'eeg'}; % this will work for biosemi, egi and other detected channel arrangements

Vladimir Litvak - 2014-05-13 13:17:21 +0200

(In reply to Robert Oostenveld from comment #1) I'm not sure it'll work so well because it'll detect any channel whose name matches one of the 1005 labels in any system. I suspect you can have names like C3 or P3 also in something which is not 1020. In most cases it'll be benign but who knows...

Robert Oostenveld - 2014-05-13 13:44:10 +0200

(In reply to Vladimir Litvak from comment #2) Agreed. But it would only be for systems with ft_senstype=eeg, and for those I would assume that almost all channels have chantype=eeg anyway. Furthermore, this has been the behaviour for some time now and would not change. The only change is that non-1020 channels can also be marked as chantype=eeg.

Robert Oostenveld - 2014-05-15 08:38:41 +0200

mac011> svn commit fileio/ft_chantype.m Sending fileio/ft_chantype.m Transmitting file data . Committed revision 9534. See for details I hope you agree with the solution.

Robert Oostenveld - 2014-05-15 08:38:55 +0200

see previous comment

Robert Oostenveld - 2014-07-15 17:25:12 +0200

Closed several bugs that were recently resolved. If it is closed in error, please reopen.