Finding Atlas regions for top X% of sources

The most direct way to move from GUI to scripting is by generating automatically the code for a pipeline created in the GUI. See the tutorial script:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

Overall, these are the steps your script should perform:

  1. Extract the sources at the given time stamp (625.3440 s in the shared image).
    Process Extract > Extract values
    :bulb: This step is done to avoid loading the sources in the entire time window (57 s in the shared image), as the amount of required RAM will be in the range of some GB.

  2. Load the sources (results) the file obtained in Step1, find the indices for the top 20% vertices, and find the respective HeadModelFile.
    Function in_bst_results()
    The data in the loaded source file is organized according to: https://neuroimage.usc.edu/brainstorm/Tutorials/SourceEstimation#On_the_hard_drive

  3. Using the indices and head model from Step 2, fin the locations of the vertices. Locations are given in in SCS coordinates, the need to be converted from SCS coordinates to voxels coordinates
    https://neuroimage.usc.edu/brainstorm/CoordinateSystems
    Function cs_convert()

  4. Finally load the desired atlas (AAL3 in the shared image), and find value (variable Cube) and the label for that value (variable Labels) for the each of the voxel coordinates.
    Function in_mri_bst
    The data in the atlas (anatomical parcellation) is organized according to: https://neuroimage.usc.edu/brainstorm/Tutorials/ExploreAnatomy#On_the_hard_drive:_MRI