Script for right click -> project sources

Hello Francois and other Brainstorm experts,

I'm currently automatizing some steps in my processing pipeline. Some of those steps include things outside the process box. For example, I'd like to automatize a projection of sources on a different surface. When doing it manually, I would right click the source file I want to project and navigate the contextual menus.

My question is where can I find the script that does this step so I could include it in my batch script?

Thank you again for your help,

In general, you can use the Matlab window "Find files" (Ctrl+Shift+F) with the option "Include subfolders", to search for the text of a button or a menu. This will take you to the corresponding callback function.

For example, if you search 'Project sources' (including the quotes), you will find the menu in tree_callbacks.m:

This will take you to the function bst_project_sources(ResultsFile, DestSurfFile). Then read the header of the function for help. Put a breakpoint in there if you're not sure to understand how it is called from the interface.

PS: There is a process "Project on default anatomy" which calls this function to project the source maps on the default surface of the default anatomy, but which won't let you chose which surface you want to use.