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

Error in EEGLAB plug in BrainBeats for HEP extraction #707

Open
oux20a opened this issue Dec 6, 2023 · 15 comments
Open

Error in EEGLAB plug in BrainBeats for HEP extraction #707

oux20a opened this issue Dec 6, 2023 · 15 comments

Comments

@oux20a
Copy link

oux20a commented Dec 6, 2023

Description

I am using the BrainBeats plug in feature of EEGLAB, hoping to use this for extracting and analysing Heartbeat Evoked Potentials from my EEG data. I've solved a lot of previous error messages by installing plug ins, but I am new to EEGLAB and at a loss how to fix this one. Any help appreciated. It's quite a new plugin, so I'm using the only version (BrainBeats1.1) which can be downloaded here: https://sccn.ucsd.edu/eeglab/plugin_uploader/plugin_list_all.php

I have put my biosemi .bdf EEG data into EEGLab on Matlab and saved as a .set file after assigning channel locations and rereferencing to mastoids. I have then opened .set file in Brainbeats1.1 and tried to extract Heartbeat Evoked Potentials.

Brainbeats paper contains instructions
Cannard, C., Wahbeh, H., & Delorme, A. (2023). BrainBeats : an open-source EEGLAB plugin to jointly analyze EEG and cardiovascular ( ECG / PPG ) signals. 0–26.
https://www.biorxiv.org/content/10.1101/2023.06.01.543272v1

I can run the script (method 1) until receiving error message.
[https://bangoroffice365-my.sharepoint.com/:i:/g/personal/oux20a_bangor_ac_uk/EVe4OLSVIyxOuWP8BexeLNwBUFrzIHEv5-QEt_JUzVkW1A?e=kpTywH]url

BrainBeats EEGLAB error in function run_HEP at line 41
](url)

Here is the .set data file I am working with
https://bangoroffice365-my.sharepoint.com/:u:/g/personal/oux20a_bangor_ac_uk/EVRMkBXb48JNhWAS7lfg2uYBj089XIXJr2SCrgRy3tvM5Q?e=bcw7M1


#### Steps to Reproduce
  1. [Saved my .bdf file as a .set file in EEGLAB]
  2. [Load data into EEGLAB: File > Load existing dataset >MGpractice231123_1524.set]
  3. [Tools>Brainbeats>process file at subject level]
  4. [Select "Heartbeat-evoked potentials HEP" as analysis to run, "ECG" as heart data type, select the ECG channels labeled > 'EKGl' is my heart beat channel]
  5. [All other ticks in boxes are left as automated]
  6. [Select Ok]

#### Expected behavior: [*The paper by Cannard et al 2023 doesn't specify what happens next - expected all the script to run on MATLAB and then produce some HEP data to analyse*]
#### Actual behavior: [*I get an EEGLAB error message stating: "EEGLAB error in function run_HEP() at line 41: Assigning to 2 elements using a simple assignment statement is not supported. Consider using comma-separated list assignment.*]
#### Versions | | | |----| ---- | | OS version | [*Windows 10 OS build 19045.3693*] | | Matlab version | [*R2023b*] | | EEGLAB version | [*2023.1*] |
@arnodelorme
Copy link
Collaborator

Apologies for the late reply.
@amisepa can you look into this?

@amisepa
Copy link
Contributor

amisepa commented Feb 8, 2024

@oux20a can you please try the new version of BrainBeats v1.4. and see if the problem is still present?
Let me know if it works. I can't access your dataset so please re-upload if you want me to take a look.
Thanks

@oux20a
Copy link
Author

oux20a commented Feb 9, 2024 via email

@amisepa
Copy link
Contributor

amisepa commented Feb 9, 2024

Hi Kitty,

Yes we'll make sure it works for you. It works for us so there is no reason we can't solve the issues.

Please try these steps:

  1. Can you please remove any old version of EEGLAB and install the latest version by downloading and unzipping the latest version: https://github.com/sccn/eeglab
  2. Same for BrainBeats: download here v1.4. https://github.com/amisepa/BrainBeats and unzip it in eeglab > plugins folder on your ocmputer
  3. Add path in MATLAB to eeglab folder
  4. Launch eeglab
  5. Load tutorial dataset
  6. Try HEP with default parameters

If you still get errors, please report them here

Cedric

@oux20a
Copy link
Author

oux20a commented Feb 13, 2024

Hello Cedric,

Thank you so much for offering your assistance. I was confident I had the newest versions, but I’ve still wiped everything and followed the steps you outlined above.

At first I got an EEGLAB error “EEGLAB error in function clean_eeg() at line 143: Undefined function ‘ref_infinity’ for input arguments of type ‘struct’.”

