Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract epochs function ignores the first epoch #22

Closed
vpKumaravel opened this issue Jun 23, 2019 · 2 comments
Closed

Extract epochs function ignores the first epoch #22

vpKumaravel opened this issue Jun 23, 2019 · 2 comments
Labels
question Further information is requested

Comments

@vpKumaravel
Copy link

vpKumaravel commented Jun 23, 2019

Hi,

Description

I want to process artifacts in a 1 second window and therefore, I create temporary epochs using eeg_regepoch function:
EEG = eeg_regepochs(EEG,'eventtype', 'temp', 'extractepochs', 'on', 'recurrence', 1, 'limits', [0 1]);
I find that, by doing so, I miss the first epoch (500 latency points as my Fs = 500 Hz) in the outcome.

Screenshots: https://drive.google.com/drive/folders/1poMQwW_M-uhVyeDmxLNanPEoXfs51Ee7?usp=sharing

Related bug report in the past: https://sccn.ucsd.edu/pipermail/eeglablist/2017/012607.html


#### Steps to Reproduce
  1. Load the continuous eeg data

  2. Plot the data and leave the figure open (to later compare)

  3. Run the function in the command line
    EEG = eeg_regepochs(EEG,'eventtype', 'temp', 'extractepochs', 'on', 'recurrence', 1, 'limits', [0 1]);

  4. Plot the data again and compare this figure with (2).

  5. Instead of (3), if I run this function,
    EEG = eeg_regepochs(EEG,'eventtype', 'temp', 'extractepochs', 'on', 'recurrence', 1, 'limits', [0.002 1]);
    I get the expected behavior.
    Note: 0.002 indicates the latency of my first event in the data.


#### Expected behavior: I expect, if I have, let's say [0-40] seconds of data, I get 40 epochs of 1 second each.
#### Actual behavior: Instead, I get 39 epochs
#### Versions
OS version Windows 10
Matlab version R2018b
EEGLAB version EEG development head

Kindly close this bug if this is the intended functionality. Thanks!

@nucleuscub
Copy link
Member

Hi @Velu44 ,
Can you please run the code below and let me know what do you get. The three values displayed at the end of the script must be the same and equal to the initial number of 1s segments (40 here).
Thanks,
R

`% Define number of trials
ntrials = 40;

% Create dummy EEG set
EEG = eeg_emptyset;
EEG.srate = 500;
EEG.data = rand(1,ntrialsEEG.srate + 1,1);
EEG.epoch = 0;
EEG.trials = 1;
EEG.nbchan = 1;
EEG.pnts = ntrials
EEG.srate + 1;
EEG = eeg_checkset(EEG);

% Here we will generate 40 trials of 1 sec duration (500 points)
EEG1 = eeg_regepochs(EEG,'eventtype', 'temp', 'extractepochs', 'on', 'recurrence', 1, 'limits', [0 1]);

% Here we will generate 40 trials of 0.3s duration (150 points). Notice here below that 0.5 and 0.8s is relative
% to the dummy event(temp) so trials will not contain the dummy event
EEG2 = eeg_regepochs(EEG,'eventtype', 'temp', 'extractepochs', 'on', 'recurrence', 1, 'limits', [0.5 0.8]);

% Disp
disp(['Original trials:' num2str(ntrials)]);
disp(['Case 1 trials:' num2str(EEG1.trials)]);
disp(['Case 2 trials:' num2str(EEG2.trials)]);`

@nucleuscub nucleuscub added the question Further information is requested label Aug 9, 2019
@arnodelorme
Copy link
Collaborator

I have fixed the function eeg_regepochs.m so it returns the right number of epochs. The last epoch was missing though, not the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants