Compute Sources (2018) New error

Hello guys, me again.

So now that I solved my Events issue, I’m facing a Compute Sources issue.

I don’t think I changed anything significant with my dataset, but the function to compute sources has changed since I have last used it. Now, it returns me an error, preventing Matlab to compute the whole thing. Here’s the full error:

Error using process_inverse_2018>Compute (line 644)
Requested 150002x150002 (167.6GB) array exceeds maximum array size preference. Creation of arrays greater than
this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel
for more information.

Note: Matlab 2018a changed the behavior of the SVD() function.
If issues arise, we recommend using another version.

Error in process_inverse_2018 (line 24)
eval(macro_method);

Error in panel_protocols>TreeInverse (line 1224)
[OutputFiles, errMessage] = process_inverse_2018(‘Compute’, iStudies, iDatas);

Error in panel_protocols (line 44)
eval(macro_method);

Error in tree_callbacks>@(h,ev)panel_protocols(‘TreeInverse’,bstNodes,‘2018’) (line 2308)
gui_component(‘MenuItem’, jPopup, [], ‘Compute sources [2018]’, IconLoader.ICON_RESULTS, [],
@(h,ev)panel_protocols(‘TreeInverse’, bstNodes, ‘2018’));

I’m once again very grateful for your help. I think the solution for this one is what changed between the old Compute Sources and the new Compute Sources (2018). Once again, the issue probably comes from me!

@John_Mosher @Sylvain Is it expected that process_inverse_2018 creates a NdipolesxNdipoles matrix?
I’m not sure it was the case before…

I have looked inside the function and I don’t see where such an nsources x nscources array could be created.
@JonathanC: can you track this down by putting a breakpoint at the top of process_inverse_2018.m and executing the function step by step, please?

Hello everyone,

Thank you for your sustained helped. The error message does mention that it doesn’t work well in Matlab 2018a, so I will be trying to install an older version today.

@Sylvain , The error comes from a “try” of the bst_inverse_linear_2018 function (Line 638). I investigated and it seems to be line 1020 of this function that causes the issue:

Kernel(Ndx,: ) = diag(Alpha{kk})*Kernel(Ndx,: );

@MartinC My 16 other participants were analyzed using the 150 000 surface.

I will be installing an older Matlab to see if it fixes the issue. Sorry for not noticing that part of the error earlier.

Once again, thank you everyone for your help,

P.-S. : There isn’t an emoji in the code. It represents a colon : and a closed parenthesis ) .

1 Like

Please replace line 1020 by the following:
Kernel(Ndx,: ) = spdiags(Alpha{kk}’,0,length(Ndx),length(Ndx))*Kernel(Ndx,:);

The sparse matrix implementation should help (also speeds up execution with such large arrays!).

Let me know how this works out for you: may still be challenging because of the large amount of sources requested though.

Hello again,

Changing the line worked perfectly.

Not so much using Matlab 2017B. If any one finds this post in the future, Sylvain’s line is the solution!

Thank you everyone for your help,

Good!
What do you mean by “not so much with Matlab2017B” ?

The error said:

Note: Matlab 2018a changed the behavior of the SVD() function.
If issues arise, we recommend using another version.

Reverting to 2017B doesn't solve the problem.

I understand from your post that the memory issue is resolved, but you are still getting this SVD warning concerning Matlab18a even though you are using Matlab17b. Is my interpretation correct?

While you guys were helping me with a solution, I downgrade to 2017b to see if it would solve the problem. It did not.

Once I had your answer to change the line, I went back to 2018a, applied your fix and it was working perfectly. Now, I don’t have any issues left. I just wanted to add more info in case someone looks up the forum with a similar issue.

OK thanks - all is well now then.

Discussion about the technical implementation moved to github: