Back to the main page.
Bug 2334 - ft_trialfun_general selects wrong events after r8613
Status | CLOSED FIXED |
Reported | 2013-10-23 17:28:00 +0200 |
Modified | 2019-08-10 12:03:02 +0200 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P3 normal |
Assigned to: | Sarang Dalal |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Jim Herring - 2013-10-23 17:28:01 +0200
In r8613 the following lines were changed by sardal in ft_trialfun_general: " if ~isempty(cfg.trialdef.eventvalue) % this cannot be done robustly in a single line of code if ~iscell(cfg.trialdef.eventvalue) valchar = ischar(cfg.trialdef.eventvalue); valnumeric = isnumeric(cfg.trialdef.eventvalue); else valchar = ischar(cfg.trialdef.eventvalue{1}); valnumeric = isnumeric(cfg.trialdef.eventvalue{1}); end for i=1:numel(event) if (ischar(event(i).value) && valchar) || (isnumeric(event(i).value) && valnumeric) sel(i) = sel(i) & ~isempty(intersect(event(i).value, cfg.trialdef.eventvalue)); end end end " to " if ~isempty(cfg.trialdef.eventvalue) % this cannot be done robustly in a single line of code if ~iscell(cfg.trialdef.eventvalue) valchar = ischar(cfg.trialdef.eventvalue); valnumeric = isnumeric(cfg.trialdef.eventvalue); eventvalue = cfg.trialdef.eventvalue; else valchar = ischar(cfg.trialdef.eventvalue{1}); valnumeric = isnumeric(cfg.trialdef.eventvalue{1}); eventvalue = cfg.trialdef.eventvalue{1}; end for i=1:numel(event) if (ischar(event(i).value) && valchar) || (isnumeric(event(i).value) && valnumeric) sel(i) = sel(i) & ~isempty(intersect(event(i).value, eventvalue)); end end end" with the comment: "fix for labels on trials from CTF data (cell vs string discrepancy)". Two problems have hereby been introduced: 1. In case cfg.trialdef.eventvalue is a cell variable with multiple events(e.g. {'S 1' 'S 2' 'S 3'}), only the first event is used to compare with each trial due to "eventvalue = cfg.trialdef.eventvalue{1};". 2. "eventvalue = cfg.trialdef.eventvalue{1};" causes event value to become a char-variable if it was a cell of strings. This causes intersect in "sel(i) = sel(i) & ~isempty(intersect(event(i).value, eventvalue));" to compare the characters within the string separately rather than comparing the string as a whole. I'm not sure what the problem with ft_trialfun_general was in the first place (I could not find a bug on it) but this fix introduces problems for Brainvision users.
Sarang Dalal - 2013-10-23 18:44:02 +0200
Sorry to have introduced this problem. We have just committed another revision that should hopefully maintain compatibility with your data as well as fix the problem we had with CTF data. Please let me know if it continues to be a problem.
Jim Herring - 2013-11-01 16:26:03 +0100
The fix works. Thanks! I've assigned the bug to you and will change the status to resolved.