[Eeglablist] using pop_eegplot and eeg_eegrej in a script

James Desjardins jdesjardins at brocku.ca
Thu Jun 16 08:10:02 PDT 2011


Hi Chang,


1- Regarding your questions about to the number of channels plotted in  
the scroll figure...

You can have more control over the scroll plot if you call eegplot.m  
rather than pop_eegplot.m. In order to plot 30 channels with a scroll  
bar the following will work:

eegplot(EEG.data, ...
	'eloc_file',EEG.chanlocs, ...
	'dispchans',30 ...
	);


If instead you would like to only plot specified channels, the  
following creates a "chaninds" vector containing the channel indices  
to plot, then calls eegplot while reducing the data and chanlocs to  
the specified channels:

chaninds=[2,4,6,8];
eegplot(EEG.data(chaninds,:,:), ...
	'eloc_file',EEG.chanlocs(chaninds) ...
	);



When using eegplot instead of pop_eegplot you will notice that by  
default there is no "Reject" or "Update Marks" button in the bottom  
right corner of the scroll plot. To include the "reject" button you  
need to specify a string that will be evaluated following the closing  
of the figure. See the eeg_rejmacro.m file that contains some example  
code for handling rejection options in eegplot. The following is an  
example string adapted from code in eeg_rejmacro.m for the "command"  
optional input to eegplot. This will perform the rejection of trials  
when you press the "reject" button in the bottom right corner of the  
scroll figure:

%command string for reject marked trials... all marked epochs...
cmd = [ ...
'[tmprej tmprejE] = eegplot2trial( TMPREJ, EEG.pnts,' ...
'				EEG.trials);' ...
'[EEGTMP LASTCOM] = pop_rejepoch(EEG, tmprej, 1);' ...
'if ~isempty(LASTCOM),'...
' [ALLEEG EEG CURRENTSET tmpcom] = pop_newset(ALLEEG, EEGTMP,  
CURRENTSET);' ...
' if ~isempty(tmpcom),' ...
'  EEG = eegh(LASTCOM, EEG);' ...
'  eegh(tmpcom);' ...
'  eeglab(''redraw'');' ...
' end;' ...
'end;' ...
'clear EEGTMP tmpcom;' ...
] ;





... then include cmd in the call to eegplot as follows:

chaninds=[2,4,6,8];
eegplot(EEG.data(chaninds,:,:), ...
	'eloc_file',EEG.chanlocs(chaninds), ...
	'command',cmd, ...
	'butlabel','reject' ...
	);



2- Regarding your second question about channel colors by epoch...

The background colors and channel highlights (in red) are determined  
by the "winrej" optional input to eegplot (see the eegplot help for  
details). The rejection information is stored in the "reject" field of  
the EEG structure. To convert the reject field into a winrej array you  
can use trial2eegplot.m (or eegplot2trial.m to convert a winrej array  
into the reject field of the EEG structure).

The following code manually creates a winrej array in which the trials  
2, 6 and 8 will be displayed with a light grey background. Also,  
channels 2, 4 and 6 will be red in trials 2, channels 3, 9 and 12 will  
be red in trial 6 and channels 6 through 12, 16 and 18 will be red in  
trial 8.

%example manual winrej matrix
epoch = [2,6,8];
epochchanind = {[2,4,6],[3,9,12],[6:12,16,18]};

rejepochcol =  [.95, .95, .95];
rejepoch = zeros(1,EEG.trials);
rejepoch(epoch) = ones(1,length(epoch));
rejepochE = zeros(EEG.nbchan,EEG.trials);
for i=1:length(find(rejepoch));
    rejepochE(epochchanind{i},epoch(i))=ones(size(epochchanind{i}));
end

winrej=trial2eegplot(rejepoch,rejepochE,EEG.pnts,rejepochcol);



... then include winrej in the call to eegplot as follows:

eegplot(EEG.data, ...
	'eloc_file',EEG.chanlocs, ...
	'winrej',winrej ...
	);




James Desjardins
Technician, MA Student
Department of Psychology, Behavioural Neuroscience
Cognitive and Affective Neuroscience Lab
Brock University
500 Glenridge Ave.
St. Catharines, ON, Canada
L2S 3A1
905-688-5550 x4676


Quoting Chang Gu <chang.gu at vanderbilt.edu>:

