automatic EOG rejection

Ingrid Nieuwenhuis ingrid.nieuwenhuis at DONDERS.RU.NL
Mon Aug 10 16:24:30 CEST 2009


Hi Lars,

What you can do is:
1- read in whole data as one trial with define trial -> you get a trl
(Ntrx3) with one row
2- detect artifacts with artifact_eog -> you get an artifact (Nartx2)
stating first and last sample of each artifact (you managed this if I'm
correctly, but fiddled a bit with samples for padding, so make sure the
artifact samples match the data!!
3- Then you can use redefinetrial to go from a trl with 1 row to a trl with
all epochs based on the triggers (Ntrx3)
4- Finally you use rejectartifact which modifies your trl to not include the
artifacts anymore. (see help for options, you can cut out only the artifacts
leaving you with most data, but trials with "holes" or reject all trials
completely when contaminated). 

Robert and I have worked recently on a databrowser which is also included in
the more recent versions of FieldTrip. Although it still might be a little
buggy/unstable (work in progress :) ) it might be quite useful for you to
check stage 2, (if the artifacts match the data correctly) since it allows
you to browse through the data and see which segments are marked as
artifact. So if you read in the unfiddled data (with trl from stage 1) with
the artifact field (you got after stage 2) in the browser you can see if
your padding did not shift the artifacts with regard to the sample numbers.
(Hope I'm clear enough in what I mean here).

Best Ingrid



> -----Original Message-----
> From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On
> Behalf Of Lars Meyer
> Sent: Monday, August 10, 2009 3:58 PM
> To: FIELDTRIP at NIC.SURFNET.NL
> Subject: Re: [FIELDTRIP] automatic EOG rejection
> 
> dear ingrid,
> 
> i tried this now, works fine for the rejection (success!). but now, i'd
> have to find a way to:
> 
> - get the events from the raw data (definetrial, okay)
> - keep only those in which there is no artifact (i have the list as output
> from the rejection, so far, so good)
> 
> but, in the way you suggest, would fieldtrip not get the rejected trials
> again from the raw data, according to the triggers? right now i don't see
> how redefinetrial can both:
> 
> - get real triggers from raw data and define trials (write a trl according
> to triggers)
> - only search those segments of the raw data that result from the
> rejection process (write a trl according to clean segments)
> 
> i.e. what needs to be done is to check entries in the 'trigger-trial trl'
> for identity or overlap with entries in the 'rejection-trial trl'.
> 
> 
> can redefinetrial solve my problem? how? thank you so much, again!
> lars
> 
> 
> Lars Meyer | MSc
> Max Planck Institute for Human Cognitive & Brain Sciences
> Department of Neuropsychology
> Stephanstraße 1a
> 04103 Leipzig | Germany
> 
> Office | +49 (0)341 99 40 22 66
> Fax | +49 (0)341 99 40 22 60
> Mobile | +49 (0)175 113 76 65
> Home | +49 (0)341 974 26 49
> Mail | lmeyer at cbs.mpg.de
> Web | www.cbs.mpg.de/~lmeyer
> 
> ----- Ursprüngliche Mail -----
> Von: "Ingrid Nieuwenhuis" <ingrid.nieuwenhuis at donders.ru.nl>
> An: FIELDTRIP at NIC.SURFNET.NL
> Gesendet: Freitag, 7. August 2009 16:20:18 GMT +01:00
> Amsterdam/Berlin/Bern/Rom/Stockholm/Wien
> Betreff: Re: [FIELDTRIP] automatic EOG rejection
> 
> Dear Lars,
> 
> Don't understand what is wrong with your data_org trial. The trl
> definition
> has 3 columns per trial: first sample of trial, last sample of trial and
> offset, did your data_org.cfg.trl have that?
> 
> Anyways you can "epoch" your data to one long single trial
> 
> trl = [1 last_sample 0]
> or use trialfun_general in definetrial with cfg.ntrials = 1; and
> cfg.triallength = inf;
> 
> Then do artifact detection/rejection and then redefine trial to real
> epochs
> based on triggers. Would that work?
> 
> Have a nice weekend too,
> Best Ingrid
> 
> > -----Original Message-----
> > From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On
> > Behalf Of Lars Meyer
> > Sent: Friday, August 07, 2009 4:00 PM
> > To: FIELDTRIP at NIC.SURFNET.NL
> > Subject: Re: [FIELDTRIP] automatic EOG rejection
> >
> > dear ingrid,
> >
> > thanks a lot, I greatly appreciate your immediate response!
> > what you suggest was what I was trying next :-). I already had suspected
> > the padding to be my problem.
> > however, 'artifact_eog' always tries to fetch 'trl' >> error:
> >
> > ??? Reference to non-existent field 'trl'.
> > Error in ==> artifact_eog at 165
> >   tmpcfg.trl              = cfg.trl;
> >
> >
> > as soon as i declare
> >
> > cfg.trl = data_org.cfg.trl
> >
> >
> > i.e. get 'trl' from the original, continuous data structure in memory
> > (data_org), matlab errors
> >
> > Input must be a row vector of characters
> >
> >
> > thanks a lot in advance, and have a good weekend,
> > lars
> >
> >
> > Lars Meyer | MSc
> > Max Planck Institute for Human Cognitive & Brain Sciences
> > Department of Neuropsychology
> > Stephanstraße 1a
> > 04103 Leipzig | Germany
> >
> > Office | +49 (0)341 99 40 22 66
> > Fax | +49 (0)341 99 40 22 60
> > Mobile | +49 (0)175 113 76 65
> > Home | +49 (0)341 974 26 49
> > Mail | lmeyer at cbs.mpg.de
> > Web | www.cbs.mpg.de/~lmeyer
> >
> > ----- Ursprüngliche Mail -----
> > Von: "Ingrid Nieuwenhuis" <ingrid.nieuwenhuis at donders.ru.nl>
> > An: FIELDTRIP at NIC.SURFNET.NL
> > Gesendet: Freitag, 7. August 2009 15:08:06 GMT +01:00
> > Amsterdam/Berlin/Bern/Rom/Stockholm/Wien
> > Betreff: Re: [FIELDTRIP] automatic EOG rejection
> >
> > Dear Lars,
> >
> > The error message means that fetch_data tries to fetch data outside of
> > your
> > trials where there is no data supplied in the input data file.
> Fetch_data
> > was recently changed and now puts NaNs where there is no data. But
> > filtering
> > data with NaNs is not a good idea, therefore the warning.
> >
> > What happens is in artifact_eog is that the data is padded, or better
> > said,
> > there is an attempt to pad the data. This is done to avoid filter
> artifact
> > at the edges, and for optimal artifact detections at/just over the
> border
> > (which can influence filtering). This padding doesn't work because in
> the
> > input data you supplied there is no extra data which can be used for
> > padding. Therefore the NaN's or the error that not all samples are
> present
> > in the data.
> >
> > Would you can do is epoch the data into trials after artifact detection.
> > So
> > first detect and reject artifacts, and then use redefinetrial (give the
> > trl
> > you have now) to epoch the data.
> >
> > Hope this helps,
> > Best Ingrid
> >
> > > -----Original Message-----
> > > From: FieldTrip discussion list [mailto:FIELDTRIP at NIC.SURFNET.NL] On
> > > Behalf Of Lars Meyer
> > > Sent: Friday, August 07, 2009 2:23 PM
> > > To: FIELDTRIP at NIC.SURFNET.NL
> > > Subject: [FIELDTRIP] automatic EOG rejection
> > >
> > > dear all,
> > >
> > > (newest fieldtrip, newest matlab)
> > >
> > > trying automatic EOG artifact rejection, i get the following error:
> > >
> > > In fetch_data at 111
> > > In artifact_zvalue at 213
> > > In artifact_eog at 179
> > > Warning: data contains NaNs, no filtering applied
> > >
> > >
> > > workflow was (these all worked):
> > >
> > > - reading continous data to memory
> > > - merging EOG channels (from V+/V_ / H+/H_ to eogv and eogh)
> > > - appending EOG channels
> > > - re-refercing
> > > - filtering
> > > - epoching according to triggers
> > >
> > >
> > > while trying automatic rejection comes the error; visual rejection
> just
> > > works fine. in the olf fieldtrip version, the error message said "not
> > all
> > > samples are present in the data". i checked the data structure; the
> > merged
> > > EOG channels have been correctly appended and labelled. attached is my
> > > code, thanks a lot in advance!
> > >
> > >
> > > all best,
> > > lars
> > >
> > >
> > > Lars Meyer | MSc
> > > Max Planck Institute for Human Cognitive & Brain Sciences
> > > Department of Neuropsychology
> > > Stephanstraße 1a
> > > 04103 Leipzig | Germany
> > >
> > > Office | +49 (0)341 99 40 22 66
> > > Fax | +49 (0)341 99 40 22 60
> > > Mobile | +49 (0)175 113 76 65
> > > Home | +49 (0)341 974 26 49
> > > Mail | lmeyer at cbs.mpg.de
> > > Web | www.cbs.mpg.de/~lmeyer
> > >
> > > ----------------------------------
> > > The aim of this list is to facilitate the discussion between users of
> > the
> > > FieldTrip  toolbox, to share experiences and to discuss new ideas for
> > MEG
> > > and EEG analysis. See also
> > > http://listserv.surfnet.nl/archives/fieldtrip.html and
> > > http://www.ru.nl/neuroimaging/fieldtrip.
> >
> > ----------------------------------
> > The aim of this list is to facilitate the discussion between users of
> the
> > FieldTrip  toolbox, to share experiences and to discuss new ideas for
> MEG
> > and EEG analysis. See also
> > http://listserv.surfnet.nl/archives/fieldtrip.html and
> > http://www.ru.nl/neuroimaging/fieldtrip.
> >
> > ----------------------------------
> > The aim of this list is to facilitate the discussion between users of
> the
> > FieldTrip  toolbox, to share experiences and to discuss new ideas for
> MEG
> > and EEG analysis. See also
> > http://listserv.surfnet.nl/archives/fieldtrip.html and
> > http://www.ru.nl/neuroimaging/fieldtrip.
> 
> ----------------------------------
> The aim of this list is to facilitate the discussion between users of the
> FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG
> and EEG analysis. See also
> http://listserv.surfnet.nl/archives/fieldtrip.html and
> http://www.ru.nl/neuroimaging/fieldtrip.
> 
> ----------------------------------
> The aim of this list is to facilitate the discussion between users of the
> FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG
> and EEG analysis. See also
> http://listserv.surfnet.nl/archives/fieldtrip.html and
> http://www.ru.nl/neuroimaging/fieldtrip.

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.



More information about the fieldtrip mailing list