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

[Tutorial] EEG and epilepsy - add cMEM estimate #721

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Edouard2laire
Copy link
Contributor

@Edouard2laire Edouard2laire commented Jul 11, 2024

Hello,

As we will be merging multifunkim/best-brainstorm#13 soon, this PR update the script corresponding to cMEM of the two following tutorials:

image

Should we fix the script to get a better head model?

@rcassani
Copy link
Member

When trying to run the pipeline, running:

sAvgSrcMEM = bst_process('CallProcess', 'process_inverse_mem', sFilesAvg, [], ...

gives the error:

Line 16: fminusub
Objective function is undefined at initial point. Fminunc cannot continue.
_______________________________________________
Call stack: 
>fminusub.m at 16 
>fminunc.m at 488 
>be_minimize_free_energy.m at 56 
>be_solve_mem.m at 56 
>be_launch_mem.m>MEM_mainLoop at 185 
>be_launch_mem.m at 79 
>be_cmem_solver.m at 182 
>be_main_call.m at 157 
>be_main.m at 60 
>process_inverse.m>Compute at 696 
>process_inverse.m at 24 
>process_inverse_mem.m>Run at 139 
>process_inverse_mem.m at 24 
>bst_process.m>Run at 236 
>bst_process.m>CallProcess at 2316
>bst_process.m at 38

How can i update the MEM figure from the tutorial ? i would like to change it to

Firs,t login in the in the Brainstorm website, button at upper right corner.
(If you do not have an account, please send me an email, so I can give you the necessary info details on creating one)

After login, on the tutorial page to edit, go to the top navigatin bar, then Menu > Attachments.
Then update the tutorial, use this use this syntax:

{{attachment:sim_ar_spectra_metrics.png||width="100%"}}
More info on working with images on Moinmoin here: http://moinmo.in/HelpOnImages

@Edouard2laire
Copy link
Contributor Author

Edouard2laire commented Jul 15, 2024

When trying to run the pipeline, running:

sAvgSrcMEM = bst_process('CallProcess', 'process_inverse_mem', sFilesAvg, [], ...

gives the error:

Line 16: fminusub
Objective function is undefined at initial point. Fminunc cannot continue.
_______________________________________________
Call stack: 
>fminusub.m at 16 
>fminunc.m at 488 
>be_minimize_free_energy.m at 56 
>be_solve_mem.m at 56 
>be_launch_mem.m>MEM_mainLoop at 185 
>be_launch_mem.m at 79 
>be_cmem_solver.m at 182 
>be_main_call.m at 157 
>be_main.m at 60 
>process_inverse.m>Compute at 696 
>process_inverse.m at 24 
>process_inverse_mem.m>Run at 139 
>process_inverse_mem.m at 24 
>bst_process.m>Run at 236 
>bst_process.m>CallProcess at 2316
>bst_process.m at 38

Did you download the new MEM version https://github.com/Edouard2laire/best-brainstorm/archive/refs/heads/wMEM.zip?

this error is due to the fact that the script is having an error with the forward model
image

So for some vertex, G is 0 for all the sensors and it cause issue with MEM. I made the new version of MEM more robust to that multifunkim/best-brainstorm@9fe8740 but I guess we should also fix the forward model from the script :)

How can i update the MEM figure from the tutorial ? i would like to change it to

Firs,t login in the in the Brainstorm website, button at upper right corner. (If you do not have an account, please send me an email, so I can give you the necessary info details on creating one)

After login, on the tutorial page to edit, go to the top navigatin bar, then Menu > Attachments. Then update the tutorial, use this use this syntax:

{{attachment:sim_ar_spectra_metrics.png||width="100%"}} More info on working with images on Moinmoin here: http://moinmo.in/HelpOnImages

Thx. :)

@Edouard2laire Edouard2laire marked this pull request as draft July 15, 2024 16:34
@Edouard2laire
Copy link
Contributor Author

