[Eeglablist] fitTwoDipoles error message

Maksimovskiy, Arkadiy AMAKSIMOVSKIY at MCLEAN.HARVARD.EDU
Wed Oct 19 17:32:48 PDT 2022


Hello Experts,
I am encountering the following error when using the fitTwoDipoles function to estimate symmetrically constrained bilateral dipoles.
Error:
‘Index exceeds the number of array elements. Index must not exceed 6.’
Code:
EEG = fitTwoDipoles(EEG, 'LRR', 35);
Output (last few lines before the error):
Optimization terminated:
the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-04
and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-04
found minimum after non-linear optimization for topography 1 on [-5.54128e-06 2.87688 -31.3614; 5.54128e-06 2.87688 -31.3614]
the call to "ft_dipolefitting" took 2 seconds and required the additional allocation of an estimated 0 MB
Fail to look up brain areas
Index in position 1 exceeds array bounds.
Error in fitTwoDipoles (line 46)
    firstDipolePosxyz  = EEG.dipfit.model(bilateralDipoleIdx(m)).posxyz(1,:);
Version info:
"fieldtrip-" v20221018
EEGLAB v2022.1

The function consists of the following code:
function EEG = fitTwoDipoles(EEG, symmetryRegion, threshold)

% Run Caterina's bilateral dipole finder.
sym_class = IC_sym_class(EEG,  'sym_reg', symmetryRegion, 'threshold', threshold, 'plot', 'no');
bilateralDipoleIdx = find(sym_class(2,:));

% Fit bilateral dipoles
for m=1:length(bilateralDipoleIdx)
    firstDipolePosxyz  = EEG.dipfit.model(bilateralDipoleIdx(m)).posxyz(1,:);
    firstDipoleMomxyz  = EEG.dipfit.model(bilateralDipoleIdx(m)).momxyz(1,:);
    secondDipolePosxyz = firstDipolePosxyz.*[-1 1 1];
    secondDipoleMomxyz = firstDipoleMomxyz.*[-1 1 1];
    EEG.dipfit.model(bilateralDipoleIdx(m)).posxyz(2,:) = secondDipolePosxyz;
    EEG.dipfit.model(bilateralDipoleIdx(m)).momxyz(2,:) = secondDipoleMomxyz;
    EEG.dipfit.model(bilateralDipoleIdx(m)).select = [1 2];
    EEG = dipfit_nonlinear(EEG, 'symmetry', 'x', 'component', bilateralDipoleIdx(m));
end

for m=1:length(bilateralDipoleIdx)
    disp(bilateralDipoleIdx(m))
end

When testing the function, line by line, it looks like the error message is generated from index 2 of the bilateralDipoleIdx array:

bilateralDipoleIdx = 2    44    47    71    78    80    81    86    88    89

firstDipolePosxyz  = EEG.dipfit.model(bilateralDipoleIdx(1)).posxyz(1,:);
firstDipoleMomxyz  = EEG.dipfit.model(bilateralDipoleIdx(2)).momxyz(1,:);
Index in position 1 exceeds array bounds.

I would love to hear if anyone encountered this and knows how to troubleshoot.
Thanks in advance,
Arkadiy
The information in this e-mail is intended only for the person to whom it is addressed.  If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at https://urldefense.com/v3/__https://www.massgeneralbrigham.org/complianceline__;!!Mih3wA!DnjxyyLXEUm3G7lW5fcKMLcIdnIjIoqfLzK-USqJtZXPKRU7SNnMR5bQX1F8vzHfkmpmu03EiueO_4kMS_5kabWqn_zqciKvuRiVHhI$   <https://urldefense.com/v3/__https://www.massgeneralbrigham.org/complianceline__;!!Mih3wA!DnjxyyLXEUm3G7lW5fcKMLcIdnIjIoqfLzK-USqJtZXPKRU7SNnMR5bQX1F8vzHfkmpmu03EiueO_4kMS_5kabWqn_zqciKvuRiVHhI$  > .
Please note that this e-mail is not secure (encrypted).  If you do not wish to continue communication over unencrypted e-mail, please notify the sender of this message immediately.  Continuing to send or respond to e-mail after receiving this message means you understand and accept this risk and wish to continue to communicate over unencrypted e-mail. 



More information about the eeglablist mailing list