Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

d1_taskPLS_recognition_erp_trace.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. currentFile = mfilename('fullpath');
  2. [pathstr,~,~] = fileparts(currentFile);
  3. cd(fullfile(pathstr,'..'))
  4. rootpath = pwd;
  5. pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
  6. pn.data_erp = fullfile(rootpath, 'data', 'erp');
  7. pn.data_erf = fullfile(rootpath, 'data', 'erf');
  8. pn.tools = fullfile(rootpath, 'tools');
  9. addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
  10. addpath(fullfile(pn.tools, 'BrewerMap'));
  11. addpath(fullfile(pn.tools, 'shadedErrorBar'));
  12. %% load erp
  13. for ind_id = 1:33
  14. id = sprintf('sub-%03d', ind_id); disp(id)
  15. load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
  16. for ind_option = 1:4%numel(conds.behavior)
  17. if ind_id == 1
  18. erpgroup.behavior.(conds.behavior{ind_option}) = erp_bl.behavior{ind_option};
  19. erpgroup.behavior.(conds.behavior{ind_option}) = ...
  20. rmfield(erpgroup.behavior.(conds.behavior{ind_option}), {'avg', 'var', 'dof'});
  21. erpgroup.behavior.(conds.behavior{ind_option}).dimord = 'sub_chan_time';
  22. end
  23. erpgroup.behavior.(conds.behavior{ind_option}).avg(ind_id,:,:) = erp_bl.behavior{ind_option}.avg;
  24. end
  25. end
  26. time = erpgroup.behavior.hit.time;
  27. elec = erpgroup.behavior.hit.elec;
  28. channels = erpgroup.behavior.hit.label;
  29. mergeddata = cat(4, erpgroup.behavior.hit.avg, ...
  30. erpgroup.behavior.miss.avg);
  31. smoothdur = 10; % 5 = 10 ms
  32. %% get max. channels
  33. load(fullfile(pn.data, 'd1_taskpls_erp.mat'),...
  34. 'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
  35. stat.mask = stat.mask;
  36. stat.prob = stat.prob.*-1;
  37. result.vsc = result.vsc.*-1;
  38. result.usc = result.usc.*-1;
  39. plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.35 & stat.time<.55).*...
  40. stat.prob(:,:,stat.time>.35 & stat.time<.55),3));
  41. [~, topo1] = sort(plotData.powspctrm, 'descend');
  42. plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.6 & stat.time<.8).*...
  43. stat.prob(:,:,stat.time>0.6 & stat.time<.8),3));
  44. [~, topo2] = sort(plotData.powspctrm, 'descend');
  45. plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>1.2 & stat.time<1.7).*...
  46. stat.prob(:,:,stat.time>1.2 & stat.time<1.7),3));
  47. [~, topo3] = sort(plotData.powspctrm, 'descend');
  48. %% visualize intial changes
  49. idx_chans = topo1(1);
  50. % avg across channels and conditions
  51. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  52. h = figure('units','centimeters','position',[0 0 10 8]);
  53. cla; hold on;
  54. % highlight relevant phase in background
  55. patches.timeVec = [0.35 0.55];
  56. patches.colorVec = [.8 .95 1];
  57. for indP = 1:size(patches.timeVec,2)-1
  58. YLim = [-7 2]*10^-4;
  59. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  60. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  61. p.EdgeColor = 'none';
  62. end
  63. % new value = old value ? subject average + grand average
  64. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  65. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  66. standError = nanstd(curData,1)./sqrt(size(curData,1));
  67. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  68. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  69. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  70. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  71. standError = nanstd(curData,1)./sqrt(size(curData,1));
  72. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  73. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  74. % ax = gca; ax.YDir = 'reverse';
  75. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  76. 'location', 'southwest'); legend('boxoff')
  77. xlabel('Time (s) from stim onset')
  78. xlim([-.25 1.9]); ylim(YLim)
  79. ylabel({'ERP';'(microVolts)'});
  80. xlabel({'Time (s)'});
  81. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  82. figureName = ['d_rec_erp_1_pos'];
  83. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  84. saveas(h, fullfile(pn.figures, figureName), 'png');
  85. idx_chans = topo1(end-1:end);
  86. % avg across channels and conditions
  87. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  88. h = figure('units','centimeters','position',[0 0 10 8]);
  89. cla; hold on;
  90. % highlight relevant phase in background
  91. patches.timeVec = [0.35 0.55];
  92. patches.colorVec = [.8 .95 1];
  93. for indP = 1:size(patches.timeVec,2)-1
  94. YLim = [-3 3]*10^-4;
  95. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  96. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  97. p.EdgeColor = 'none';
  98. end
  99. % new value = old value ? subject average + grand average
  100. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  101. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  102. standError = nanstd(curData,1)./sqrt(size(curData,1));
  103. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  104. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  105. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  106. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  107. standError = nanstd(curData,1)./sqrt(size(curData,1));
  108. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  109. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  110. % ax = gca; ax.YDir = 'reverse';
  111. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  112. 'location', 'southwest'); legend('boxoff')
  113. xlabel('Time (s) from stim onset')
  114. xlim([-.25 1.9]); ylim(YLim)
  115. ylabel({'ERP';'(microVolts)'});
  116. xlabel({'Time (s)'});
  117. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  118. figureName = ['d_rec_erp_1_neg'];
  119. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  120. saveas(h, fullfile(pn.figures, figureName), 'png');
  121. %% visualize second topo
  122. idx_chans = topo2(1);
  123. % avg across channels and conditions
  124. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  125. h = figure('units','centimeters','position',[0 0 10 8]);
  126. cla; hold on;
  127. % highlight relevant phase in background
  128. patches.timeVec = [0.6 1.0];
  129. patches.colorVec = [1 .95 .8];
  130. for indP = 1:size(patches.timeVec,2)-1
  131. YLim = [-5 5]*10^-4;
  132. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  133. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  134. p.EdgeColor = 'none';
  135. end
  136. % % highlight relevant phase in background
  137. % patches.timeVec = [1.2 1.7];
  138. % patches.colorVec = [1 .8 .7];
  139. % for indP = 1:size(patches.timeVec,2)-1
  140. % YLim = [-5 5]*10^-4;
  141. % p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  142. % [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  143. % p.EdgeColor = 'none';
  144. % end
  145. % new value = old value ? subject average + grand average
  146. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  147. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  148. standError = nanstd(curData,1)./sqrt(size(curData,1));
  149. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  150. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  151. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  152. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  153. standError = nanstd(curData,1)./sqrt(size(curData,1));
  154. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  155. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  156. % ax = gca; ax.YDir = 'reverse';
  157. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  158. 'location', 'southwest'); legend('boxoff')
  159. xlabel('Time (s) from stim onset')
  160. xlim([-.25 1.9]); ylim(YLim)
  161. ylabel({'ERP';'(microVolts)'});
  162. xlabel({'Time (s)'});
  163. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  164. figureName = ['d_rec_erp_2_pos'];
  165. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  166. saveas(h, fullfile(pn.figures, figureName), 'png');
  167. %% topo 3: negative
  168. idx_chans = [63, 26, 21, 58];
  169. % avg across channels and conditions
  170. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  171. h = figure('units','centimeters','position',[0 0 10 8]);
  172. cla; hold on;
  173. % highlight relevant phase in background
  174. patches.timeVec = [0.6 1.0];
  175. patches.colorVec = [1 .95 .8];
  176. for indP = 1:size(patches.timeVec,2)-1
  177. YLim = [-2 12]*10^-4;
  178. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  179. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  180. p.EdgeColor = 'none';
  181. end
  182. % highlight relevant phase in background
  183. patches.timeVec = [1.2 1.7];
  184. patches.colorVec = [1 .8 .7];
  185. for indP = 1:size(patches.timeVec,2)-1
  186. YLim = [-2 12]*10^-4;
  187. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  188. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  189. p.EdgeColor = 'none';
  190. end
  191. % new value = old value ? subject average + grand average
  192. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  193. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  194. standError = nanstd(curData,1)./sqrt(size(curData,1));
  195. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  196. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  197. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  198. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  199. standError = nanstd(curData,1)./sqrt(size(curData,1));
  200. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  201. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  202. % ax = gca; ax.YDir = 'reverse';
  203. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  204. 'location', 'southwest'); legend('boxoff')
  205. xlabel('Time (s) from stim onset')
  206. xlim([-.25 1.9]); ylim(YLim)
  207. ylabel({'ERP';'(microVolts)'});
  208. xlabel({'Time (s)'});
  209. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  210. figureName = ['d_rec_erp_3_neg'];
  211. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  212. saveas(h, fullfile(pn.figures, figureName), 'png');
  213. %% topo 3: positive lateral
  214. idx_chans = [16, 53, 15, 54, 52, 51];
  215. % avg across channels and conditions
  216. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  217. h = figure('units','centimeters','position',[0 0 10 8]);
  218. cla; hold on;
  219. % % highlight relevant phase in background
  220. % patches.timeVec = [0.6 1.0];
  221. % patches.colorVec = [1 .95 .8];
  222. % for indP = 1:size(patches.timeVec,2)-1
  223. % YLim = [-4 2.5]*10^-4;
  224. % p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  225. % [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  226. % p.EdgeColor = 'none';
  227. % end
  228. % highlight relevant phase in background
  229. patches.timeVec = [1.2 1.7];
  230. patches.colorVec = [1 .8 .7];
  231. for indP = 1:size(patches.timeVec,2)-1
  232. YLim = [-4 2.5]*10^-4;
  233. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  234. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  235. p.EdgeColor = 'none';
  236. end
  237. % new value = old value ? subject average + grand average
  238. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  239. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  240. standError = nanstd(curData,1)./sqrt(size(curData,1));
  241. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  242. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  243. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  244. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  245. standError = nanstd(curData,1)./sqrt(size(curData,1));
  246. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  247. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  248. % ax = gca; ax.YDir = 'reverse';
  249. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  250. 'location', 'southwest'); legend('boxoff')
  251. xlabel('Time (s) from stim onset')
  252. xlim([-.25 1.9]); ylim(YLim)
  253. ylabel({'ERP';'(microVolts)'});
  254. xlabel({'Time (s)'});
  255. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  256. figureName = ['d_rec_erp_3_pos_lat'];
  257. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  258. saveas(h, fullfile(pn.figures, figureName), 'png');
  259. %% topo 3: positive posterior
  260. idx_chans = [28];
  261. % avg across channels and conditions
  262. condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
  263. h = figure('units','centimeters','position',[0 0 10 8]);
  264. cla; hold on;
  265. % highlight relevant phase in background
  266. patches.timeVec = [0.6 1.0];
  267. patches.colorVec = [1 .95 .8];
  268. for indP = 1:size(patches.timeVec,2)-1
  269. YLim = [-6 2.5]*10^-4;
  270. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  271. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  272. p.EdgeColor = 'none';
  273. end
  274. % highlight relevant phase in background
  275. patches.timeVec = [1.2 1.7];
  276. patches.colorVec = [1 .8 .7];
  277. for indP = 1:size(patches.timeVec,2)-1
  278. YLim = [-6 2.5]*10^-4;
  279. p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
  280. [YLim(1) YLim(1) YLim(2), YLim(2)], patches.colorVec(indP,:));
  281. p.EdgeColor = 'none';
  282. end
  283. % new value = old value ? subject average + grand average
  284. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
  285. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  286. standError = nanstd(curData,1)./sqrt(size(curData,1));
  287. l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  288. 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
  289. curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
  290. curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
  291. standError = nanstd(curData,1)./sqrt(size(curData,1));
  292. l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
  293. 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
  294. % ax = gca; ax.YDir = 'reverse';
  295. legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
  296. 'location', 'southwest'); legend('boxoff')
  297. xlabel('Time (s) from stim onset')
  298. xlim([-.25 1.9]); ylim(YLim)
  299. ylabel({'ERP';'(microVolts)'});
  300. xlabel({'Time (s)'});
  301. set(findall(gcf,'-property','FontSize'),'FontSize',14)
  302. figureName = ['d_rec_erp_3_pos_post'];
  303. saveas(h, fullfile(pn.figures, figureName), 'epsc');
  304. saveas(h, fullfile(pn.figures, figureName), 'png');