[Eeglablist] automatic artifact rejection

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Thu May 7 20:26:31 PDT 2015


Dear Stephen,

You are absolutely right. This is what Dana asked.

> e.g.; I would like to remove epochs where the *difference between the
maximum and minimum* in an interval of a selectable length, and the
difference between the maximum and minimum in the epoch itself, exceeds a
specific value.

> which would be similar to what eeg_rejthresh does (I think)

I don't know either :-)

I often use this simple amplitude thresholding for epoch rejection, and it
works well. I wonder why. Maybe it's because noise in EEG recording is
often associated with high amplitude. In the sense we are lucky, aren't we?
There could be a parallel universe where EEG noise has nothing to do with
amplitude...

Makoto

On Thu, May 7, 2015 at 7:44 PM, Stephen Politzer-Ahles <spa268 at nyu.edu>
wrote:

> Hm, good point. Since the OP asked for the difference between the epoch
> maximum and minimum, this seemed like the best way to do it (although there
> might be a cleaner way to code it. Looking at max(abs(EEG.data,[],2)) seems
> like it would instead find the greatest voltage in either direction, which
> would be similar to what eeg_rejthresh does (I think)
>
> Best,
> Seve
>
>
>
> Stephen Politzer-Ahles
> New York University, Abu Dhabi
> Neuroscience of Language Lab
> http://www.nyu.edu/projects/politzer-ahles/
>
> On Thu, May 7, 2015 at 11:01 PM, Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
> wrote:
>
>> Dear Stephen,
>>
>> Very smart, as usual!
>>
>> By the way, could you please tell me why you subtract min from max?
>> > diffs = squeeze( max(EEG.data,[],2) - min(EEG.data,[],2) );
>>
>> What if you have max 10150 and min 10000?  (after high-pass filtering it
>> is not likely to happen though)
>>
>> I thought this would be more straightforward
>> > diffs = squeeze(max(abs(EEG.data,[],2)));
>>
>> Am I missing something here? I appreciate your comment. Thank you!
>>
>> Makoto
>>
>> On Mon, May 4, 2015 at 9:07 PM, Stephen Politzer-Ahles <spa268 at nyu.edu>
>> wrote:
>>
>>> Hi Dana,
>>>
>>> I also would have thought these would be implemented, but I couldn't
>>> find t hem just now; maybe they're in ERPLAB.
>>>
>>> It shouldn't be hard, though, to code this yourself. Below is a quick
>>> sample I just made; I can't guarantee this will work in all cases but it
>>> gives you an idea. You could easily run some simple code like this and then
>>> just add the bad trial list into the EEG.reject structure.
>>>
>>> Best,
>>> Steve
>>>
>>>
>>> %%% MAXMIN CRITERION
>>>
>>> % Finds the difference between the maximum and minimum of each epoch.
>>> Could
>>> % be tweaked to look only at a certain time range within the epoch
>>> diffs = squeeze( max(EEG.data,[],2) - min(EEG.data,[],2) );
>>>
>>> % We'll kick out any trials whose difference exceeds this uV threshhold
>>> threshold = 200;
>>>
>>> % Find samples that exceed the threshhold
>>> [chanidx, epochidx] = find( diffs > threshold );
>>>
>>> % Find epochs that have at least one sample, at any channel, exceeding
>>> the
>>> % threshhold
>>> badepochs.maxmin = unique( epochidx );
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> %%% NEIGHBORING SAMPLES CRITERION
>>>
>>> % Find the difference between neighboring samples each pair of
>>> neighboring samples
>>> diffs = arrayfun( @(x)( squeeze (EEG.data(:,x,:) - EEG.data(:,x-1,:) )
>>> ), 2:size(EEG.data,2), 'UniformOutput', false );
>>>
>>> % organize that cell array into a matrix, which will be easier to work
>>> with
>>> n_chan = size(diffs{1},1);
>>> n_samp = length(diffs);
>>> n_trial = size(diffs{1},2);
>>> diffs = reshape(cell2mat(diffs), n_chan, n_samp, n_trial);
>>>
>>> % get the max difference across samples, for each trial
>>> diffs = squeeze( max(diffs,[],2) );
>>>
>>> % We'll kick out any trials whose difference exceeds this uV threshhold
>>> threshold = 75;
>>>
>>> % Find samples that exceed the threshhold
>>> [chanidx, epochidx] = find( diffs > threshold );
>>>
>>> % Find epochs that have at least one sample, at any channel, exceeding
>>> the
>>> % threshhold
>>> badepochs.neighbsamp = unique( epochidx );
>>>
>>>
>>>
>>> Stephen Politzer-Ahles
>>> New York University, Abu Dhabi
>>> Neuroscience of Language Lab
>>> http://www.nyu.edu/projects/politzer-ahles/
>>>
>>> On Thu, Apr 30, 2015 at 12:37 PM, Son, D.M.E. van <
>>> d.m.e.van.son at fsw.leidenuniv.nl> wrote:
>>>
>>>>  Dear Eeglab members,
>>>>
>>>> Before manually selecting artifacts in my data, I would like to
>>>> pre-select artifacts automatically. I have seen that Eeglab provides an
>>>> automatic epoch rejection toolbox, but specific epoch selection that I
>>>> would like to make, does not seem to be provided.
>>>> e.g.; I would like to remove epochs where the difference between the
>>>> maximum and minimum in an interval of a selectable length, and the
>>>> difference between the maximum and minimum in the epoch itself, exceeds a
>>>> specific value. Also, I’d like to remove epochs wherin the absolute
>>>> difference between two neighboring sampling points exceeds a certain
>>>> value.
>>>>
>>>> Does anyone have an idea if this is possible in Eeglab automatically?
>>>> Or perhaps it is possible that I script this separately?
>>>>
>>>> Many thanks in advance
>>>>
>>>> Dana
>>>>
>>>>
>>>> _______________________________________________
>>>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>>> To unsubscribe, send an empty email to
>>>> eeglablist-unsubscribe at sccn.ucsd.edu
>>>> For digest mode, send an email with the subject "set digest mime" to
>>>> eeglablist-request at sccn.ucsd.edu
>>>>
>>>
>>>
>>> _______________________________________________
>>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>> To unsubscribe, send an empty email to
>>> eeglablist-unsubscribe at sccn.ucsd.edu
>>> For digest mode, send an email with the subject "set digest mime" to
>>> eeglablist-request at sccn.ucsd.edu
>>>
>>
>>
>>
>> --
>> Makoto Miyakoshi
>> Swartz Center for Computational Neuroscience
>> Institute for Neural Computation, University of California San Diego
>>
>
>


-- 
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150507/6cad5904/attachment-0001.html>


More information about the eeglablist mailing list