also @rcassani, what do you think of the idea to move MEM just after sLoreta ? i think it make more sense to do all the Source analysis: Surface at the same time instead of sLoreta, then volume then back to surface with MEM

@rcassani
Copy link
Member

I tried with the master branch on https://github.com/Edouard2laire/best-brainstorm which is the one used in Brainstorm when installing and updating the brainentropy plugin

About the order, I think we can move MEM after sLORETA. With its own section with the [Advance] label.

@Edouard2laire
Copy link
Contributor Author

Edouard2laire commented Jul 15, 2024

About the order, I think we can move MEM after sLORETA. With its own section with the [Advance] label.

ok. if I may, the tutorial editor is probably the worst editor i had to use to write text so far. Like, i think it can really remove the will to live to even the most joyous person...

Page took 20 minutes to save and is now full of conflict without even the slightest possibility to go back in time, that pasting doesn't work (what text editor doesn't support ctrl+c, ctrl+v???), or that the editor chooses randomly to put half of the page in bold without possibility to remove it if you select the link at the same time as text... or the attachment system!

image

@rcassani
Copy link
Member

Indeed, writing in MoinMoin is a real pain, apologies for all the suffering.
Few pointers:

  • Admin users can revert pages (let me know if you need to do so)
  • The slowness things is not on MoinMoin side, but today's issue with the server
  • It helps to edit the text without their fancy editor, but using the "Show Raw Text" editor

@Edouard2laire
Copy link
Contributor Author

Hi @rcassani

it seems that the change in the BEM surface fcce1d7 to fix the warning about dipole outside the skull is making quite a difference in the inverse problem solution; including for sLoreta:

Screenshot 2024-07-15 at 21 01 26

Do you know if that is correct ?

@Edouard2laire
Copy link
Contributor Author

Indeed, writing in MoinMoin is a real pain, apologies for all the suffering. Few pointers:

  • Admin users can revert pages (let me know if you need to do so)
  • The slowness things is not on MoinMoin side, but today's issue with the server
  • It helps to edit the text without their fancy editor, but using the "Show Raw Text" editor

Indeed, the raw text editor is much better ! :)

This reverts commit fcce1d7.
@Edouard2laire Edouard2laire marked this pull request as ready for review September 5, 2024 18:39
@Edouard2laire
Copy link
Contributor Author

multifunkim/best-brainstorm#13 is now merged. The PR is now ready to be reviewed :)

Copy link
Member

@rcassani rcassani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Edouard2laire, to avoid duplication of code, and potential problems in maintenance.
I think for the tutorial_BEst.m we can use the same approach as in the brain fingerprint tutorial script, where it starts with an already processed Protocol.

So tutorial_BEst.m will look for the the 'TutorialIntroduction' and do the steps starting with L411:

%% ===== TUTORIAL #20: HEAD MODEL ====================================================
%  ===================================================================================

'baseline', [], ...
'sensortypes', 'MEG', ...
'target', 1, ... % Noise covariance (covariance over baseline time window)
'dcoffset', 0, ... % Block by block, to avoid effects of slow shifts in data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As identity is required, the dcoffset is ignored. However, dcoffset is a radio option, it's value must be >=1.

Set it to 1 so it matches the comment of the same line

% ===================================================================================
disp([10 'DEMO> Tutorial #22: Source estimation' 10]);

% coherent Maximu Entropy on the Mean (cMEM)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

'Comment', 'Average Devient (cMEM)');


% wawelet Maximum Entropy on the Mean (wMEM)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

'threshold', 0, ...
'Comment', 'Average Devient (wMEM - scale 5 )');

% 3. Localizing all scale:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

'time', 83.3*1e-3, ...
'threshold', 0, ...
'Comment', 'Average Devient (wMEM - all scale)');
%% ===== SAVE REPORT =====
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line is needed

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

Successfully merging this pull request may close these issues.

2 participants