Simply EEGLAB

Merging & selecting data

Station 1 · Lesson 6 · EEGLAB 2026.1

In the GUI

  1. EditSelect data eeglab_data.set
  2. Time range [min max] (s)on->remove these 0 120
  3. OKWhat do you want to do with the new dataset?Name it:OK D1 part 1
  4. Frames per epoch #2: D1 part 1
  5. Datasets Dataset 1:Continuous EEG Data
  6. EditSelect data
  7. Time range [min max] (s)on->remove these 0 120
  8. OK D1 part 2
  9. EditAppend datasets
  10. Dataset indices to merge 2 3
  11. Preserve ICA weights of the first dataset ?OK
  12. OK Merged datasetsD1 merged
  13. Events #4: D1 merged
  14. PlotChannel data (scroll) D1 merged
  15. Datasets Dataset 1:Continuous EEG Data
  16. EditSelect data using eventsRemove data portions around events - pop_rmdat()
  17. Event type(s) ([]=all) square
  18. Time limits [start, end] in sec. -0.5 1square
  19. Keep selectedOK D1 around square
  20. Events boundary

Script

[ALLEEG, EEG, CURRENTSET, ALLCOM] = eeglab;
sampleFolder = fullfile(fileparts(which('eeglab')), 'sample_data');
EEG = pop_loadset('filename', 'eeglab_data.set', 'filepath', sampleFolder);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, 0, ...
    'setname', 'Continuous EEG Data', 'gui', 'off');
EEG = pop_select(ALLEEG(1), 'time', [0 120]);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, ...
    'setname', 'D1 part 1', 'gui', 'off');
EEG = pop_select(ALLEEG(1), 'rmtime', [0 120]);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, ...
    'setname', 'D1 part 2', 'gui', 'off');
EEG = pop_mergeset(ALLEEG, [2 3], 0);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, ...
    'setname', 'D1 merged', 'gui', 'off');
[ALLEEG.pnts]                                  % 30504 15361 15143 30504
isequal(ALLEEG(4).data, ALLEEG(1).data)        % 1: same signal as the original
eeg_eventtypes(EEG)                            % square 80, rt 74, boundary 1
EEG.event(eeg_findboundaries(EEG)).latency     % 15361.5: between samples 15361 and 15362
EEG = pop_rmdat(ALLEEG(1), {'square'}, [-0.5 1], 0);
[ALLEEG, EEG, CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET, ...
    'setname', 'D1 around square', 'gui', 'off');
EEG.pnts                                       % 15336
numel(eeg_findboundaries(EEG))                 % 80
eeglab redraw;

Which value should I choose?

What you wantMenuWhat to type
One continuous part of the recordingEdit > Select dataThe range in seconds in Time range [min max] (s), checkbox unticked.
Remove one continuous part (start, end or a break)Edit > Select dataThe same range, with the checkbox under on->remove these ticked.
The data around one event typeEdit > Select data using eventsThe event type, the limits in seconds around it, and Keep selected.
Remove the data around an event, such as a TMS pulse that saturates the amplifierEdit > Select data using eventsThe event type, short limits around it, and Remove selected. The official tutorial gives this example.
Several runs of one participant in one datasetEdit > Append datasetsThe dataset numbers in the order they were recorded.

Check

  • The Datasets menu lists five datasets: Continuous EEG Data, D1 part 1, D1 part 2, D1 merged and D1 around square
  • Frames per epoch for the first four: 30504, 15361, 15143 and 30504
  • D1 merged has 155 events, eeg_eventtypes shows boundary 1, and you see it as a red line at 120 seconds in the scroll window
  • isequal(ALLEEG(4).data, ALLEEG(1).data) gives 1: merging gave back exactly the original signal
  • D1 around square has 15336 samples and 80 boundary events

For your Methods

Data from the [N] recording runs were concatenated into a single continuous dataset (pop_mergeset, EEGLAB 2026.1), with boundary events marking the joins.

Full lesson: https://simplyeeglab.pages.dev/en/lesson/merge-select-data/

Content license: CC BY-NC-SA 4.0 · MIT (code)

An independent learning site, not affiliated with EEGLAB or SCCN.