Authored by Olivier David

Improve Bipolar Montage input

... ... @@ -30,20 +30,25 @@ catch
end
try
SaveChannels = S.Save;
Bipole=S.Bipole;
catch
SaveChannels = 0;
Bipole = [];
end
try
bipole = load(S.Bipole);
SaveChannels = S.Save;
catch
bipole = [];
SaveChannels = 0;
end
for i0=1:size(Filename,1)
try
bipole = load(Bipole);
catch
bipole = Bipole;
end
T=deblank(Filename(i0,:));
D=spm_eeg_load(T);
... ...
... ... @@ -109,9 +109,9 @@ end
% Set positions
chNotFound = {};
chMatchLog = {};
for i0 = 1:size(t,1)
chNotFound = {};
chMatchLog = {};
T = deblank(t(i0,:));
% Clone file if requested in input
if (nargin >= 1) && isfield(S, 'FileOut') && ~isempty(S.FileOut)
... ... @@ -136,6 +136,7 @@ for i0 = 1:size(t,1)
sensLtmp(ismember(double(sensLtmp),[',' ';' '-'])) ='';
Sensors.label{i1} = sensLtmp;
iChanPos = findChannel(Sensors.label{i1}, Name, 'all_upper');
iChanPos = findChannel(upper(Sensors.label{i1}), upper(Name), 'all_upper');
% If the channel was already found in the list before: check the best option based on the case
if ~isempty(iChanPos) && ~isempty(chMatchLog)
iPrevious = find(strcmp(Name{iChanPos}, chMatchLog(:,2)));
... ... @@ -204,16 +205,18 @@ for i0 = 1:size(t,1)
end
% Match file: Correspondance between SEEG-CSV-LENA conventions
if isfield(S, 'FileTxtOut') && ~isempty(S.FileTxtOut)
try
fid = fopen(S.FileTxtOut,'w');
fprintf(fid,'SEEG,CSV\n');
for i = 1:size(chMatchLog,1)
fprintf(fid,'%s,%s\n', chMatchLog{i,1}, chMatchLog{i,2});
try
if isfield(S, 'FileTxtOut') && ~isempty(S.FileTxtOut)
try
fid = fopen(S.FileTxtOut,'w');
fprintf(fid,'SEEG,CSV\n');
for i = 1:size(chMatchLog,1)
fprintf(fid,'%s,%s\n', chMatchLog{i,1}, chMatchLog{i,2});
end
fclose(fid);
catch
disp('Log with matched channels names SEEG-CSV not saved.')
end
fclose(fid);
catch
disp('Log with matched channels names SEEG-CSV not saved.')
end
end
... ... @@ -309,11 +312,19 @@ for i0 = 1:size(t,1)
SpmMat.D.trials.events(iEvt).type = noteNameNew;
end
end
csv_struct.csv_labels = csv_all_electrodes(:,1);
try
csv_struct.csv_labels = csv_all_electrodes(:,1);
catch
elec_labels = Name';
elec_labels_no_primes = strrep(elec_labels,'p','''');
csv_all_electrodes = [elec_labels elec_labels_no_primes];
csv_struct.csv_labels = csv_all_electrodes(:,1);
end
SpmMat.D.other = csv_struct; % Add an extra field to the .mat so we have a listing of all channel labels in the csv.
% Update existing .mat file
save(SpmFile, '-struct', 'SpmMat');
save(spm_eeg_load(SpmFile)); % SPM's save to create a valid SPM object
clear csv_all_electrode csv_struct
end
end
... ...