Back to the main page.

Bug 728 - change to ft_channelselection in SVN commit 3548 breaks some wildcard functionality

Status CLOSED FIXED
Reported 2011-06-02 22:21:00 +0200
Modified 2011-06-21 15:52:21 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P1 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Eliezer Kanal - 2011-06-02 22:21:37 +0200

The code change in 3548 breaks wildcard selectors where the wildcard is in the middle, e.g. "M*1". The negation operator is being interpreted incorrectly here. See line 161, the code should be: Index: ft_channelselection.m =================================================================== --- ft_channelselection.m (revision 3613) +++ ft_channelselection.m (working copy) @@ -158,7 +158,7 @@ labelreg = labelreg | ~cellfun(@isempty, regexp(datachannel, ['^' channel{i}(1:end-1) '.*'], 'once')); findreg = [findreg i]; end - if length(channel{i})>1 && ~channel{i}(1)=='*' && ~channel{i}(end)=='*' && any(channel{i}=='*') + if length(channel{i})>1 && ~(channel{i}(1)=='*') && ~(channel{i}(end)=='*') && any(channel{i}=='*') % the wildcard is in the middle sel = strfind(channel{i}, '*'); str1 = channel{i}(1:(sel-1)); with parenthesis around the "channel{i}(1)==1" statement. Ideally, the equality comparisons should all be replaced with `strcmp` calls, which are more robust for this sort of comparison.


Jan-Mathijs Schoffelen - 2011-06-03 09:44:24 +0200

Hi Jörn, Could you look into this and fix it as suggested? Thanks, JM


Jörn M. Horschig - 2011-06-07 13:42:44 +0200

done + using strmcp and strfind instead of ==