This was a familiar error message that had previously been resolved following advice from a technician at my University - that I install the 'REST_cmd' plugin.

I installed reference_infinity-REST_cmd again for my new EEGLAB download. I also re-added plug in biosig4octmat-3.8.3 as this was another recommendation I’d found online previously for processing EEG/biomedical data. My Matlab command window stated I wasn’t using the most updated version of plug-ins ‘dipfit’ and ‘ICLabel’ so I updated these too. All plug-ins were sourced directly from https://sccn.ucsd.edu/eeglab/plugin_uploader/plugin_list_all.php

It successfully runs through a lot more code, before the error: “EEGLAB error in function vis_artifacts() at line 153: Undefined function ‘mad’ for input arguments of type ‘double’”

I’d read that EEGLAB may function better with additional toolboxes in Matlab (I am running most recent version R2023b) https://sccn.ucsd.edu/eeglab/ressources.php#:~:text=Additional%20Matlab%20toolboxes%3A%20EEGLAB%20requires,However%2C%20some%20toolboxes%20are%20recommended … So I’ve added Signal Processing toolbox, Statistics toolbox and Image processing toolbox.

Running Brainbeats again, it went much further than I had seen previously (pop-up graphs included RR Intervals and artifacts, EEG channels removed, Interbeat intervals (IBI) distribution, Epochs removed). However, I got this error message -first one I’ve seen that has said it’s not a bug:

“pop_runica error: wrong value for argument ‘icatype’, This is not a bug (Error occurred in function pop_runica() at line 301)”

Any advice regarding how to move forward would be most appreciated.

Best wishes,

Kitty

@amisepa
Copy link
Contributor

amisepa commented Feb 13, 2024

Thanks for this new info.

What computer are you using (Windows, MAc, Linux)?

Strangely, the REST_cmd plugin should get installed automatically by BrainBeats if it is not already installed.
For future reference, you can also install and update plugins from the EEGLAB GUI, it's easier. File > Manage extensions > type name of plugin in search bar > Install/update

Strange about the error in vis_artifacts(), the mad function was introduced in MATLAB R2006a. Maybe part of the Statistics toolbox? not sure I thought that was part of basic MATLAB.

“pop_runica error: wrong value for argument ‘icatype’, This is not a bug (Error occurred in function pop_runica() at line 301)”
Can you put a break point at line 301 of pop_runica and see what the input right after 'icatype' is. My guess is that the PICARD plugin was not installed automatically just like REST_cmd, and it's trying to run it.
If you don't know how to do that, go extension manager and install the PICARD plugin manually.
Alternatively, Change the option in the GUI parameters to the standard ICA and tell me if that works.

Cedric

@oux20a
Copy link
Author

oux20a commented Feb 14, 2024

Hello Cedric,

I'm using Windows 11, it's a brand new laptop with 16GB RAM.
Thanks for the tip re installing future plugins.
Perhaps because my Matlab download was through a student license it was basic, but I could get add-on toolboxes.

After installing PICARD plugin it runs for longer again and the “pop_runica error” doesn’t happen. I re-read your paper yesterday and saw reference to PICARD plugin there too, apologies for not picking up on this earlier.

I had a go at the break point recommendation (I’m not a programmer as you’ve probably guessed!). I put a break point at line 301 in pop_runica. When I ran Brainbeats again it stopped at that line and last two lines in command window read:
“Pop_select: removing 18 unreferenced events
301 if ischar(g), error(g); end”

On the pop_runica code itself, I could only see “icatype” nearby at line 293. Around that the code reads:
[ g, addoptions ] = finputcheck( options, { 'icatype' 'string' unique({ allalgs.name }) 'runica'; ...
'dataset' 'integer' [] [1:length(ALLEEG)];
'options' 'cell' [] {};
'concatenate' 'string' { 'on','off' } 'off';
'concatcond' 'string' { 'on','off' } 'off';
'reorder' 'string' { 'on','off' } 'on';
'chanind' { 'cell','integer' } { [] [] } [];}, ...
'pop_runica', 'ignore');

That’s probably not what you meant and I've misunderstood? (But it runs further with PICARD anyway, which has resolved the pop_runica error).

I tried running again but setting the "ICA method to extract artifactual components" to 'normal' rather than 'fast (default)' in the GUI for HEP. It’s the only parameter I could see relating to your suggestion “Change the option in the GUI parameters to the standard ICA” - so I’m not sure if that was what you meant?

I get “uicontrol error. Value must be numeric and finite, This is not a bug (Error occurred in function pop_selectcomps() at line 216).”

I get this same error if I re-select the default ICA parameter of 'fast' as well.

Sorry this isn't an easy fix, I'm very grateful for your support.

