[FieldTrip] Possible Bug using ft_rejectvisual followed by ft_rejectartifact

Eli Kinney-lang E.Kinney-Lang at sms.ed.ac.uk
Thu Jun 16 17:19:19 CEST 2016

Hello all,

  This is my first post, so I apologize if I am not detailed  
enough/don't give enough correct information for my question. My name  
is Eli, and I am a researcher at the University of Edinburgh studying  
non-invasive brain-computer interfaces.
Background and summary:
In a side project, I am looking at using EEG to determine if there are  
cognitive difficulties in infants with epilepsy. In this project I am  
processing the EEG data from 20 channels recorded by a local hospital  
group. I have set up a fieldtrip processing pipeline in order to  
investigate this problem. Within the processing pipeline I have a  
two-step artifact removal chain.
First, I visually remove obvious artifacts using the ft_rejectvisual  
and the cfg.method ='summary'. I then use automatic rejection based on  
z-value to remove any additional trials which contain muscle, jump or  
EOG artifacts. However, when I run the automatic rejection, if I have  
removed a single trial using the visual method, I the automatic  
rejection method calculates a z-value of '0' for all trials, failing  
to reject anything. If I do NOT reject anything from ft_rejectvisual  
(but still call the function) then the automatic rejection works  
properly. This is inconsistent, and does not happen for each subject,  
but does occur for some subjects. Other subjects have both functioning  
properly. Any suggestions as to what may be causing this would be  
Expanded details:
-Given a preprocessed EEG data I run ft_rejectvisual using cfg.method  
= 'summary' as the only cfg.
-cfg for automatic rejection:
     cfg.trl = dat.cfg.trl;
     cfg.continuous = 'yes';
     cfg.artfctdef.zvalue.channel = 'all';
     cfg.artfctdef.zvalue.cutoff      = 2;
     cfg.artfctdef.zvalue.trlpadding  = 0;
     cfg.artfctdef.zvalue.artpadding  = 0.1;
     cfg.artfctdef.zvalue.fltpadding  = 0.2;
     cfg.artfctdef.zvalue.bpfilter    = 'yes';
     cfg.artfctdef.zvalue.bpfreq = [110 140];
     cfg.artfctdef.zvalue.bpfiltord   = 8;
     cfg.artfctdef.zvalue.bpfilttype  = 'but';
     cfg.artfctdef.zvalue.hilbert     = 'yes';
     cfg.artfctdef.zvalue.boxcar      = 0.2;
     [~, artifact_muscle] = ft_artifact_zvalue(cfg,dat);
     cfg = [];
-data structure:
dat =

            hdr: [1x1 struct]
          label: {20x1 cell}
        fsample: 511
          trial: {1x94 cell}
           time: {1x94 cell}
     sampleinfo: [94x2 double]
            cfg: [1x1 struct]

I cannot upload the data due to confidentiality, but am glad to  
clarify any questions/provide more information where needed. Is this  
user error, or is it possibly a bug? Any recommendations are welcome.  
Thank you.


Eli Kinney-Lang

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

More information about the fieldtrip mailing list