[Eeglablist] Processing Startle in EEGlab

Tara Miskovich miskovi2 at uwm.edu
Wed Sep 16 17:19:11 PDT 2015


This looks like it worked! Thank you so much Steve!

Tara

On Tue, Sep 15, 2015 at 1:27 AM, Stephen Politzer-Ahles <
stephen.politzer-ahles at ling-phil.ox.ac.uk> wrote:

> Hi Tara,
>
> It looks like the problem is that your EEG.event.type values are strings
> rather than numbers, and EEG.event.type itself is a series of structure
> field values (technically separate variables) rather than an array. Both of
> these prevent you from concatenating them with STLResponse, which is a
> simple numeric array. For example, notice how these types are different:
>
> >> EEG.event(1:3).type
>
> ans =
>
> 98
>
>
> ans =
>
> 98
>
>
> ans =
>
> 98
>
>
> >> STLResponse(1:3)
>
> ans =
>
>     98
>     98
>     98
>
>
> Fortunately, this is easy to fix by just extracting the values of
> EEG.event.type and putting them into an array with the same shape as
> STLResponse. Replacing your last block of code with the following should do
> the trick:
>
> %% Score startle peaks
>         STLResponse = squeeze(max(EEGNA.data(1,find(EEGNA.times>=20 &
> EEGNA.times<=100),:))); %Identify peak response of startle trials in
> scoring window
>         STLResponse = [arrayfun( @(x)(str2num(EEG.event(x).type)),
> 1:length(EEG.event) )' STLResponse]; %Store peak values by event type
>
> or, in an easier-to-read version:
>
> %% Score startle peaks
>         STLResponse = squeeze(max(EEGNA.data(1,find(EEGNA.times>=20 &
> EEGNA.times<=100),:))); %Identify peak response of startle trials in
> scoring window
>         triggers = arrayfun( @(x)(str2num(EEG.event(x).type)),
> 1:length(EEG.event) )'; % Pull out a list of event codes in array format
>         STLResponse = [triggers STLResponse]; %Store peak values by event
> type
>
>
> Best,
> Steve
>
>
>
> ---
> Stephen Politzer-Ahles
> University of Oxford
> Language and Brain Lab, Faculty of Linguistics, Phonetics & Philology
> http://users.ox.ac.uk/~cpgl0080/
>
> On Mon, Sep 14, 2015 at 7:43 PM, Tara Miskovich <miskovi2 at uwm.edu> wrote:
>
>> Thank you Steve,
>>
>> Sorry for the delay, I have been trying to play around with the issue,
>> but still appear stuck. I think I fixed the "*Error using horzcat *CAT
>> arguments dimensions are not consistent." error, and I resampled to 1000hz
>> so the the first issue shouldn't be there.
>>
>> Now I am getting the "Warning: Concatenation involves an empty array
>> with an incorrect number of rows. This may not be allowed in a future
>> release." error again, and nothing is being calculated for the STLResponse.
>>
>> I attached the google drive link for the data and the script. Thank you
>> so much, I cannot figure out how to get past this issue.
>>
>> Tara
>>>>  StartleProcessing
>> <https://docs.google.com/a/ucdavis.edu/folderview?id=0B-sCc9Ecpq99QnRvc3FLYThIQlE&usp=drive_web>
>>>>
>> On Tue, Sep 8, 2015 at 1:54 AM, Stephen Politzer-Ahles <
>> stephen.politzer-ahles at ling-phil.ox.ac.uk> wrote:
>>
>>> Hm, it's strange that the first warning message changed (first it was
>>> "Warning: Concatenation involves an empty array with an incorrect number of
>>> rows", now "Warning: Out of range or non-integer values truncated during
>>> conversion to character.") when I don't think it's related to the line that
>>> I suggested. Did you make any other changes higher up in the code?
>>>
>>> As for the last error message, I suspect that's related to the last line
>>> of code (if the number of elements in STLResponse is different than the
>>> number in EEG.event.type, or if one of them needs to be transposed). You
>>> could try running through the code one line at a time to see where the
>>> error pops up. If that doesn't take care of it and no one else has a
>>> solution, you might need to try sharing the data (either via the EEGLAB
>>> Bugzilla, or via a link on e.g. Dropbox or Google Drive; the list doesn't
>>> allow attachments) so we can replicate the issue.
>>>
>>> Best,
>>> Steve
>>>
>>> On Mon, Sep 7, 2015 at 10:34 PM, Tara Miskovich <miskovi2 at uwm.edu>
>>> wrote:
>>>
>>>> Thanks for the response Steve. Thanks for catching that—it isn't
>>>> exactly 1000. I ran the code you gave me and now this pops up. Thank you so
>>>> much for the help with this.
>>>>
>>>> pop_epoch():64 epochs selected
>>>> Epoching...
>>>> pop_epoch():64 epochs generated
>>>> pop_epoch(): checking epochs for data discontinuity
>>>> pop_rmbase(): Removing baseline...
>>>> Warning: Out of range or non-integer values truncated during conversion
>>>> to character.
>>>>
>>>> Then I get:
>>>>
>>>> *Error using horzcat*
>>>> CAT arguments dimensions are not consistent.
>>>>
>>>> On Sat, Sep 5, 2015 at 4:03 PM, Stephen Politzer-Ahles <
>>>> stephen.politzer-ahles at ling-phil.ox.ac.uk> wrote:
>>>>
>>>>> Hello Tara,
>>>>>
>>>>> It's hard to tell without seeing the data, but this sort of thing
>>>>> might happen when the timepoints in your data are not exactly e.g. 20 and
>>>>> 100 ms (which might be the case if your sampling rate was not 1000 Hz). Is
>>>>> the issue fixed if you replace the line in question with the following?
>>>>>
>>>>> STLResponse = squeeze(max(EEG.data(1,find(EEG.times>=20 &
>>>>> EEG.times<=100),:)));
>>>>>
>>>>> Best,
>>>>> Steve
>>>>>
>>>>> On Sat, Sep 5, 2015 at 8:17 PM, Tara Miskovich <miskovi2 at uwm.edu>
>>>>> wrote:
>>>>>
>>>>>> Hello all,
>>>>>>
>>>>>> I am having difficulty with a script I obtained for processing
>>>>>> startle data in EEGlab:
>>>>>>
>>>>>> %% High pass filter
>>>>>>         [HP28_1,HP28_2] = butter(2,28/(EEG.srate/2),'high');    %
>>>>>> generate filter coefficient for 4th order 28Hz High pass Butterworth filter
>>>>>>         EEG.data = filtfilt(HP28_1,HP28_2,EEG.data);  %apply that
>>>>>> filter to ORB channel; filter order is divided by 2 because we use the
>>>>>> filtfilt function to avoid phase shifts in the data
>>>>>>
>>>>>> %% Rectify
>>>>>>         EEG.data = abs(EEG.data); %the 'abs' function rectifies the
>>>>>> data
>>>>>>
>>>>>> %% Low pass filter
>>>>>>         [LP30_1,LP30_2] = butter(2,30/(EEG.srate/2),'low');    %
>>>>>> generate filter coefficient for 4th order 30Hz Low pass Butterworth filter
>>>>>>         EEG.data = filtfilt(LP30_1,LP30_2,EEG.data);  %%apply that
>>>>>> filter to ORB channel; filter order is divided by 2 because we use the
>>>>>> filtfilt function to avoid phase shifts in the data
>>>>>>
>>>>>> %% Epoch and baseline correct
>>>>>>         EventCodes = num2cell(unique([EEG.event.type])); %Extract
>>>>>> event codes for epoching
>>>>>>         EEG = pop_epoch( EEG, EventCodes, [-0.05 0.25], 'epochinfo',
>>>>>> 'yes');  %Epoch file for events that indicate startle probes
>>>>>>         EEG = pop_rmbase( EEG, [-50   0]); %Baseline correct
>>>>>>
>>>>>> %% Mark and reject trials with excessive artificat
>>>>>>         Artifact = squeeze(max(EEG.data(1,1:find(EEG.times==0),:)) -
>>>>>> min( EEG.data(1,1:find(EEG.times==0),:)) > 40); %Identify trials with
>>>>>> greater than 40 microvolt deflections in baseline
>>>>>>         EEGNA = pop_select(EEG,'notrial', find(Artifact)); %Reject
>>>>>> these trials
>>>>>>
>>>>>> %% Score startle peaks
>>>>>>         STLResponse =
>>>>>> squeeze(max(EEG.data(1,find(EEG.times==20):find(EEG.times==100),:)));
>>>>>> %Identify peak response of startle trials in scoring window
>>>>>>         STLResponse = [[EEG.event.type]' STLResponse]; %Store peak
>>>>>> values by event type
>>>>>>
>>>>>> I get the following output:
>>>>>>
>>>>>> pop_epoch():64 epochs selected
>>>>>> Epoching...
>>>>>> pop_epoch():64 epochs generated
>>>>>> pop_epoch(): checking epochs for data discontinuity
>>>>>> pop_rmbase(): Removing baseline...
>>>>>> Warning: Concatenation involves an empty array with an incorrect
>>>>>> number of rows.
>>>>>> This may not be allowed in a future release.
>>>>>>
>>>>>> I am not sure what is the issue here, but after "STLResponse =
>>>>>> squeeze(max(EEG.data(1,find(EEG.times==20):find(EEG.times==100),:)));
>>>>>> %Identify peak response of startle trials in scoring window" I end up with
>>>>>> an empty 0 by 64 matrix.
>>>>>>
>>>>>> I am just a little new to this and can't seem to figure out what is
>>>>>> going on here.
>>>>>>
>>>>>> Thank you!
>>>>>> Tara
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Thank you,
>>>>
>>>> Tara A. Miskovich, M.S.
>>>> Affective Neuroscience Laboratory
>>>> Department of Psychology
>>>> University of Wisconsin-Milwaukee
>>>> 334 Garland Hall
>>>> miskovi2 at uwm.edu
>>>>
>>>
>>>
>>
>>
>> --
>> Thank you,
>>
>> Tara A. Miskovich, M.S.
>> Affective Neuroscience Laboratory
>> Department of Psychology
>> University of Wisconsin-Milwaukee
>> 334 Garland Hall
>> miskovi2 at uwm.edu
>>
>
>


-- 
Thank you,

Tara A. Miskovich, M.S.
Affective Neuroscience Laboratory
Department of Psychology
University of Wisconsin-Milwaukee
334 Garland Hall
miskovi2 at uwm.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150916/59571095/attachment.html>


More information about the eeglablist mailing list