-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddSEEGlabels.m
51 lines (45 loc) · 1.75 KB
/
addSEEGlabels.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function addSEEGlabels
% function addSEEGlabels
% Add brain segmentation labels to each sEEG contact and save in the 2nd
% column of the channel_labels variable. Uses labels found in ITKSnap CSV
% file.
%
% DR 12/2022
% parameters
ddir = '/Users/drew/Box/sEEG'; % data directory
subj = 'HUP247_RID921'; % subject
% load locations
cd(ddir);
locCSV = fullfile(subj,[subj '_ITKSNAP'],'electrodenames_coordinates_native_and_T1.csv'); % CSV file path and name
try
locations = readtable(locCSV);
catch
error([locCSV ' not found']);
end
% match formatting with what is in channel_labels
locelec = locations.Var1;
for ii = 1:length(locelec)
blett = isstrprop(locelec{ii},'alpha');
bnumb = isstrprop(locelec{ii},'digit');
if sum(blett)>1 && sum(bnumb)==1 && ~strncmp(locelec{ii},'EMG',3) && ~strncmp(locelec{ii},'Fp',2)
locelec{ii} = [locelec{ii}(blett) '0' locelec{ii}(bnumb)];
end
end
% load channel labels
load(fullfile(subj,[subj '_Induction.mat']),'channel_labels'); % the CSV reconstructions are useful only for induction sessions (after EMU stay)
% add location to each channel label
for ii = 1:length(channel_labels)
elec = channel_labels{ii,1};
ind = find(strncmpi(locelec,elec,length(elec)));
if ~isempty(ind)
channel_labels{ii,2} = locations.Var2{ind};
elseif any(ismember(elec,{'C3','C4','Cz','CZ','Fp1','Fp2','F3','F4','F7','F8','Fz','FZ','P3','P4','Pz','PZ','O1','O2','T3','T4','T5','T6'}))
channel_labels{ii,2} = 'EEG';
elseif any(ismember(elec,{'LOC','ROC'}))
channel_labels{ii,2} = 'EOG';
else
channel_labels{ii,2} = '';
end
end
% append to session .mat file
save(fullfile(subj,[subj '_Induction.mat']),'channel_labels','-append'); % overwrites if had run this function previously