Back to the main page.

Bug 1558 - trialinfo lost after artifact rejection

Reported 2012-06-26 10:02:00 +0200
Modified 2012-08-23 10:48:11 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P3 normal
Assigned to: Jan-Mathijs Schoffelen
Depends on:
Blocks: 1564
See also:

Stephen Whitmarsh - 2012-06-26 10:02:12 +0200

Attached data and cfg. After the following call I lost my trialinfo. I first thought that might be the case with only partial rejection but it also happens with complete rejection. Bug can't be more than about a month old as my script used to work but now stopped working because of this. dataclean = ft_rejectartifact(cfg,data);

Stephen Whitmarsh - 2012-06-26 10:05:54 +0200

Created attachment 286 data + cfg

Stephen Whitmarsh - 2012-06-26 10:06:34 +0200

'data_small' instead of 'data' because of size for upload.

Stephen Whitmarsh - 2012-06-26 10:14:13 +0200

ofcourse, i might be wrong and trialinfo was always lost after artifact_rejection. then i would be doubting my own sanity though, which i, ofcourse, by default do.

Stephen Whitmarsh - 2012-06-26 15:21:02 +0200

ah, it was caused by some dependance on a personal workaround - removing my own scripts from the path fixed it. cheers!

Stephen Whitmarsh - 2012-06-26 17:53:20 +0200

No! Its still doesn't work! Could anyone please load the data and type: test = ft_rejectartifact([],data_small) and see if they can replicate the loss of the trialinfo? I'll be here all night! :-)

Stephen Whitmarsh - 2012-06-26 18:06:26 +0200

Ok, ft_redefinetrial removes trialinfo at line 483 of ft_rejectartifact

Jan-Mathijs Schoffelen - 2012-06-27 11:41:48 +0200

So, it is removed in ft_redefinetrial?

- 2012-06-27 18:38:29 +0200

(In reply to comment #7) Actually, I had a similar bug. ft_redefinetrial delete the trialinfo field. Apparently at line 250, it decides to remove the trialinfo field if there is a trialinfo field and that there are more than 1 trial in the data. So it probably remove the trialinfo field after the call of ft_rejectartifact. In my case, I also noticed that even if the initial data did not have trialinfo and the input trl matrix has more than 3 columns, these data were not added to a trialinfo field whan I called ft_redefinetrial. So I added these lines to my code : if ~remove && ~isfield(data, 'trialinfo') && size(trl,2)>3 data.trialinfo = trl(:,4:end); end

Stephen Whitmarsh - 2012-06-27 19:19:10 +0200

Hi there! Yes I traced the problem to a similar statement but instead of needing 1 trail in total, i think it checkes if that is is only 1 original trial on the inverval of interest that fits the new trial, if you see what i mean (its in a loop going through all the trials it needs to adjust). So if there is more than one its not smart enough to copy the trialinfo into both (or more). In my case this was caused because my script creating trials with overlapping samplenumbers. Removing those then worked. I am pretty sure it didn't behave like this a month or two ago though. Thanks for the patch! Much appreciated, Stephen

Jan-Mathijs Schoffelen - 2012-07-08 12:06:42 +0200

indeed when the sampleinfo contains overlapping samples in consecutive trials, the trialinfo is thrown out. In the example data, the first two trials have the same sampleinfo, causing this conflict. (I did not check for the rest of the trials though). Although I don't know whether past versions of ft_redefinetrial were more lenient, I think the current behavior is correct.