Thanks,
Kitty

@amisepa
Copy link
Contributor

amisepa commented Feb 15, 2024

The plugin should be installed automatically by BrainBeats though. I'll need to investigate that.

"ICA method to extract artifactual components" to 'normal' rather than 'fast (default)'

Yes that's what I meant, sorry if that wasn't clear.

I get “uicontrol error. Value must be numeric and finite, This is not a bug (Error occurred in function pop_selectcomps() at line 216).”

Does this happen when you click in the GUI or while it runs?

After installing PICARD plugin it runs for longer again and the “pop_runica error” doesn’t happen. I re-read your paper yesterday and saw reference to PICARD plugin there too, apologies for not picking up on this earlier.

So this worked then? Is it only when you select new options in the GUI that you get an error now?

@oux20a
Copy link
Author

oux20a commented Feb 15, 2024

Hello Cedric,

The pop_runica error was resolved by PICARD plugin.

The 'uicontrol error' is the next block - after PICARD plugin fixed pop_runICA I tried running again and got that error message (yes, with default parameters re-set in GUI).

Sorry about this

Thanks, Kitty

@oux20a
Copy link
Author

oux20a commented Feb 28, 2024

Hello Cedric,

I'm sorry to keep bothering you about this and really appreciate all your suggestions so far.

I saw there had been updates to BrainBeats 2 days ago by yourself on https://github.com/amisepa/BrainBeats/ but unfortunately the error I described previously is still occurring, using the Brainbeats sample data.
“uicontrol error. Value must be numeric and finite, This is not a bug (Error occurred in function pop_selectcomps() at line 216).”

I've been busy with the adventure therapy side of my interoception research over the last couple of weeks and am now focusing on progressing with the EEG data. I'm going to look into alternatives for HEP but would ideally really love to use Brainbeats, so it would be great to hear if you think the error is resolvable.

Best wishes,
Kitty

@amisepa
Copy link
Contributor

amisepa commented Feb 28, 2024

Hi, yes sorry I have been working on other things, the paper is about to get published after a few minor plot tweaks.

I thought you could run it without the GUI, no? Do you know how to use the command lines?
See the "brainbeats_tutorial" script in the BrainBeats folder.
For example, with all default settings, use this for HEP:

EEG = brainbeats_process(EEG,'analysis','hep','heart_signal','ECG', ...
'heart_channels',{'ECG'},'clean_eeg',true);

@amisepa
Copy link
Contributor

amisepa commented Feb 28, 2024

I'll try to fix the GUI issue shortly

@oux20a
Copy link
Author

oux20a commented Feb 28, 2024

Ah sorry, miscommunication. I meant 'yes' I still get the uicontrol error even with default parameters on GUI.
Absolutely no need to apologise, I appreciate you will be very busy. Please don't feel obliged to reply until the publication pressure is over.
If I run by command line I still get the same issue I think. It runs for the same amount of time (same graphs and text running in command window) then stops due to an error. Rather than pop up box the error is specified in command window in red text. However it gives more detail afterwards than the GUI does, maybe that's helpful?

It reads:
"Error using uicontrol
Value must be numeric and finite

Error in pop_selectcomps (line 216)
hh = uicontrol(gcf, 'Style', 'pushbutton', 'string', 'Cancel', 'Units','Normalized', 'backgroundcolor',
GUIBUTTONCOLOR, ...

Error in clean_eeg (line 304)
pop_selectcomps(EEG,1:nComps)

Error in run_HEP (line 110)
[HEP, params] = clean_eeg(HEP,params);

Error in brainbeats_process (line 290)
EEG = run_HEP(EEG, CARDIO, params, Rpeaks); % for adding cardio channel back in final output

Error in brainbeats_tutorial (line 71)
EEG = brainbeats_process(EEG,'analysis','hep','heart_signal','ECG', ..."

@oux20a
Copy link
Author

oux20a commented Feb 28, 2024

And the point that it gets to before the error is:
[lots of previous iterations...]
iteration 172, gradient norm = 1.602e-08
Scaling components to RMS microvolt
Scaling components to RMS microvolt
ICLabel: extracting features...
Scaling components to RMS microvolt
Recomputing ICA activations
ICLabel: calculating labels...
ICLabel: saving results...
0 components flagged for rejection, to reject them use Tools > Remove components from data
Scaling components to RMS microvolt
Drawing figure...
Error using uicontrol

@amisepa
Copy link
Contributor

amisepa commented Feb 28, 2024

Oh ok, so this is actually an ICLabel issue, when plotting the components.

@arnodelorme have you ever seen this when calling pop_selectcomps ?

@amisepa amisepa reopened this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants