Script for copy selected scouts and merge scouts

Dear Expert,

I'm trying to use batch to copy some scouts from the Desikan-Killiany gyral atlas and then merge them.

I've done this using the GUI. I copied and merged the bilateral Cuneus or rostral of ACC.

Now I'd like to implement it using scripts since the process needs to be done for each subject:

% Source File
SourceFile = ['link|Subject01/Condition/*dSPM*.mat|', 'Subject01/condition/data*trial*.mat'];
% Plot figure for volume scouts
hFig = view_mri([], SourceFile);
% Get scouts
[sScouts, sSurf, iSurf] = panel_scout('GetScouts');

Then I got 104 scouts in the sScouts (seems all scouts in the Desikan-Killiany). Am I going the right path? What should I do next to select, copy, and merge the scouts I want?

Thank you in advance!

Best wishes,
Shuting

Yes, this is way.
One thing you may want to add is to explicitly select the Atlas, to ensure that the same Atlas is used for all the subjects. After getting the Scouts:

% Set current atlas
atlasName = 'THE_ATLAS_NAME';
iAtlas = find(strcmpi(atlasName, {sSurf.Atlas.Name}));
panel_scout('SetCurrentAtlas', iAtlas, 1);

To Copy selected scouts to a new atlas. This sets the new atlas as current atlas

% Get Scouts from current atlas
sScouts = panel_scout('GetScouts');
% Names of scouts to copy
selScoutNames = {'cuneus L', 'cuneus R', 'fusiform L'};
iSelScouts = find(ismember({sScouts.Label}, selScoutNames));
panel_scout('SetSelectedScouts', iSelScouts);
panel_scout('CreateAtlasSelected', 0, 0);

Now, to merge them:

% Get Scouts from current atlas (which is now the copied scouts)
sScouts = panel_scout('GetScouts');
mergeScoutNames = {'cuneus L', 'cuneus R'};
iSelScouts = find(ismember({sScouts.Label}, mergeScoutNames));
panel_scout('SetSelectedScouts', iSelScouts);
panel_scout('JoinScouts');

If you haven't, check the Scripting tutorial, this is full of information to write your own scripts.

In this specific case, to know which functions are called behind each GUI element, check this section of the Scripting tutorial:

Dear Raymundo,

Many thanks for your support! It really saves time!

Best wishes,
Shuting