> Dear James & colleagues,
>
> I also have similar questions about eegplot(). I tied using UserData to
> control the total number of channels displayed by eegplot:
>
> pop_eegplot( EEG, 1, 1, 1);
> ud=get(gcf,'UserData');
> ud.dispchans=30; % e.g. 30 channels only
> set(gcf,'UserData',ud);
> eegplot('draws',0);
>
> A "scroll EEG plot" pops out successfully, but only with the last 30
> channels of EEG data: there's no scroll button on the left for selecting
> which 30 channels... Does anyone know if there's a way to add it so that we
> can scroll channels? Or, instead of always showing last 30 channels, a way
> to show certain 30 channels?
>
> Another question about eegplot() is that,  how can I plot certain channels
> within certain segments by different color? I image that we could pass the
> channel number and segments as arguments to eegplot to do that. ( just like
> the in 'all method' artifact detection, EEGlab plots bad channels in
> segments in red . ) Does someone have any idea about that?
>
> Thanks in advance!
>
>
>
> On Mon, Jun 6, 2011 at 2:42 PM, James Desjardins   
> <jdesjardins at brocku.ca>wrote:
>
>> Hi Sebastian,
>>
>>
>> Regarding your first question:
>>
>> I find it useful to batch interactive pruning procedures as well (if
>> for no other reason ... it drastically reduces the number of coffee
>> breaks that I take while pruning data!). To make streamlined
>> interactive batch scripts I have found that accessing the figure's
>> UserData is the best way to proceed.
>>
>> If your script is already loading the data that you want to display
>> and edit the following code will (1) create the eegplot, (2) access
>> the current eegplot's UserData structure, (3) adjust the "winlength"
>> field of UserData, (4) set the current eegplot's UserData using the
>> new values, (5) redraw the current eegplot figure with the new values,
>> (6) wait for this figure to close before continuing on with the
>> remainder of the script.
>>
>> pop_eegplot( EEG, 1, 1, 1); %1
>> ud=get(gcf,'UserData');     %2
>> ud.winlength=40;            %3
>> set(gcf,'UserData',ud);     %4
>> eegplot('draws',0)          %5
>> uiwait;                     %6
>>
>>
>> This procedure is flexible in that any figure properties or UserData
>> fields can be adjusted in script. For example changing step 4 above to:
>>
>> set(gcf,'UserData',ud, 'Position', [1,1,1024,768]);
>>
>> ... will also move the figure to the bottom-left corner of the display
>> and change the size to 1024x768 pixels.
>>
>>
>> Regarding your second question:
>>
>> The final input to the pop_eegplot function ("reject") when set to 1
>> allows the immediate removal of marked time periods. When using this
>> setting simply click the "REJECT" button in the bottom left corner of
>> the eegplot figure when you are finished pruning and then a separate
>> call to pop_eegrej will not be necessary.
>>
>> I hope that this is helpful.
>>
>> James Desjardins
>> Technician, MA Student
>> Department of Psychology, Behavioural Neuroscience
>> Cognitive and Affective Neuroscience Lab
>> Brock University
>> 500 Glenridge Ave.
>> St. Catharines, ON, Canada
>> L2S 3A1
>> 905-688-5550 x4676
>>
>>
>> Quoting Sebastian Urchs <sebastian.urchs at gmail.com>:
>>
>> > Hi,
>> >
>> >
>> >
>> > I am setting up a pipeline for multi-subject data preprocessing including
>> > ICA on a cluster. Now in order to clean up the data before running ICA I
>> > would like to use pop_eegplot() from inside a script that loops through
>> all
>> > my subjects. I will then halt the script until the pop_eegplot() window
>> is
>> > closed again and run eeg_eegrej() on the marked data-parts.
>> >
>> >
>> >
>> > Now my questions are:
>> >
>> >
>> >
>> > : First, sliding through a large dataset in pop_eegplot() is not
>> effective
>> > at the default displayed timerange. Of course this can be changed
>> manually
>> > each time by pointing and clicking but it would be great if I could hand
>> > over arguments to pop_eegplot() when it is called that make the displayed
>> > time range say 50s. I have not managed to change
>> >
>> >
>> >
>> > "eegplotoptions = { 'winlength', 5, 'events', EEG.event };"
>> >
>> >
>> >
>> > arguments from the pop_eegplot.m file itself - could it be that those
>> > settings are hardwired into the file?
>> >
>> >
>> >
>> > : Second, I am wondering where the arrays with the data marked for
>> rejection
>> > are stored within the EEG structure. I would then use this information to
>> > call pop_eegrej() in the script which would make the whole rejection
>> process
>> > much faster.
>> >
>> >
>> >
>> > Thanks a lot in advance!
>> >
>> >
>> >
>> > Sebastian,
>> >
>> > LMU Munich
>> >
>> >
>>
>>
>>
>>
>> _______________________________________________
>> 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
>>
>
>
>
> --
> Chang Gu
> Psychology & Human Development
> Vanderbilt University
> Nashville, TN
>
>
>
>
>
> --
> Chang Gu
> Psychology & Human Development
> Vanderbilt University
> Nashville, TN
>






More information about the eeglablist mailing list