11.7: Exercise- EEG.history and eegh

Applied Event-Related Potential Data Analysis 2e · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    11.7: Exercise- EEG.history and eegh

    EEGLAB has a super convenient history feature, which we shamelessly copied when we created ERPLAB. Whenever you run a routine from the ERPLAB Studio GUI, the equivalent Matlab command text is saved in the history. The history field of the EEG variable (i.e., EEG.history) stores the history of the routines that were applied to that specific EEGset. You can see the history by typing EEG.history on the Matlab command line. In addition, you can get a history of everything that was done since the last time you launched eStudio (which might include routines applied to many different EEGsets) by typing eegh on the command line.

    You can also see the history in ERPLAB Studio's History panel (which allows you to select the Current EEGset history or the Current session history).

    Go to the EEGsets panel and select the first EEGset (which should be named My First Custom Dataset). This EEGset should now be stored in the EEG variable, and if you type EEG.history you should see the history of the routines that were applied to this EEGset:

    >> EEG.history

    ans =
         EEG.etc.eeglabvers = '2025.0.0'; % this tracks which version of EEGLAB is being used, you may ignore it
         EEG = pop_loadset('filename','1_N170.set','filepath','/Users/luck/Library/CloudStorage/Box-Box/Permanent_Sharing/ERP_Analysis_Book_Files/Chapter_11/');

    The first line (beginning EEG.etc.eeglabvers) was automatically added by the software to help you track what version of EEGLAB was used. The second line (beginning pop_loadset) is the command you used to load the EEGset from a file. Notice that the Matlab command that you used to change the name of the EEGset isn’t in the history. Only EEGLAB and ERPLAB operations are automatically saved in the history.

    I want to pause for a minute and encourage you to appreciate what just happened. You used your mouse to load the EEGset using the ERPLAB Studio GUI, which should have been simple and natural now that you’ve spent a lot of time using ERPLAB Studio. And then the history allowed you to see the actual Matlab command that was used to load the EEGset. This is the same command you’ll use to load EEGsets when you start writing scripts. So, you don’t need to read some opaque documentation to figure out what command to use and how to use it. You just need to run the routine from the GUI and look at the history.

    This makes scripting so much easier! And it’s not just for beginners: when I created the scripts for each chapter of this book, I first ran the routines from the GUI so that I could get the history, which I then copied into the scripts that I was writing. I’m not sure which of the original EEGLAB developers came up with this scheme, but it’s brilliant!

    Now that I’ve gushed about how great this is, I want to note a small complication. If you look closely at the pop_loadset command that was used to load the EEGset, you’ll see that it specifies the filename ('filename', '1_N170.set') and the location of the file on your hard drive (the path to the file, listed in the string following 'filepath'). However, the path that you can see on your computer is not the same as the path shown above, which shows the path on my computer ('/Users/luck/Library/CloudStorage/Box-Box/Permanent_Sharing/ERP_Analysis_Book_Files/Chapter_11/').

    Keep in mind that the paths you’ll see in this book reflect the organization of files on my computer, so they won’t be the same as the paths you’ll see on your computer. Paths can be pretty confusing. One of the most common problems people have when learning to write scripts is getting the paths wrong. I often get them wrong myself. Later, I’ll demonstrate a strategy you can use to avoid path problems.

    Now select the second EEGset in the EEGsets panel (01_N170_filt), and type EEG.history to see the history for that EEGset:

    EEG.etc.eeglabvers = '2025.0.0'; % this tracks which version of EEGLAB is being used; you may ignore it
    EEG = pop_loadset('filename', '1_N170.set', 'filepath','/Users/luck/Library/CloudStorage/Box-Box/Permanent_Sharing/ERP_Analysis_Book_Files/Chapter_11/');
    EEG  = pop_basicfilter( EEG,  1:33, 'Boundary', 'boundary', 'Cutoff', [ 0.1 30], 'Design', 'butter', 'Filter', 'bandpass', 'Order',  2, 'RemoveDC', 'on' ); % GUI: 25-Oct-2025 06:26:07'

    You’ll see that the first two lines are the same as the history for the first EEGset. That’s because those commands are part of the sequence of operations that was applied to the second EEGset. Following those lines, you can see the command for filtering the EEG (beginning with pop_basicfilter). When you're writing a script that includes filtering, you can see what text to write by filtering a file in the GUI, looking at the history, and then copying this line of code into your script.

    Now go back to the EEGsets panel and select the first EEGset (My First Custom EEGset). Then delete channel 33 from this EEGset by going to the Edit/Delete Channels & Locations panel, entering 33 in the Chan field, and clicking the Delete chan button. We've now modified both of the EEGsets, deleting channel 33 from EEGset 1 and filtering EEGset 2. If you select one of these two EEGsets, which causes it to be stored in the EEG variable, you can see the Matlab commands for these operations.

    If you want to see everything you've done since launching eStudio, you can use type eegh in the Command window. If you do that now, you should see something like this:

    EEG = pop_loadset('filename','1_N170.set','filepath','/Users/luck/Library/CloudStorage/Box-Box/Permanent_Sharing/ERP_Analysis_Book_Files/Chapter_11/');
    % Selected continuous EEG sets: [1. 1_N170]
    EEG  = pop_basicfilter( EEG,  1:33 , 'Boundary', 'boundary', 'Cutoff', [ 0.1 30], 'Design', 'butter', 'Filter', 'bandpass', 'Order',  2, 'RemoveDC', 'on' ); % GUI: 25-Oct-2025 06:26:07
    % Selected continuous EEGsets: [2. 01_N170_filt]
    % Selected continuous EEGsets: [1. My First Custom Dataset]
    % Selected continuous EEGsets: [2. 01_N170_filt]
    % Selected continuous EEGsets: [1. My First Custom Dataset]
    EEG = pop_select( EEG, 'rmchannel',{'VEOG_lower'});
    % Selected continuous EEG sets: [1. My First Custom Dataset]

    Note that several lines begin with a percent symbol (%). Matlab uses this symbol to denote that a line is a comment rather than code to be executed. ERPLAB Studio adds comments to the session history to make it clear which EEGset or ERPset has been selected.

    The first line in the history above is the command for loading the first EEGset from your hard drive into the EEG variable. The next line is a comment indicating that EEGset 1 is now selected. The next line of code is for the filtering routine, which operates on the EEG variable. The resulting EEGset was saved as the second EEGset in ALLEEG, and became the selected EEGset, so the following comment indicates that the second EEGset is now selected.

    The next several lines are comments resulting from the fact that the previous exercises involved switching between the two EEGsets in the EEGsets panel.

    The next line of Matlab code (i.e., the next line that does not begin with a %) shows the operation for removing channel 33 from the first EEGset. You can tell that it operated on the first EEGset because the comment right above it indicates that EEGset 1 was selected.

    As a reminder, you can also see the history in ERPLAB Studio's History panel, selecting either the Current EEGset history (like typing EEG.history) or Current session history (like typing eegh). It's hard to see the history very well in a small panel, so there is a button for showing the history in the command window. There's also a button that lets you save the history in a file, which is useful when you are ready to turn the history into a script.

    You now know how to see the Matlab commands for the routines you run in the ERPLAB Studio GUI. This will make your life much easier in the following exercises, where you’ll start putting together scripts.


    This page titled 11.7: Exercise- EEG.history and eegh was last modified on Thu, 01 Oct 2026 18:52:38 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Steven J Luck directly on the LibreTexts platform.