Validate Stim Names for STR
Showing
4 changed files
with
71 additions
and
19 deletions
@@ -174,6 +174,9 @@ for i0 = 1:size(t,1) | @@ -174,6 +174,9 @@ for i0 = 1:size(t,1) | ||
174 | chMatchLog{end+1,1} = Sensors.label{i1}; | 174 | chMatchLog{end+1,1} = Sensors.label{i1}; |
175 | chMatchLog{end,2} = Name{iChanPos}; | 175 | chMatchLog{end,2} = Name{iChanPos}; |
176 | Sensors.label{i1} = Name{iChanPos}; | 176 | Sensors.label{i1} = Name{iChanPos}; |
177 | + if max(Sensors.chanpos(:))>1 && strcmp(Sensors.unit,'m') | ||
178 | + Sensors.unit='mm'; | ||
179 | + end | ||
177 | else | 180 | else |
178 | disp(['ImaGIN> WARNING: ' Sensors.label{i1} ' not assigned']); | 181 | disp(['ImaGIN> WARNING: ' Sensors.label{i1} ' not assigned']); |
179 | chNotFound{end+1} = Sensors.label{i1}; | 182 | chNotFound{end+1} = Sensors.label{i1}; |
@@ -215,16 +218,18 @@ for i0 = 1:size(t,1) | @@ -215,16 +218,18 @@ for i0 = 1:size(t,1) | ||
215 | end | 218 | end |
216 | 219 | ||
217 | % Match file: Correspondance between SEEG-CSV-LENA conventions | 220 | % Match file: Correspondance between SEEG-CSV-LENA conventions |
218 | - if isfield(S, 'FileTxtOut') && ~isempty(S.FileTxtOut) | ||
219 | - try | ||
220 | - fid = fopen(S.FileTxtOut,'w'); | ||
221 | - fprintf(fid,'SEEG,CSV\n'); | ||
222 | - for i = 1:size(chMatchLog,1) | ||
223 | - fprintf(fid,'%s,%s\n', chMatchLog{i,1}, chMatchLog{i,2}); | 221 | + if exist('S','var') |
222 | + if isfield(S, 'FileTxtOut') && ~isempty(S.FileTxtOut) | ||
223 | + try | ||
224 | + fid = fopen(S.FileTxtOut,'w'); | ||
225 | + fprintf(fid,'SEEG,CSV\n'); | ||
226 | + for i = 1:size(chMatchLog,1) | ||
227 | + fprintf(fid,'%s,%s\n', chMatchLog{i,1}, chMatchLog{i,2}); | ||
228 | + end | ||
229 | + fclose(fid); | ||
230 | + catch | ||
231 | + disp('Log with matched channels names SEEG-CSV not saved.') | ||
224 | end | 232 | end |
225 | - fclose(fid); | ||
226 | - catch | ||
227 | - disp('Log with matched channels names SEEG-CSV not saved.') | ||
228 | end | 233 | end |
229 | end | 234 | end |
230 | 235 |
@@ -100,7 +100,7 @@ for i1=1:NName | @@ -100,7 +100,7 @@ for i1=1:NName | ||
100 | Z=ones(1,101)*Pos(1,3); | 100 | Z=ones(1,101)*Pos(1,3); |
101 | end | 101 | end |
102 | D=sqrt((X-Pos(1,1)).^2+(Y-Pos(1,2)).^2+(Z-Pos(1,3)).^2); | 102 | D=sqrt((X-Pos(1,1)).^2+(Y-Pos(1,2)).^2+(Z-Pos(1,3)).^2); |
103 | - NElec=ceil(max(D)/d); | 103 | + NElec=max([ceil(max(D)/d) 1]); |
104 | for i2=1:NElec | 104 | for i2=1:NElec |
105 | NElectrode=NElectrode+1; | 105 | NElectrode=NElectrode+1; |
106 | NameElectrode{NElectrode}=[NameElec{i1} num2str(i2)]; | 106 | NameElectrode{NElectrode}=[NameElec{i1} num2str(i2)]; |
@@ -261,6 +261,53 @@ if strcmpi(patientCode(5:end),'FRE') | @@ -261,6 +261,53 @@ if strcmpi(patientCode(5:end),'FRE') | ||
261 | fprintf('\n \n MESSAGE: .. %s parameters updated ..::\n',patientCode); | 261 | fprintf('\n \n MESSAGE: .. %s parameters updated ..::\n',patientCode); |
262 | end | 262 | end |
263 | end | 263 | end |
264 | +str_flag = 0; | ||
265 | +% STR patients have amplitude that varies | ||
266 | +if strcmpi(patientCode(5:end),'STR') | ||
267 | + load('/gin/data/database/02-raw/stim_parameters-ftract-str.mat','stim_params') | ||
268 | + Loc = find(ismember(stim_params.PCode, patientCode), 1); | ||
269 | + if ~isempty(Loc) | ||
270 | + str_flag = 1; | ||
271 | + Frq = stim_params.Freq{Loc}; | ||
272 | +% Amp = stim_params.Ampl{Loc}; | ||
273 | + Pul = stim_params.Pulse{Loc}; | ||
274 | + for n = 1:length(KeepEvent) | ||
275 | + xsub1 = regexp(Notes{KeepEvent(n)},rxp1,'match'); | ||
276 | + xsub2 = regexp(Notes{KeepEvent(n)},rxp2,'match'); | ||
277 | + xsub3 = regexp(Notes{KeepEvent(n)},rxp3,'match'); | ||
278 | + | ||
279 | +% if ~isempty(xsub1) % insert stim Amplitude | ||
280 | +% Notes{KeepEvent(n)} = char(strrep(Notes{KeepEvent(n)},xsub1,Amp)); | ||
281 | +% else | ||
282 | +% Notes{KeepEvent(n)} = [Notes{KeepEvent(n)} '_' Amp]; | ||
283 | +% end | ||
284 | +% | ||
285 | +% if isempty(xsub1) % insert stim Amplitude | ||
286 | +% Notes{KeepEvent(n)} = [Notes{KeepEvent(n)} '_' Amp]; | ||
287 | +% end | ||
288 | + | ||
289 | + if ~isempty(xsub2) % insert stim Frequency | ||
290 | + Notes{KeepEvent(n)} = char(strrep(Notes{KeepEvent(n)},xsub2,Frq)); | ||
291 | + else | ||
292 | + Notes{KeepEvent(n)} = [Notes{KeepEvent(n)} '_' Frq]; | ||
293 | + end | ||
294 | + | ||
295 | + if ~isempty(xsub3) % insert stim Pulse | ||
296 | + Notes{KeepEvent(n)} = char(strrep(Notes{KeepEvent(n)},xsub3,Pul)); | ||
297 | + else | ||
298 | + Notes{KeepEvent(n)} = [Notes{KeepEvent(n)} '_' Pul]; | ||
299 | + end | ||
300 | + Notes{KeepEvent(n)} = char(strrep(Notes{KeepEvent(n)},'_3_','_')); | ||
301 | + evt(KeepEvent(n)).type = Notes{KeepEvent(n)}; | ||
302 | + end | ||
303 | + D = events(D,1,evt); | ||
304 | + D2 = clone(D, D.fnamedat, [D.nchannels D.nsamples D.ntrials]); | ||
305 | + D2(:,:,:) = D(:,:,:); | ||
306 | + save(D2); | ||
307 | + fprintf('\n \n MESSAGE: .. %s parameters updated ..::\n',patientCode); | ||
308 | + %set_final_status('OK') | ||
309 | + end | ||
310 | +end | ||
264 | val_flag = 0; | 311 | val_flag = 0; |
265 | if strcmpi(patientCode(5:end),'VAL') | 312 | if strcmpi(patientCode(5:end),'VAL') |
266 | load('/gin/data/database/02-raw/stim_parameters-ftract-val.mat','stim_params') | 313 | load('/gin/data/database/02-raw/stim_parameters-ftract-val.mat','stim_params') |
@@ -287,7 +334,7 @@ if strcmpi(patientCode(5:end),'VAL') | @@ -287,7 +334,7 @@ if strcmpi(patientCode(5:end),'VAL') | ||
287 | end | 334 | end |
288 | 335 | ||
289 | 336 | ||
290 | -if mil_flag == 0 || fre_flag == 0 || buc_flag == 0 || val_flag == 0 | 337 | +if mil_flag == 0 || fre_flag == 0 || buc_flag == 0 || str_flag == 0 || val_flag == 0 |
291 | pVals = []; | 338 | pVals = []; |
292 | for k = 1:length(KeepEvent) | 339 | for k = 1:length(KeepEvent) |
293 | xsub3 = regexp(Notes{KeepEvent(k)},rxp3,'match'); | 340 | xsub3 = regexp(Notes{KeepEvent(k)},rxp3,'match'); |
@@ -279,15 +279,15 @@ if size(DD,1)>1 | @@ -279,15 +279,15 @@ if size(DD,1)>1 | ||
279 | end | 279 | end |
280 | 280 | ||
281 | for i1 = 1:size(DD,1) | 281 | for i1 = 1:size(DD,1) |
282 | -% try | ||
283 | -% [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:)),S{i1}); | ||
284 | -% catch | ||
285 | -% try | 282 | + try |
283 | + [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:)),S{i1}); | ||
284 | + catch | ||
285 | + try | ||
286 | [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:)),S); | 286 | [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:)),S); |
287 | -% catch | ||
288 | -% [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:))); | ||
289 | -% end | ||
290 | -% end | 287 | + catch |
288 | + [D,TimeWindow,TimeWindowWidth] = ImaGIN_spm_eeg_tf_main(deblank(DD(i1,:))); | ||
289 | + end | ||
290 | + end | ||
291 | if (i1==1) && ~exist('S', 'var') | 291 | if (i1==1) && ~exist('S', 'var') |
292 | S.Method=D.tf.Method; | 292 | S.Method=D.tf.Method; |
293 | switch D.tf.Method | 293 | switch D.tf.Method |
-
Please register or login to post a comment