EEGLAB - Rename an event

6 views (last 30 days)
COLLART Aymeric
COLLART Aymeric on 22 Oct 2021
Answered: COLLART Aymeric on 26 Oct 2021
Hi,
I need to reanalyze an EEG dataset that was already preprocessed with EEGLAB and ERPLAB. However, I discovered that a " sign was added to the label of a bin, and this sign is disturbing some other functions.
The dataset looks like this (I highlighted the cells I would like to change in blue and underlined the " sign to erase).
What I would like to do is to erase this " sign (as with the "find and replace" function in Excel). After going through a lot of similar questions and trying to implement the answers, nothing really worked.
Did anyone run into a similar problem, and if so, is there a solution to this problem?
Thank you in advance for the replies!
Best regards,
Aymeric

Accepted Answer

Dave B
Dave B on 22 Oct 2021
Edited: Dave B on 22 Oct 2021
In general, the excel-like find and replace can be done with strrep:
bad = {'a' 'b"' 'c'}
bad = 1×3 cell array
{'a'} {'b"'} {'c'}
good = strrep(bad,'"','')
good = 1×3 cell array
{'a'} {'b'} {'c'}
But I'm not 100% sure I follow what your data structure is. If you uploaded a mat file containing EEG it would be somewhat easier (save('eegdata','EEG')), maybe this would work (it removes all quotes regardless of the label):
for i = 1:numel(EEG.event)
EEG.event(i).codelabel = strrep(EEG.event(i).codelabel, '"', '');
EEG.event(i).binlabel = strrep(EEG.event(i).binlabel, '"', '');
end

More Answers (1)

COLLART Aymeric
COLLART Aymeric on 26 Oct 2021
Thanks a lot for this answer, the code you provided perfectly worked!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by