SEEG contact locations

Is there a way to navigate to individual SEEG contact locations (not manually) once you have plotted them all in the iEEG tab? I have 14 electrodes with a total of 186 contacts. If you click the electrode it brings you to #1 contact. Is there a way to navigate directly to #2, #3, #4, etc? I would like to display in the crosshairs each individual contact and then create a screenshot for each one. This is a similar workflow I have used with CURRY to provide the neurologists screenshots of each contact location. Thanks in advance for any help.

You can reproduce what is done in function panel_ieeg.m>CenterMriOnElectrode:

In an automated script, it could look like this:

MriFile = 'Subject01/subjectimage_post.mat';
ChannelFile = 'Subject01/@rawSZ1/channel.mat';

% Get index of MRI file in the anatomy folder
[sSubject, iSubject, iAnat] = bst_get('MriFile', MriFile);
% Open MRI viewer
hFig = panel_ieeg('DisplayChannelsMri', ChannelFile, 'SEEG', iAnat);

% Load channel file and MRI
ChannelMat = in_bst_channel(ChannelFile);
sMri = in_mri_bst(MriFile);

% Loop on electrodes
for iElec = 1:length(ChannelMat.IntraElectrodes)
    sElec = ChannelMat.IntraElectrodes(iElec);
    % Get contacts for this electrode, sorted by index
    iChan = find(strcmpi({ChannelMat.Channel.Group}, sElec.Name));
    [~,I] = sort_nat({ChannelMat.Channel(iChan).Name});
    iChan = iChan(I);
    % Loop on contacts
    for i = 1:length(iChan)
        % Set location in the MRI viewer
        figure_mri('SetLocation', 'scs', hFig, [], ChannelMat.Channel(iChan(i)).Loc);
        % Screen capture
        out_figure_image(hFig, 'image.png')
    end
end

% Close figure
close(hFig);

Thank you! This is exactly what I want to do. However, I'm getting an error (it could be me). I'm using the latest version of Brainstorm with Matlab 2022a, Mac OS 10.15.7 (Intel). I'm using your above script and named it to screenshot.m. I did of course update the paths to the Mri and channel file.

Dot indexing is not supported for variables of this type.

Error in panel_ieeg>DisplayChannelsMri (line 2625)
sSubject = bst_get('Subject', sStudy.BrainStormSubject);

Error in panel_ieeg (line 30)
eval(macro_method);

Error in screenshot (line 7)
hFig = panel_ieeg('DisplayChannelsMri', ChannelFile, 'SEEG', iAnat);

Ok I fixed the 'Dot indexing is not supported for variables of this type' error, apparently the paths for the data is case sensitive. Now the script runs and I get this error:

Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.

Error in panel_ieeg>DisplayChannelsMri (line 2630)
MriFile = sSubject.Anatomy(iAnatomy).FileName;

Error in panel_ieeg (line 30)
eval(macro_method);

Error in screenshot (line 7)
hFig = panel_ieeg('DisplayChannelsMri', ChannelFile, 'SEEG', iAnat);

apparently the paths for the data is case sensitive.

Yes, on MacOS/Linux the file names and paths are always case sensitive.

Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

I guess the previous line, trying to get the index of the MRI in the database, is not working.
You need to adjust this code to your database structure, e.g. depending on whether you are using anatomy templates... If you are using the first MRI file in the subject folder, you can use iAnat=1.
Check the index of a file by hovering the mouse over the files in the database explorer.

Before trying to write Brainstorm scripts, I recommend you start by reading this page:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

Hi Francois-

How can I using code replicate 'Display contacts as spheres' in the iEEG panel and then in the MRI viewer replicate toggling off 'Display labels' ?

I want to run these two commands before I start the screenshots. Thanks in advance!

Brian

How can I using code replicate 'Display contacts as spheres' in the iEEG panel

panel_ieeg('SetDisplayMode', 'sphere');

and then in the MRI viewer replicate toggling off 'Display labels' ?

figure_3d('ViewSensors', hFig, [], 1);

See this procedure for finding callback functions:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Find_interface_callback_functions