Command line history

Hello,

I have a perhaps basic question. I am currently working on a script to batch process my data, and while I have been succesful for the most part in generating .m files via the RUN command, I need to know a specific command to load a custom atlas to a surface. My question is, is there a way to visualize the command history so I can do it manually and copy it to my script?

Thanks in advance

is there a way to visualize the command history so I can do it manually and copy it to my script?

Unfortunately, not yet.
This is part of our roadmap for the developments of the next two years.

The Scripting tutorial include lots of information about writing scripts with Brainstorm:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

You can try searching for functions from the callbacks of the GUI elements:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Find_interface_callback_functions

The menus for loading atlases in the Scout tab are all defined in function panel_scout / CreatePanel.
If you can't find what you are looking for, please describe exactly what you are trying to do, including screen captures.

I see, thank you! Here's a screenshot of what I am trying to do:

and then:

Thank you very much for the help!

The function you need is import_label.m:

First of all, update Brainstorm, as I added the option to specify the file format from the command line (which was not possible for volumes before): Import labels from script: Specify FileFormat from command line · brainstorm-tools/brainstorm3@7c5cb88 · GitHub

To load a surface atlas, like you seem to be doing in this example:

SurfaceFile = 'sepi01/tess_cortex_pial_low.mat';
ScoutFile = 'brodmann.nii.gz';
isNewAtlas = 1;
[sAtlas, Messages] = import_label(SurfaceFile, ScoutFile, isNewAtlas, [], 'MRI-MASK');

However, it is not recommended to load a volume atlas on a surface. This leads to very poorly defined ROIs. Use volume a volume source model instead:
https://neuroimage.usc.edu/brainstorm/Tutorials/TutVolSource

And then to load the atlas:

SurfaceFile = 'sepi01/tess_cortex_pial_low.mat';
ScoutFile = 'brodmann.nii.gz';
isNewAtlas = 1;
ResultsFile = 'link|sepi01/SPIKE/results_Dipoles_EEG_KERNEL_220907_1900.mat|sepi01/SPIKE/data_SPIKE_average_220907_1855.mat';
ResultsMat = in_bst_results(ResultsFile, 0, 'GridLoc');
[sAtlas, Messages] = import_label(SurfaceFile, ScoutFile, isNewAtlas, [], 'MRI-MASK');

Not straightforward indeed... we'll work on improving this in the future.

Other question: you are loading a parcellation in subject space. Has this volume shen214 really been registered and resliced to match the subject T1 MRI?
Otherwise, if this is in MNI space, you should use 'Volume mask or atlas (dilated, MNI space)' / 'MRI-MASK-MNI'

Thank you very much! You are right indeed, the atlas was not matched to the T1 MRI but is rather in MNI space, that was a mistake on my part.

Thank you for the tip of not loading a volume atlas on a surface as well. I am currently trying to compute a volume instead, I will get back to you if I run into issues.

EDIT:

I get this error message when trying to load the atlas to the BEM volume

If it helps, this is why it gives the error message:

Why are there NaN values in the mask?

Have you edited the file import_label.m? The line numbers do not match the current version of the file.

There are multiple problems here.

First, you can't load a volume atlas from the display of the volume grid of the head model.
This is actually loading the parcellation as a surface atlas on the cortex surface. I realize this is very counter-intuitive and will fix it soon.
What you need to do is to compute sources on some recordings, then displaying the volume source maps in a 3D view, and with the 3D figure selected, use the load menu from the scout tab.

Another problem is the non-linear MNI registration loaded from CAT12. If you open the the T1 MRI in the MRI viewer and navigate around the edges of the volume, you would see that there are points that do not have MNI coordinates. The NaN values come from there.
All the brain locations should have MNI coordinates, please check that this is really the case.
If you find some missing MNI coordinates within the head volume, then something went wrong in the CAT12 computation.
If the all the head voxels seem to have MNI coordinates, then it means that the problem comes from the parcellation that you are trying to import. It might not be correctly defined in MNI coordinates.

To check this further, import this volume in the subject anatomy instead of loading it directly from the Scout tab. In the anatomy view, right-click on the subject > Import MRI > File format: Volume atlas (MNI space)

Here too, I have things to fix. I will try to find a way to always return MNI coordinates, even outside the head, possibly by using the linear MNI registration instead.
I will work on this soon, but it should not impact what you are trying to do now.
If your .nii volume is correctly registered to the MNI space, and CAT12 worked correctly on your subject's MRI, then MNI should be available for all the brain locations.

First of all, thank you for the help! Indeed, I had not properly registered the T1 MRI to MNI space, that has been fized now. I have also managed to import the the volume atlas as such following your steps. Is there a way to do this last step using Matlab commands?

Here too, I have things to fix. I will try to find a way to always return MNI coordinates, even outside the head, possibly by using the linear MNI registration instead.
I will work on this soon, but it should not impact what you are trying to do now.

This fix is now available: Bugfix: Capture errors with missing MNI definition in CAT12 normaliza… · brainstorm-tools/brainstorm3@36c16f4 · GitHub

Is there a way to do this last step using Matlab commands?

See my previous post: Command line history - #4 by Francois

2 posts were split to a new topic: Simulate sources from unconstrained scouts

A post was merged into an existing topic: Simulate sources from unconstrained scouts