
Consider my data epoched with ERPLAB with a part of EEG.epoch variable shown in the picture. Obviously, there are a number of epochs belonging to bin 7, but epoch4bin(EEG,7) will return an empty [].
It is observed that when there is(are) one or more epoch(s) with 2 or more events defined in BDF, both EEG.epoch.eventbini and EEG.epoch.eventlatency variables will be the cell type. However, when there isn't, EEG.epoch.eventbini will be the double type, as shown in the picture (EEG.epoch.eventlatency will be 0s but not the cell type as well, but this doesn't matter in this issue). This very condition is not considered in the function epoch4bin.
Consider how epoch4bin will process the 1st epoch in the picture:
Let me first give value binArray=7; i=1;
then test the script as in epoch4bin
` bini = EEG.epoch(i).eventbini; % bin indices at this epoch
laten = EEG.epoch(i).eventlatency; % latencies at this epoch
if iscell(laten)
laten = cell2mat(laten);
end
indxtimelock = find(laten == 0,1,'first'); % catch zero-time locked code position,
bin = bini(indxtimelock); % bin of the home item event code (time-locked event)
if iscell(bin)
bin = cell2mat(bin); %bug. It said "bini"
end
if nnz(ismember_bc2(bin, binArray)) > 0
indx(k) = i;
k=k+1;
end`
The result will be that nnz(ismember_bc2(bin, binArray))==0, because the sentence bin = bini(indxtimelock); has acted as if EEG.epoch.eventbini is a cell. Unfortunately, here bini is not a cell but a double [2, 7, 11]. Therefore bin will be 2 but not [2, 7, 11], then nnz(ismember_bc2(bin, binArray))==0. The epoch4bin function then will wrongly decide that my 1st epoch does not belong to bin 7.
Therefore, I suggest a modification of epoch4bin as shown below:
change bin = bini(indxtimelock);
to
if iscell(bini) bin = bini(indxtimelock); elseif isnumeric(bini) bin=bini; end
The EEG EVENTLIST example and my BDF txt file are attached.
13_Eventlist_Bins_TF.txt
BDFpare.txt
Consider my data epoched with ERPLAB with a part of EEG.epoch variable shown in the picture. Obviously, there are a number of epochs belonging to bin 7, but
epoch4bin(EEG,7)will return an empty [].It is observed that when there is(are) one or more epoch(s) with 2 or more events defined in BDF, both EEG.epoch.eventbini and EEG.epoch.eventlatency variables will be the cell type. However, when there isn't, EEG.epoch.eventbini will be the double type, as shown in the picture (EEG.epoch.eventlatency will be 0s but not the cell type as well, but this doesn't matter in this issue). This very condition is not considered in the function epoch4bin.
Consider how epoch4bin will process the 1st epoch in the picture:
Let me first give value
binArray=7; i=1;then test the script as in epoch4bin
` bini = EEG.epoch(i).eventbini; % bin indices at this epoch
laten = EEG.epoch(i).eventlatency; % latencies at this epoch
The result will be that nnz(ismember_bc2(bin, binArray))==0, because the sentence
bin = bini(indxtimelock);has acted as if EEG.epoch.eventbini is a cell. Unfortunately, here bini is not a cell but a double [2, 7, 11]. Therefore bin will be 2 but not [2, 7, 11], then nnz(ismember_bc2(bin, binArray))==0. The epoch4bin function then will wrongly decide that my 1st epoch does not belong to bin 7.Therefore, I suggest a modification of epoch4bin as shown below:
change
bin = bini(indxtimelock);to
if iscell(bini) bin = bini(indxtimelock); elseif isnumeric(bini) bin=bini; endThe EEG EVENTLIST example and my BDF txt file are attached.
13_Eventlist_Bins_TF.txt
BDFpare.txt