[FieldTrip] error with automatic artefact rejection using ft_artifact_threshold

Arnold Kochari a.kochari at uva.nl
Thu Jun 29 18:27:00 CEST 2017


I am still struggling with automatic detection of linear drif. I solved the
1st issue with ft_artifact_threshold by writing my own simple function to
do what I needed to achieve.

As I mentioned, my starting point is data segmented into trials. I look
into every trial and add it to an array if there are no values higher or
lower than +/-75. I then select only those trials that were added to this
array.

    cfg=[];

    cfg.trials=[];

    for tr = 1:length(baselined.trial)

        if length(find(baselined.trial{1, tr} > 75 | baselined.trial{1, tr}
< -75)) == 0

            cfg.trials=[cfg.trials, tr];

        end

    end

    filtered = ft_selectdata(cfg, baselined);


I hope this is useful to someone.


Arnold



On Thu, Jun 22, 2017 at 3:45 PM, Arnold Kochari <a.kochari at uva.nl> wrote:

> Dear FieldTrip community,
>
>
>
> I am new to FieldTrip and got stuck while trying to exactly replicate an
> analysis reported in a paper. I would be very grateful for any tips.
> Specifically, I cannot manage to automatically reject trials with certain
> min/max uV (question 1) and cannot find any way to automatically detect
> linear drift (question 2).
>
> *1.* After segmenting and baseline correcting using *demean*, I am trying
> to use the following code for rejection of trials with extreme values using
> *ft_artifact_threshold*, but I seem to have made a mistake somewhere:
>
>     cfg = [];
>
>     cfg.trl = 'baselined.sampleinfo';
>
>     cfg.continuous = 'no';
>
>     cfg.artfctdef.threshold.min = -75;
>
>     cfg.artfctdef.threshold.max = 75;
>
>
>
>     [cfg, artifact] = ft_artifact_threshold(cfg, baselined);
>
>
> I am getting to following error:
>
> Error using butter (line 79)
> butter: first band edge must be smaller than second
>
> Error in ft_preproc_bandpassfilter (line 153)
> [B, A] = butter(N, [min(Fbp)/Fn max(Fbp)/Fn]);
>
> Error in preproc (line 327)
> if strcmp(cfg.bpfilter, 'yes'), dat = ft_preproc_bandpassfilter(dat,
> fsample, cfg.bpfreq, cfg.bpfiltord, cfg.bpfilttype,
> cfg.bpfiltdir, cfg.bpinstabilityfix, cfg.bpfiltdf, cfg.bpfiltwintype,
> cfg.bpfiltdev, cfg.plotfiltresp, cfg.usefftfilt); end
>
> Error in ft_artifact_threshold (line 164)
> dat = preproc(dat, channel, offset2time(cfg.trl(trlop,3), hdr.Fs,
> size(dat,2)), artfctdef);
>
> *2. *I am also trying to detect a linear drift of more than +/- 50 uV
> beginning before the onset of the stimulus (so before 0). With this one, I
> am not sure where to begin. I would be grateful for tips about what
> functions I can use to do this.
>
>
> Kind regards,
> Arnold Kochari
> PhD candidate, Institute for Logic, Language and Computation, University
> of Amsterdam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170629/8b410a5c/attachment-0002.html>


More information about the fieldtrip mailing list