...
|
...
|
@@ -80,7 +80,7 @@ catch |
|
|
case '.csv'
|
|
|
[Name, Position] = readCsv(filename);
|
|
|
if all(isnan(Position))
|
|
|
error('Anatomy not found: possibly patient implanted before 2009. Check implantation scheme!');
|
|
|
warning('T1pre coordinates not found: possibly patient implanted before 2009.');
|
|
|
end
|
|
|
otherwise
|
|
|
disp('ImaGIN> ERROR: Invalid input file type.');
|
...
|
...
|
@@ -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)
|
...
|
...
|
@@ -133,10 +133,9 @@ for i0 = 1:size(t,1) |
|
|
% Loop on all channels available in the file
|
|
|
for i1 = 1:length(Sensors.label)
|
|
|
sensLtmp = Sensors.label{i1};
|
|
|
sensLtmp(ismember(double(sensLtmp),[',' ';' '-'])) ='';
|
|
|
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)));
|
...
|
...
|
@@ -163,9 +162,11 @@ for i0 = 1:size(t,1) |
|
|
% Copy channel name from input name file (ADDED BY FT 5-Oct-2018)
|
|
|
chMatchLog{end+1,1} = Sensors.label{i1};
|
|
|
chMatchLog{end,2} = Name{iChanPos};
|
|
|
Sensors.label{i1} = strrep(Name{iChanPos},'-','');
|
|
|
Sensors.label{i1} = Name{iChanPos};
|
|
|
else
|
|
|
disp(['ImaGIN> WARNING: ' Sensors.label{i1} ' not assigned']);
|
|
|
disp(['ImaGIN> WARNING: ' Sensors.label{i1} ' not assigned']);
|
|
|
Sensors.elecpos(i1,:) = NaN;
|
|
|
Sensors.chanpos(i1,:) = NaN;
|
|
|
chNotFound{end+1} = Sensors.label{i1};
|
|
|
end
|
|
|
end
|
...
|
...
|
@@ -205,18 +206,16 @@ for i0 = 1:size(t,1) |
|
|
end
|
|
|
|
|
|
% Match file: Correspondance between SEEG-CSV-LENA conventions
|
|
|
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.')
|
|
|
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
|
|
|
end
|
|
|
|
...
|
...
|
@@ -226,7 +225,7 @@ for i0 = 1:size(t,1) |
|
|
% Replace labels in D.channels
|
|
|
for iChan = 1:length(SpmMat.D.channels)
|
|
|
spmLtmp = SpmMat.D.channels(iChan).label;
|
|
|
spmLtmp(ismember(double(spmLtmp),[',' ';' '-'])) ='';
|
|
|
spmLtmp(ismember(double(spmLtmp),[',' ';' '-' '_'])) ='';
|
|
|
SpmMat.D.channels(iChan).label = spmLtmp;
|
|
|
|
|
|
iChanMatch = find(strcmpi(SpmMat.D.channels(iChan).label, chMatchLog(:,1)));
|
...
|
...
|
@@ -311,20 +310,15 @@ for i0 = 1:size(t,1) |
|
|
if (length(iChanMatch1) == 1) && (length(iChanMatch2) == 1)
|
|
|
SpmMat.D.trials.events(iEvt).type = noteNameNew;
|
|
|
end
|
|
|
end
|
|
|
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
|
|
|
if ~(exist('csv_all_electrodes','var') == 1)
|
|
|
error('Could not match notes with channels found in the implantation file.')
|
|
|
end
|
|
|
csv_struct.csv_labels = csv_all_electrodes(:,1);
|
|
|
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
|
...
|
...
|
@@ -403,8 +397,6 @@ function iChanPos = findChannel(Label, List, caseType) |
|
|
|
|
|
% Remove spaces
|
|
|
Label(Label == ' ') = [];
|
|
|
% Remove spaces
|
|
|
List = strrep(List,'-','');
|
|
|
% Switch case type
|
|
|
switch (caseType)
|
|
|
case 'no_change'
|
...
|
...
|
|