Finding Atlas regions for top X% of sources

I am having trouble using bst_freq i dont know which file to upload
I am using the below line
Here block010.mat file corresponds to time series data 586 sec to 646 sec.

Hi @Geeta,

Can you provide more information on what kind of troubles you are having?

If a filename is provided to bst_timefreq it must be either the fullpath (absolute path) or shortpath (relative path with respect to the Protocol\data)

Can you describe which TF decomposition are trying to do?
In most of the cases this operation can be carried out calling a process, rather than a direct call to bst_timefreq


Hi @Raymundo.Cassani thanks for your response.
Sorry for not giving more required details.
I have been doing analysis of time frequency raw data with the help of gui but i want to switch over to scripting for automation of processes.
Below i have attached an image. I am using Mri view for raw data at given time stamp using gui.
then finding the maximum on mri and seeing the region for amplitude >80% .
So i have a list of time stamps(which are top 10 where frequency power is highest using morlet tf) and i want that i dont have to check for every time stamp
I input the time stamp array and get array of regions respectively
Hope you understand.
I will be waiting for the response

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:

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:

  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
    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:

Thanks for your response @Raymundo.Cassani in step 1 you have said to extract values for a given time stamp but when i extract values for my sloreta:meg all Unconstr the values are same there is no change.
i extracted two files by changing the time stamps they were exactly same.
Kindly elaborate step1 more.

The coordinates here i have are not of SCS according to mri

Let's say that we want to extract the source values at the time point (e.g. 625.3442), we will set that as the Time window in the Extract values process. The resulting source map will have only the values at that time point, thus it's file size is significantly smaller, and easier to handle in the subsequent steps.

I want to do the above operation using scripting.

That is described in the scripting tutorial, in its first section: Starting a new script.
Give it a try, and let us know if you encounter any issue

The location (coordinates) for the vertices are always saved as SCS.
The are found in the sHeadModel.GridLoc

The coordinate conversion is failing as the fist argument in the cs_convert() must be the sMRI structure, not the head model. It can be retrieved as:

sSubject = bst_get('SurfaceFile', sHeadModel.SurfaceFile);
sMri = in_mri_bst(sSubject.Anatomy(sSubject.iAnatomy).FileName);

Thanks for your response i can get the coordinates now . Last step is how to get correct label for that coordinate?

This is the Step 4 in one of my previous posts:

% Example parameters
AnatAtlasName = 'aal3';
VoxelCoords = [84, 167, 200];

% Find anatomy atlas
iAnatAtlas = find(strcmp(AnatAtlasName, {sSubject.Anatomy.Comment}));
% Load anatomy atlas
sAnatAtlas = in_mri_bst(sSubject.Anatomy(iAtlas).FileName);
% Get voxel integer label
VoxelValueAnatAtlas = sAnatAtlas.Cube(VoxelCoords(1), VoxelCoords(2), VoxelCoords(3));
% Get voxel text label
iLabel = find(VoxelValueAnatAtlas == [sAnatAtlas.Labels{:,1}]); % First  column of Labels
VoxelLabel = sAnatAtlas.Labels{iLabel,2}                        % Second column of Labels

I strongly suggest you to read the Scripting tutorial to be able to automate your processing pipeline and other tasks:

Thanks for your help i did the same thing but i am getting zero from Cube(x,y,z) most of the time.
Also my voxel coordinate are coming in decimal. so i am putting the rounded off value

Most of the Cube space has value 0, because it is not brain tissue or it is not labelled in the Atlas.
Make a test by opening the atlas, selecting the a voxel, get it's value, label and MRI coordinates, and try to retrieve the same information with the code. For example in this image, the voxel is (120, 116, 151), value 2, label Right Precentral gyrus.

That's correct