update: artifact detection

Robert Oostenveld r.oostenveld at FCDONDERS.RU.NL
Thu Feb 2 18:12:41 CET 2006


Hi Marcel

On 2-feb-2006, at 17:01, Marcel Bastiaansen wrote:
> Thanks for updating the functions. They generally look much better
> now.
> I have a slight problem however. For certain types of analysis (e.g.
> multitaper) I need some data before and after the actual trials in my
> experiment (to allow tapers to shift into the data at the beginning of
> the trial, and out of the data at the end of the trial). Usually I cut
> my data so that these extra datapoints are part of the 'trial', but I
> don't check these extra datastretches for EOG artefacts (as they
> fall in
> the ITI they typically contain a lot of blinks).

That means that the eventual eye artifacts might be smeared (due to
the wavelet length, or the equivalent multitaper mechanism) into
later timepoints. I guess that yu are aware of that, and I assume
that that is not a problem.

> I used to do that  by
> specifying a negative padding value in the artefact_eog function, but
> that is no longer possible. Hence, my question is, whether it would be
> possible to include the option of checking only a user-specified
> part of
> each trial for artefacts.

The usual sequence of functions needed to get raw data from disk into
matlab memory is
  definetrial -> rejectartifact -> preprocessing

However, rejectartifact can (for you as end user) also be split up
into seperate parts. The first part is detecting artifacts, the
second part is deciding what to do with them. Artifact detection is
implemented in the artifact_xxx functions (with xxx=eog//muscle/jump
etc). The sequence then becomes
  definetrial -> artifact_eog -> rejectartifact -> preprocessing

Artifact detection is only done on selected parts of the data. The
part of the data where it searches for artifacts usually is the part
that you later want to read in (using the preprocessing function), or
sometimes with some extra time before and after each trial.  Whether
it is desirable to have this padding depends on your experimental
question and type of data.

The additional amount of time before and after each trial to look for
artifacts is specified using the "trlpadding" option. However, you
can also do it manually:

cfg = []
cfg = ...
cfg = definetrial(cfg);
trlorg = cfg.trl;   % <<<< make a copy of the original
cfg.trl(:,1) = cfg.trl(:,1) - number_of_samples_pre
cfg.trl(:,2) = cfg.trl(:,2) + number_of_samples_post
cfg = artifact_eog(cfg);
cfg.trl = trlorg;    % <<<< put the original back
cfg = rejectartifact(cfg);
data = preprocessing(cfg);

This also allows you to specify a negative amount of padding before
and after each trial, i.e. if you do *not* want to look for artifacts
in the first xxx ms. I suggest that for the moment you use this
manual option. I might implement the pre and post padding seperately
and add support for the negative padding, but don't hold your breath
for it.

> Another thing is that it is not (yet?) possible to call the old
> artefact
> routines in the way you specified it in your message below (though
> it is
> possible to directly call the artefact_eog_old function).

Thanks, I will look into that. I don't immediately see a reason why
it should not work, so that might indicate a bug.

best
Robert



More information about the fieldtrip mailing list