Authored by Anthony Boyer

Processing <2009 CRFs; Coordinates no longer mandatory; fix for HUH.

... ... @@ -246,7 +246,6 @@ if ~exist(figDir, 'dir')
end
% close all;
Size = 8; % Number of channels per screenshot
n_c = size(D,1);
if n_c >= Size
... ... @@ -254,15 +253,17 @@ if n_c >= Size
for i2 = 1:tmp
figure(i2);
set(gcf,'Position',[629 -17 702 1101])
for i3 = 1:Size
if intersect(i3+(i2-1)*Size,interIdx) == i3+(i2-1)*Size
color = 'm'; % Channel doesn't have position and is bad
elseif intersect(i3+(i2-1)*Size,NaNbIdx) == i3+(i2-1)*Size
color = 'r'; %Bad channels will be printed in red
for i3 = 1:Size
if ~ismember(chanlabels(D,i3+(i2-1)*Size),D.csv_labels)
color = 'g'; % Channel was not matched with the .csv
elseif intersect(i3+(i2-1)*Size,ixNaN) == i3+(i2-1)*Size
color = 'b'; %NaN channels will be printed in blue
color = 'b'; % Channel was matched, is good, has NaN coordinates
elseif intersect(i3+(i2-1)*Size,interIdx) == i3+(i2-1)*Size
color = 'm'; % Channel was matched, is bad, has NaN coordinates
elseif intersect(i3+(i2-1)*Size,NaNbIdx) == i3+(i2-1)*Size
color = 'r'; % Channel was matched, is bad, has coordinates
else
color = 'k'; %Good channels will be printed in black
color = 'k'; % Channel was matched, is good, has coordinates
end
subplot(Size,1,i3)
plot(time(D),D(i3+(i2-1)*Size,:),color);
... ... @@ -284,15 +285,17 @@ if n_c >= Size
if rmd ~= 0
figure(tmp + 1)
set(gcf,'Position',[629 -17 702 1101])
for i4 = 1:rmd
if intersect(i3+(i2-1)*Size+i4,interIdx)== i3+(i2-1)*Size+i4
color = 'm';
elseif intersect(i3+(i2-1)*Size+i4,NaNbIdx)== i3+(i2-1)*Size+i4
color = 'r';
for i4 = 1:rmd
if ~ismember(chanlabels(D,i3+(i2-1)*Size+i4),D.csv_labels)
color = 'g'; % Channel was not matched with the .csv
elseif intersect(i3+(i2-1)*Size+i4,ixNaN) == i3+(i2-1)*Size+i4
color = 'b';
color = 'b'; % Channel was matched, is good, has NaN coordinates
elseif intersect(i3+(i2-1)*Size+i4,interIdx) == i3+(i2-1)*Size+i4
color = 'm'; % Channel was matched, is bad, has NaN coordinates
elseif intersect(i3+(i2-1)*Size+i4,NaNbIdx) == i3+(i2-1)*Size+i4
color = 'r'; % Channel was matched, is bad, has coordinates
else
color = 'k';
color = 'k'; % Channel was matched, is good, has coordinates
end
subplot(rmd,1,i4)
plot(time(D),D(i3+(i2-1)*Size+i4,:),color);
... ... @@ -312,15 +315,17 @@ else
figure(1)
set(gcf,'Position',[629 -17 702 1101])
for i5 = 1:n_c
if intersect(i5,interIdx)== i5
color = 'm';
elseif intersect(i5,NaNbIdx)== i5
color = 'r';
elseif intersect(i5,ixNaN)== i5
color = 'b';
if ~ismember(chanlabels(D,i5),D.csv_labels)
color = 'g'; % Channel was not matched with the .csv
elseif intersect(i5,ixNaN) == i5
color = 'b'; % Channel was matched, is good, has NaN coordinates
elseif intersect(i5,interIdx) == i5
color = 'm'; % Channel was matched, is bad, has NaN coordinates
elseif intersect(i5,NaNbIdx) == i5
color = 'r'; % Channel was matched, is bad, has coordinates
else
color = 'k';
end
color = 'k'; % Channel was matched, is good, has coordinates
end
subplot(n_c,1,i5)
plot(time(D),D(i5,:),color);
ylabel([num2str(i5) ' : ' D.chanlabels{i5}])
... ...
... ... @@ -38,7 +38,7 @@ elec= sensors(D,'eeg'); % add channels without positions into bad channels
pos = elec.elecpos;
Sens = elec.label;
chanLbs = D.chanlabels;
idxNaN = find(isnan(pos(:,1)));
idxNaN = [] % find(isnan(pos(:,1))); We now assume channels without coordinates are not bad (CRFs older than 2009 do not have T1pre coordinates)
if ~isempty(idxNaN)
bIdx = [bIdx(:);idxNaN(:)];
bIdx = sort(unique(bIdx));
... ...
... ... @@ -51,7 +51,7 @@ for i0=1:size(Filename,1)
Name=Sensors.label;
Position=Sensors.elecpos;
BadChannelsMono=badchannels(D);
idxNaN = find(isnan(Position(:,1)));
idxNaN = [] % find(isnan(Position(:,1))); We now assume channels without coordinates are not bad (CRFs older than 2009 do not have T1pre coordinates)
if ~isempty(idxNaN)
BadChannelsMono = [BadChannelsMono(:);idxNaN(:)];
end
... ... @@ -75,7 +75,7 @@ for i0=1:size(Filename,1)
end
label_name_2 = matched_2.label;
label_number_2 = matched_2.index;
if strcmp(label_name_1,label_name_2) & str2num(label_number_1)+1 == str2num(label_number_2) & ~(sum(isnan(Position(i1,:))) > 0) & ~(sum(isnan(Position(i2,:))) > 0)
if strcmp(label_name_1,label_name_2) & str2num(label_number_1)+1 == str2num(label_number_2)
matched_channels = matched_channels+1;
Cpos2full(:,end+1)= mean(Position([i1 i2],:))';
Cnamesfull{1,end+1}=[Name{i1} '-' Name{i2}];
... ...
... ... @@ -48,12 +48,14 @@ if KeepEvent == 1 % Navigate all stim events
noteName(~ismember(double(noteName),['A':'Z' 'a':'z' '_' '.' '''' 'µ' '-' '0':'9'])) ='_';
noteName = regexprep(noteName,'_+','_'); noteName = regexprep(noteName,'µ','u');
noteName = strrep(noteName,'usec','us');
noteName = strrep(noteName,'sec','us'); % HUH notes
noteName = regexprep(noteName,'MA','mA'); %OD
noteName = regexprep(noteName,'Stim_Start_',''); %YUQ notes
noteName = regexprep(noteName,'Stim_Stop_',''); %YUQ notes
noteName = strrep(noteName,'-','_'); noteName = strrep(noteName,'__','_');
noteName = strrep(noteName,',','');noteName = strrep(noteName,'_mA_','_');
noteName = strrep(noteName,'sec','us'); noteName = strrep(noteName,'_us','us');
noteName = strrep(noteName,'sec','us');
noteName = strrep(noteName,'_us','us');
noteName = strrep(noteName,'AA','A'); noteName = strrep(noteName,'_MA_','_'); %some MIL notes
keepN = ''; noteName = strrep(noteName,'stim',''); noteName = strrep(noteName,'Stim','');
noteName = strrep(noteName,'TextNote:',''); % for BRN datasets
... ... @@ -93,7 +95,7 @@ if KeepEvent == 1 % Navigate all stim events
elseif numel(numbr{2}) == 3
if str2double(numbr{2}(1:2)) == str2double(numbr(1)) + 1 || str2double(numbr{2}(1:2)) + 1 == str2double(numbr(1))
elecno = strcat(numbr{2}(1:2),'_',numbr{2}(3));
noteName = strrep(noteName,numbr{2},elecno);
noteName = regexprep(noteName,numbr{2},elecno,'once'); % We should replace the first match only
elseif str2double(numbr{2}(1)) == str2double(numbr(1)) + 1 || str2double(numbr{2}(1)) + 1 == str2double(numbr(1))
elecno = strcat(numbr{2}(1),'_',numbr{2}(2:3));
noteName = strrep(noteName,numbr{2},elecno);
... ...
... ... @@ -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.');
... ... @@ -164,7 +164,9 @@ for i0 = 1:size(t,1)
chMatchLog{end,2} = 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
... ...
... ... @@ -115,7 +115,7 @@ for j=1:length(KeepEvent) % Navigate all stim events
if strcmpi(patientCode(5:end),'MIL');noteName = strrep(noteName,'.0',''); noteName = strrep(noteName,'_MA_','_');end%some MIL notes
if strcmpi(patientCode(5:end),'REN');noteName = strrep(noteName,'.0','');end%some REN notes
if strcmpi(patientCode(5:end),'BIC');noteName = strrep(noteName,'.0','');end%some BIC notes
if strcmpi(patientCode(5:end),'HUH');noteName = strrep(noteName,'.0','');end%some HUH notes
if strcmpi(patientCode(5:end),'HUH');noteName = strrep(noteName,'.0',''); noteName = strrep(noteName,'','u'); end%some HUH notes
if strcmpi(patientCode(5:end),'TOU');noteName = strrep(noteName,'.0','');end%some TOU notes
if strcmpi(patientCode(5:end),'GRE');noteName = strrep(noteName,'.0','');end%some GRE notes
if strcmpi(patientCode(5:end),'FLO');noteName = strrep(noteName,'.0','');end%some FLO notes
... ...