Error with simulate with SimMEEG: (Line 164)

When I tried to run a simulation using SimMEEG within Brainstorm, I encountered this kind of error.”

How should I deal with it?

Hi @SotomeTsubasa, the line reported in the error does not correspond with the current state of the code. Please check and report the following, you need to start Brainstorm before running these commands:

  • Brainstorm version
    bst_get('Version')

  • Directory for the Brainstorm application (you need to start Brainstorm first)
    bst_get('BrainstormHomeDir')

  • The path for bst_simmeeg.m
    which('bst_simmeeg.m', '-all')

Thank you for your replying!

I report the results executing the command as per your instructions below.


** Error: Line 164: Index exceeds the number of array elements. Index must not exceed 0.
**
** Call stack:
** >bst_simmeeg.m>LoadInputs at 164
** >bst_simmeeg.m>GUI at 42
** >bst_simmeeg.m at 26
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@bst_simmeeg,'GUI',iStudy) at 774
**


bst_get('Version')

ans =

struct with fields:

   Name: 'Brainstorm'
Version: '3.251217'
Release: '251217'
   Date: '17-Dec-2025'
 Commit: []

bst_get('BrainstormHomeDir')

ans =

'/Users/saotomeshou/Desktop/M1/実験/シミュレーション/brainstorm3'

which('bst_simmeeg.m', '-all')
/Users/saotomeshou/Desktop/M1/実験/シミュレーション/brainstorm3/toolbox/gui/bst_simmeeg.m

Hello @SotomeTsubasa, thank you for the provided information.

It seems that you are trying to use SimMEEG without a head model in the condition, is that the case?

Thank you for your replying!

Actually I am using SimMEEG with a head model in the condition. (I’m sorry if I misunderstood.)

The Brainstorm’s screen currently looks like the image below.

When I double-clicked on “10-20(19)” and confirmed data of electrodes and anatomy, the electrode seems to be slightly off-center from the scalp.

As shown in the photo below, the electrode appears to be slightly misaligned from the scalp.

Error Line 164 appears when I right-click on “NewCondition“ and click on “Simulate signals: SimMEEG“.

But today, after I click on “Simulate signals: SimMEEG“ and update SimMEEG, the following error occurred.:cry:


BST> Plugin simmeeg already loaded: /Users/saotomeshou/.brainstorm/plugins/simmeeg
BST> Processing dependencies: simmeeg requires: fieldtrip
BST> Plugin simmeeg already loaded: /Users/saotomeshou/.brainstorm/plugins/simmeeg
Unrecognized function or variable 'bst_simmeeg'.

Error in tree_callbacks>SimulateSimmeeg (line 3970)
bst_simmeeg('GUI', iStudy);

Error in tree_callbacks>@(h,ev)SimulateSimmeeg(iStudy) (line 774)
gui_component('MenuItem', jPopup, , 'Simulate signals: SimMEEG', IconLoader.ICON_EEG_NEW, , @(h,ev)SimulateSimmeeg(iStudy));

The screenshot shows you do have a channel file (iconChannel), however there is not a head model file: (iconHeadModel) which is needed to use SimMEEG.


About bst_simmeeg missing:

Please Update the SimMEEG plugin.
In the main Brainstorm window: Plugin > Simulation > SimMEEG > Update

Then, when you try to compute the simulations, you may see this error:

Index exceeds the number of array elements. Index must not exceed 0.

Error in bst_simmeeg>LoadInputs (line 164)
        hm = bst_get('HeadModelFile', fullfile(hdm_dir, x(1).name));

Error in bst_simmeeg>GUI (line 42)
    bst = LoadInputs(iStudy);

Error in bst_simmeeg (line 26)
eval(macro_method);

Error in tree_callbacks>SimulateSimmeeg (line 3971)
    bst_simmeeg('GUI', iStudy);

Error in tree_callbacks>@(h,ev)SimulateSimmeeg(iStudy) (line 775)
                        gui_component('MenuItem', jPopup, [], 'Simulate signals: SimMEEG', IconLoader.ICON_EEG_NEW, [], @(h,ev)SimulateSimmeeg(iStudy));

There is currently, a bug in SimMEEG:

You would need to manually, comment line 196 in the file:
/Users/saotomeshou/.brainstorm/plugins/simmeeg/SimMEEG-master/update_anatomy_fields.m
The lines currently reads:

h.menu_head_model.String = hdm_string(hdm_flag);

As sanity check, follow the video in SimMEEG section of the simulations tutorial:
Please note that the latest version of SimMEEG may look a bit different from the one in the video, but all the options are there.