Authored by Anthony Boyer

Fix for some GRE notes and save electrode step output as SPM object

@@ -483,7 +483,7 @@ for c = 1:length(KeepEvent) % Navigate all stim events @@ -483,7 +483,7 @@ for c = 1:length(KeepEvent) % Navigate all stim events
483 S.FileOut= fullfile(DirOut, strcat(noteNameNew,'.txt')); 483 S.FileOut= fullfile(DirOut, strcat(noteNameNew,'.txt'));
484 484
485 mat_file = load(sFile); 485 mat_file = load(sFile);
486 - csv_chanlabels = mat_file.D.csv.chanlabels; % This new field is generated during the Electrode step so the .mat stores the channel labels found in the csv 486 + csv_chanlabels = mat_file.D.other.csv_labels; % This new field is generated during the Electrode step so the .mat stores the channel labels found in the csv
487 487
488 iChanMatch1 = find(strcmpi(chLabel1, csv_chanlabels)); 488 iChanMatch1 = find(strcmpi(chLabel1, csv_chanlabels));
489 iChanMatch2 = find(strcmpi(chLabel2, csv_chanlabels)); 489 iChanMatch2 = find(strcmpi(chLabel2, csv_chanlabels));
@@ -309,9 +309,11 @@ for i0 = 1:size(t,1) @@ -309,9 +309,11 @@ for i0 = 1:size(t,1)
309 SpmMat.D.trials.events(iEvt).type = noteNameNew; 309 SpmMat.D.trials.events(iEvt).type = noteNameNew;
310 end 310 end
311 end 311 end
312 - SpmMat.D.csv.chanlabels = csv_all_electrodes(:,1); % Add an extra field to the .mat so we have a listing of all channel labels in the csv. 312 + csv_struct.csv_labels = csv_all_electrodes(:,1);
  313 + SpmMat.D.other = csv_struct; % Add an extra field to the .mat so we have a listing of all channel labels in the csv.
313 % Update existing .mat file 314 % Update existing .mat file
314 save(SpmFile, '-struct', 'SpmMat'); 315 save(SpmFile, '-struct', 'SpmMat');
  316 + save(spm_eeg_load(SpmFile)); % SPM's save to create a valid SPM object
315 end 317 end
316 318
317 end 319 end
@@ -116,6 +116,7 @@ for j=1:length(KeepEvent) % Navigate all stim events @@ -116,6 +116,7 @@ for j=1:length(KeepEvent) % Navigate all stim events
116 if strcmpi(patientCode(5:end),'REN');noteName = strrep(noteName,'.0','');end%some REN notes 116 if strcmpi(patientCode(5:end),'REN');noteName = strrep(noteName,'.0','');end%some REN notes
117 if strcmpi(patientCode(5:end),'HUH');noteName = strrep(noteName,'.0','');end%some HUH notes 117 if strcmpi(patientCode(5:end),'HUH');noteName = strrep(noteName,'.0','');end%some HUH notes
118 if strcmpi(patientCode(5:end),'TOU');noteName = strrep(noteName,'.0','');end%some TOU notes 118 if strcmpi(patientCode(5:end),'TOU');noteName = strrep(noteName,'.0','');end%some TOU notes
  119 + if strcmpi(patientCode(5:end),'GRE');noteName = strrep(noteName,'.0','');end%some GRE notes
119 noteName = strrep(noteName,'.',''); noteName = strrep(noteName,',',''); % /!\ float value becomes integer /!\ 120 noteName = strrep(noteName,'.',''); noteName = strrep(noteName,',',''); % /!\ float value becomes integer /!\
120 noteName = strrep(noteName,'sec','s'); noteName = strrep(noteName,'AA','A'); 121 noteName = strrep(noteName,'sec','s'); noteName = strrep(noteName,'AA','A');
121 noteName = strrep(noteName,'Stim_Start_',''); noteName = strrep(noteName,'Stim_Stop_',''); 122 noteName = strrep(noteName,'Stim_Start_',''); noteName = strrep(noteName,'Stim_Stop_','');