SEEG electrode group names

Hello,
Thus far I have been using a simple ASCII txt file Name, xyz to import SEEG electrode coordinates, but then I have been entering group names manually in the channel file. Is there a way to import both the group and the contact names in the in the txt file to avoid any manual changes?
I think of an ASCII Name, Name, xyz type file table T, smth like
T.Group = OF, OF, OF, OF, .. ; T.Group can be a categorical or string array in matlab
T.Contact = OF1, OF2, OF3, etc or 1,2,3, depending of the inner working of brainstorm
T.x
T.y
Y.z
..
Such txt file can be easily created automatically in matlab.
Please let me know if such file design, or any other, would automate group labeline, thank you,
Octavian

The process "Add EEG positions" is not designed to set the type of the channels.
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/process/functions/process_channel_addloc.m
https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/sensors/channel_add_loc.m

Since you are already working in Matlab and planning to write a script to generate the file, you might as well directly edit or replace the existing channel.mat in the database.
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Custom_processing
https://neuroimage.usc.edu/brainstorm/Tutorials/ChannelFile#Edit_the_channel_file

Many thanks, Francois. I was able to automate SEEG grouping and also channel type in the channel.mat file, with something like

load('path\channel.mat', 'Channel');

% grouping
a = {Channel.Name};
b = cellfun(@(x) {regexp(x, '\d*', 'split')}, a, 'UniformOutput', false);
c = cellfun(@(x) x{1,:}{1,1}, b, 'UniformOutput', false);
[Channel.Group] = c{:};

% channel type
d = cellfun(@(x) ~any(strcmp(x,{'GND', 'E', 'Mark', 'Events'})), c); % Nihon Kohden non-SEEG channels
e = {Channel.Type};
e(d) = {'SEEG'};
[Channel.Type] = e{:};

save('path\channel.mat', 'Channel', '-append')

Grouping went ok, it is amazing what Brainstorm can do. However, after changing the channel type as above, and trying to visualize electrodes, I get an error; it is not due to the file modification per se, but to that the Modality parameter does not change when the file is modified as above, it still shows "EEG". That means Modality gets set upstream when the usual channel type setting gets applied in Brainstorm (right click, set channel type etc). Could you indicate which upstream (vis a vis channel.mat) files encode the Modality parameter change? Many thanks again, Octavian

Grouping went ok

What it is that you didn't like in the automatic grouping done by Brainstorm?
Could you give a few examples? Maybe this is something that could be improved for everybody (but not sure: given the large variety of naming conventions for SEEG electrodes, pleasing everybody is not possible...)

That means Modality gets set upstream when the usual channel type setting gets applied in Brainstorm (right click, set channel type etc). Could you indicate which upstream (vis a vis channel.mat) files encode the Modality parameter change?

The precise list of channels with their types is available only in the channel.mat file, and should not get modified by any other function after you edit it manually.

However, there are two other lists that manual changes can confuse:

  1. The list of modalities available for display: this is saved in the database: GlobalData.DataBase.ProtocolStudies(iProtocol).Study(iStudy).Channel.Modalities and .DisplayableSensorTypes
    This is fixed by forcing the reloading of the protocol (or just the folder). Right-click > Reload, or functions db_reload_*.m
  2. The field IntraElectrodes in the channel file, which is created automatically the first time the channel file is loaded/displayed, and that can be edited later with the tab "iEEG": https://neuroimage.usc.edu/brainstorm/Tutorials/Epileptogenicity#On_the_hard_drive
    When editing the channel file, you can safely delete this field, so that it is recreated automatically at the next load.

If this information doesn't help you, please post the full error message and its exact context, maybe it will help me understand better what your problem is.

I was able to automate SEEG contact grouping and their type 'SEEG' as below:

% import SEEG recordings, and electrode positions
% display sensors once in GUI (Channel file -> Display sensors -> EEG (MRI
% 3D)
% exit Brainstorm to update protocols, database

cd 'Path..\brainstorm_db\My_Protocol_name\data';
prompt1 = 'subject name: ';
str1 = input(prompt1,'s');
prompt2 = 'folder name: ';
str2 = input(prompt2,'s');
load(strcat(str1,'\',str2,'\channel.mat'), 'Channel');

%% Grouping
% a = arrayfun(@(x) {regexp(x.Name, '\d*', 'split')}, Channel, 'UniformOutput', false);
a = {Channel.Name};
b = cellfun(@(x) {regexp(x, '\d*', 'split')}, a, 'UniformOutput', false);
% change regexp pattern if needed; '\d*' works for lettered root- numeric indexes (AC1, AC2, 
AC3..)
c = cellfun(@(x) x{1,:}{1,1}, b, 'UniformOutput', false);
[Channel.Group] = c{:};

%% Type
d = cellfun(@(x) ~any(strcmp(x,{'GND', 'E', 'Mark', 'Events'})), c);
% 'GND', 'E', 'Mark', 'Events' .. channels not to be typed as 'SEEG'
e = {Channel.Type};
e(d) = {'SEEG'};
[Channel.Type] = e{:};

%% Save channel file
save(strcat(str1,'\',str2,'\channel.mat'), 'Channel', '-append');
clearvars -except Channel

%% Modify protocols
load('protocol.mat', 'ProtocolStudies')
keyboard

% modify ProtocolStudies/Study/studyNo/Channel/Modalities and DisplayableSensorTypes:
% from 'EEG' to 'SEEG'

% dbcont
save('protocol.mat', 'ProtocolStudies', '-append');
cd 'Path..\brainstorm3'

%% Restart Brainstorm

A post was split to a new topic: Unknown EEG sensor positions