Browse Source

N1: split into two groups, align individual peaks, plot outputs

kosciessa 2 years ago
parent
commit
a7631a1606

+ 109 - 30
code/b_scenecat_n1.m

@@ -48,7 +48,7 @@ channels = erpgroup.scene_category.manmade.label;
 mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
     erpgroup.scene_category.natural.avg);
 
-%% plot topography of N1
+%% plot topography of visual N1
 
 % set custom colormap
 cBrew = brewermap(500,'RdBu');
@@ -59,18 +59,19 @@ h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
 
 cfg = [];
-cfg.layout = 'biosemi64.lay';
+cfg.layout = 'EEG1010.lay';
 cfg.parameter = 'powspctrm';
 cfg.comment = 'no';
 cfg.colormap = cBrew;
 cfg.colorbar = 'EastOutside';
 
 plotData = [];
-plotData.label = elec.label; % {1 x N}
+plotData.label = elec.label(1:64); % {1 x N}
 plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,1:2),3),1),4))'; 
+plotData.powspctrm = squeeze(nanmean(nanmean(nanmin(mergeddata(:,:,time>0.04 & time <0.12,1:2),[],3),1),4))'; 
 [~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1:6);
+idx_chans = sortidx(1);
+idx_chans_visual = idx_chans;
 
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
@@ -78,19 +79,20 @@ cfg.highlightchannel = plotData.label(idx_chans);
 cfg.highlightcolor = [1 0 0];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 18;
-cfg.zlim = [-5 5]*10^-4; 
+cfg.zlim = [-10 10]*10^-4; 
 cfg.figure = h;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-% figureName = ['xxx'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% visualize N1 over negative maximum
 
 % avg across channels and conditions
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
+condAvg1 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1),2),4));
+condAvg2 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,2),2),4));
+
+
 h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
 % new value = old value ? subject average + grand average
@@ -102,51 +104,128 @@ curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
 curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
 standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
 xlabel('Time (s) from stim onset')
-xlim([-1 2]); %ylim([-.03 .18])
+xlim([-.025 .16]); %ylim([-.03 .18])
 ylabel({'ERP';'(microVolts)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
-h = figure('units','centimeters','position',[0 0 15 10]);
+%% ERP components for subjects 1-17 and 18-33 are shifted in time!
+
+h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
 % new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
 standError = nanstd(curData,1)./sqrt(size(curData,1));
 l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
 standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-ax = gca; ax.YDir = 'reverse';
+% ax = gca; ax.YDir = 'reverse';
 xlabel('Time (s) from stim onset')
-xlim([0 .3]); %ylim([-.03 .18])
+xlim([-.025 .16]); %ylim([-.03 .18])
 ylabel({'ERP';'(microVolts)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
-% across all channels
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,:,:,1:2),2),4));
+%% align individual subjects N1 to first negative peak
+
+% find individual minimum (avg. across conditions) between 40 and 120 ms
+
+time2search = find(time>0.04 & time <0.12);
 
-h = figure('units','centimeters','position',[0 0 15 10]);
+newtime = 0-100*(time(2)-time(1)):(time(2)-time(1)):0+100*(time(2)-time(1));
+
+for indID = 1:size(condAvg,1)
+    %[peaks, locs] = findpeaks(condAvg1(indID,:));
+    tmp = find(islocalmin(condAvg(indID,time2search), ...
+        'FlatSelection', 'center', ...
+        'MinSeparation', 25));
+    minVal1(indID) = condAvg1(indID,time2search(tmp(1)));
+    curmin = time2search(tmp(1));
+    alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
+
+    minVal2(indID) = condAvg2(indID,time2search(tmp(1)));
+    curmin = time2search(tmp(1));
+    alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
+    
+    alignedTopo(indID,:,:) = squeeze(nanmean(mergeddata(indID,:,curmin-100:curmin+100,1:2),4));
+end
+
+% alternatively: consider global minimum
+% for indID = 1:size(condAvg,1)
+%     [~, minLoc1(indID)] = min(condAvg(indID,time2search));
+%     curmin = time2search(minLoc1(indID));
+%     minVal1(indID) = condAvg1(indID,curmin);
+%     alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
+%     [~, minLoc2(indID)] = min(condAvg(indID,time2search));
+%     curmin = time2search(minLoc2(indID));
+%     minVal1(indID) = condAvg2(indID,curmin);
+%     alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
+% end
+
+mergeddata_aligned = cat(3, alignedN1_1, alignedN1_2);
+
+[h, p] = ttest(minVal1, minVal2)
+
+% avg across channels and conditions
+condAvg_al = squeeze(nanmean(mergeddata_aligned(:,:,1:2),3));
+
+% check that troughs are aligned
+% figure; imagesc(zscore(condAvg_al,[],2))
+% figure; imagesc(condAvg_al)
+
+h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
 % new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,:,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+curData = squeeze(mergeddata_aligned(:,:,1));
+curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
 standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,:,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+l1 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(mergeddata_aligned(:,:,2));
+curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
 standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-ax = gca; ax.YDir = 'reverse';
-xlabel('Time (s) from stim onset')
-xlim([0 .3]); %ylim([-.03 .18])
+l2 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend({'manmade', 'natural'}, 'location', 'NorthWest'); legend('boxoff')
+xlabel('Time (s) from local minimum')
+xlim([-100 100]); %ylim([-.03 .18])
 ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
+xlabel({'Time (ms) from local minimum'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
+%% plot topography around detected trough
+
+h = figure('units','centimeters','position',[0 0 10 10]);
+set(gcf,'renderer','Painters')
+
+cfg = [];
+cfg.layout = 'EEG1010.lay';
+cfg.parameter = 'powspctrm';
+cfg.comment = 'no';
+cfg.colormap = cBrew;
+cfg.colorbar = 'EastOutside';
+
+plotData = [];
+plotData.label = elec.label(1:64); % {1 x N}
+plotData.dimord = 'chan';
+plotData.powspctrm = squeeze(nanmean(nanmean(alignedTopo(:, :, newtime>-.01 & newtime < .01),3),1))'; 
+[~, sortidx] = sort(plotData.powspctrm, 'ascend');
+idx_chans = sortidx(1);
+idx_chans_visual = idx_chans;
+
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+cfg.highlightchannel = plotData.label(idx_chans);
+cfg.highlightcolor = [1 0 0];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 18;
+cfg.zlim = [-5 5]*10^-4; 
+cfg.figure = h;
+ft_topoplotER(cfg,plotData);
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
+
 %% plot difference between conditions
 
 h = figure('units','centimeters','position',[0 0 10 10]);

+ 178 - 119
code/b_scenecat_n1_bl.m

@@ -11,7 +11,8 @@ pn.tools = fullfile(rootpath, 'tools');
     addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
     addpath(fullfile(pn.tools, 'BrewerMap'));
     addpath(fullfile(pn.tools, 'shadedErrorBar'));
-    
+pn.figures = fullfile(rootpath, 'figures');
+
 %% load event info
 
 load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
@@ -48,7 +49,24 @@ channels = erpgroup.scene_category.manmade.label;
 mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
     erpgroup.scene_category.natural.avg);
 
-%% plot topography of N1
+%% plot the ERPs (for initial inspection)
+
+% manmade = erpgroup.scene_category.manmade;
+% manmade.avg = squeeze(nanmean(manmade.avg,1));
+% manmade.dimord = 'chan_time';
+% 
+% natural = erpgroup.scene_category.natural;
+% natural.avg = squeeze(nanmean(natural.avg,1));
+% natural.dimord = 'chan_time';
+% 
+% cfg = [];
+% cfg.layout = 'EEG1010.lay';
+% cfg.interactive = 'yes';
+% cfg.showoutline = 'yes';
+% cfg.xlim = [-.2 .3];
+% ft_multiplotER(cfg, natural, manmade)
+
+%% plot topography of visual N1
 
 % set custom colormap
 cBrew = brewermap(500,'RdBu');
@@ -59,18 +77,18 @@ h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
 
 cfg = [];
-cfg.layout = 'biosemi64.lay';
+cfg.layout = 'EEG1005.lay';
 cfg.parameter = 'powspctrm';
 cfg.comment = 'no';
 cfg.colormap = cBrew;
 cfg.colorbar = 'EastOutside';
 
 plotData = [];
-plotData.label = elec.label; % {1 x N}
+plotData.label = elec.label(1:64); % {1 x N}
 plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,1:2),3),1),4))'; 
+plotData.powspctrm = squeeze(nanmean(nanmean(nanmin(mergeddata(:,:,time>0.04 & time <0.12,1:2),[],3),1),4))'; 
 [~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1:6);
+idx_chans = sortidx(1);
 
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
@@ -82,31 +100,19 @@ cfg.zlim = [-10 10]*10^-4;
 cfg.figure = h;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-% figureName = ['xxx'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['b_topo_minimum'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% visualize N1 over negative maximum
 
 % avg across channels and conditions
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
-% h = figure('units','centimeters','position',[0 0 10 8]);
-% cla; hold on;
-% % new value = old value ? subject average + grand average
-% curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-% curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-% standError = nanstd(curData,1)./sqrt(size(curData,1));
-% l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-% curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-% curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-% standError = nanstd(curData,1)./sqrt(size(curData,1));
-% l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% xlabel('Time (s) from stim onset')
-% xlim([-.2 .5]); %ylim([-.03 .18])
-% ylabel({'ERP';'(microVolts)'});
-% xlabel({'Time (s)'});    
-% set(findall(gcf,'-property','FontSize'),'FontSize',12)
+condAvg1 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1),2),4));
+condAvg2 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
@@ -121,51 +127,123 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
 % ax = gca; ax.YDir = 'reverse';
 xlabel('Time (s) from stim onset')
-xlim([-.05 .3]); %ylim([-.03 .18])
+xlim([-.025 .16]); %ylim([-.03 .18])
 ylabel({'ERP';'(microVolts)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
-% 
-% % across all channels
-% condAvg = squeeze(nanmean(nanmean(mergeddata(:,:,:,1:2),2),4));
-% 
-% h = figure('units','centimeters','position',[0 0 15 10]);
-% cla; hold on;
-% % new value = old value ? subject average + grand average
-% curData = squeeze(nanmean(mergeddata(:,:,:,1),2));
-% curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-% standError = nanstd(curData,1)./sqrt(size(curData,1));
-% l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-% curData = squeeze(nanmean(mergeddata(:,:,:,2),2));
-% curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-% standError = nanstd(curData,1)./sqrt(size(curData,1));
-% l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+
+%% ERP components for subjects 1-17 and 18-33 are shifted in time!
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
 % ax = gca; ax.YDir = 'reverse';
-% xlabel('Time (s) from stim onset')
-% xlim([0 .3]); %ylim([-.03 .18])
-% ylabel({'ERP';'(microVolts)'});
-% xlabel({'Time (s)'});    
-% set(findall(gcf,'-property','FontSize'),'FontSize',12)
+legend({'Initial 17', 'Final 16'}, 'location', 'NorthWest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.025 .16]); %ylim([-.03 .18])
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['b_twogroups'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% align individual subjects N1 to first negative peak
+
+% find individual minimum (avg. across conditions) between 40 and 120 ms
+
+time2search = find(time>0.04 & time <0.12);
+
+newtime = 0-100*(time(2)-time(1)):(time(2)-time(1)):0+100*(time(2)-time(1));
 
-%% plot difference between conditions
+for indID = 1:size(condAvg,1)
+    %[peaks, locs] = findpeaks(condAvg1(indID,:));
+    tmp = find(islocalmin(condAvg(indID,time2search), ...
+        'FlatSelection', 'center', ...
+        'MinSeparation', 25));
+    minVal1(indID) = condAvg1(indID,time2search(tmp(1)));
+    curmin = time2search(tmp(1));
+    alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
+
+    minVal2(indID) = condAvg2(indID,time2search(tmp(1)));
+    curmin = time2search(tmp(1));
+    alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
+    
+    alignedTopo(indID,:,:) = squeeze(nanmean(mergeddata(indID,:,curmin-100:curmin+100,1:2),4));
+end
+
+% alternatively: consider global minimum
+% for indID = 1:size(condAvg,1)
+%     [~, minLoc1(indID)] = min(condAvg(indID,time2search));
+%     curmin = time2search(minLoc1(indID));
+%     minVal1(indID) = condAvg1(indID,curmin);
+%     alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
+%     [~, minLoc2(indID)] = min(condAvg(indID,time2search));
+%     curmin = time2search(minLoc2(indID));
+%     minVal1(indID) = condAvg2(indID,curmin);
+%     alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
+% end
+
+mergeddata_aligned = cat(3, alignedN1_1, alignedN1_2);
+
+[h, p, ci, stats] = ttest(minVal1, minVal2)
+
+% avg across channels and conditions
+condAvg_al = squeeze(nanmean(mergeddata_aligned(:,:,1:2),3));
+
+% check that troughs are aligned
+% figure; imagesc(zscore(condAvg_al,[],2))
+% figure; imagesc(condAvg_al)
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% new value = old value ? subject average + grand average
+curData = squeeze(mergeddata_aligned(:,:,1));
+curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(mergeddata_aligned(:,:,2));
+curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend({'manmade', 'natural'}, 'location', 'NorthWest'); legend('boxoff')
+xlabel('Time (s) from local minimum')
+xlim([-100 100]); %ylim([-.03 .18])
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (ms) from local minimum'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['b_scenecat_N1'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot topography around detected trough
 
 h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
 
 cfg = [];
-cfg.layout = 'biosemi64.lay';
+cfg.layout = 'EEG1010.lay';
 cfg.parameter = 'powspctrm';
 cfg.comment = 'no';
 cfg.colormap = cBrew;
 cfg.colorbar = 'EastOutside';
 
 plotData = [];
-plotData.label = elec.label; % {1 x N}
+plotData.label = elec.label(1:64); % {1 x N}
 plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,2),3),1),4))'...
-    -squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,1),3),1),4))'; 
+plotData.powspctrm = squeeze(nanmean(nanmean(alignedTopo(:, :, newtime>-.01 & newtime < .01),3),1))'; 
 [~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1:6);
+idx_chans = sortidx(1);
+idx_chans_visual = idx_chans;
 
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
@@ -173,76 +251,57 @@ cfg.highlightchannel = plotData.label(idx_chans);
 cfg.highlightcolor = [1 0 0];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 18;
-%cfg.zlim = [-5 5]*10^-4; 
+cfg.zlim = [-5 5]*10^-4; 
 cfg.figure = h;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-
-
-%% visualize for negative pls channels
-
-idx_chans = [28:30];
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-xlabel('Time (s) from stim onset')
-xlim([-.2 1]); %ylim([-.03 .18])
-xlim([-.05 .3]);
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
-%% visualize for positive pls channels
-
-idx_chans = [21:23, 58:62];
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+figureName = ['b_trough_topo'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-xlabel('Time (s) from stim onset')
-xlim([-.5 1]); %ylim([-.03 .18])
-xlim([-.05 .3]);
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
-
-%% visualize for frontal channels
-
-idx_chans = [37];%[4,38,39];
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-xlabel('Time (s) from stim onset')
-xlim([-1 2]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
+%% plot topography for different timewindows
+% 
+% timewins = [0.03 0.075; ...
+%     0.075, 0.1; ...
+%     0.1, 0.15; ...
+%     0.495, 0.535];
+% 
+% % set custom colormap
+% cBrew = brewermap(500,'RdBu');
+% cBrew = flipud(cBrew);
+% colormap(cBrew)
+% 
+% h = figure('units','centimeters','position',[0 0 10 10]);
+% set(gcf,'renderer','Painters')
+% 
+% for indTime = 1:size(timewins,1)
+%     subplot(3,2,indTime)
+% 
+%     cfg = [];
+%     cfg.layout = 'EEG1010.lay';
+%     cfg.parameter = 'powspctrm';
+%     cfg.comment = 'no';
+%     cfg.colormap = cBrew;
+%     cfg.colorbar = 'EastOutside';
+% 
+%     plotData = [];
+%     plotData.label = elec.label(1:64); % {1 x N}
+%     plotData.dimord = 'chan';
+%     plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>=timewins(indTime,1) & time <=timewins(indTime,2),1),3),1),4))'; 
+%     [~, sortidx] = sort(plotData.powspctrm, 'ascend');
+%     idx_chans = sortidx(1:6);
+% 
+%     cfg.marker = 'off'; 
+%     cfg.highlight = 'yes';
+%     cfg.highlightchannel = plotData.label(idx_chans);
+%     cfg.highlightcolor = [1 0 0];
+%     cfg.highlightsymbol = '.';
+%     cfg.highlightsize = 18;
+%     cfg.zlim = [-10 10]*10^-4; 
+%     cfg.figure = h;
+%     ft_topoplotER(cfg,plotData);
+%     cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
+% 
+% end

File diff suppressed because it is too large
+ 1853 - 0
figures/b_scenecat_N1.eps


+ 1 - 0
figures/b_scenecat_N1.png

@@ -0,0 +1 @@
+../.git/annex/objects/9Q/WV/MD5E-s32384--99d39d021810ab53a7e207e52a7d54c4.png/MD5E-s32384--99d39d021810ab53a7e207e52a7d54c4.png

File diff suppressed because it is too large
+ 2266 - 0
figures/b_topo_minimum.eps


+ 1 - 0
figures/b_topo_minimum.png

@@ -0,0 +1 @@
+../.git/annex/objects/PQ/1Q/MD5E-s60621--0e28aa85716c6eebc8cf057e9d443411.png/MD5E-s60621--0e28aa85716c6eebc8cf057e9d443411.png

File diff suppressed because it is too large
+ 2288 - 0
figures/b_trough_topo.eps


+ 1 - 0
figures/b_trough_topo.png

@@ -0,0 +1 @@
+../.git/annex/objects/7f/Zz/MD5E-s60733--9850126583f252458cc0a456d77422f4.png/MD5E-s60733--9850126583f252458cc0a456d77422f4.png

File diff suppressed because it is too large
+ 1773 - 0
figures/b_twogroups.eps


+ 1 - 0
figures/b_twogroups.png

@@ -0,0 +1 @@
+../.git/annex/objects/Jw/6v/MD5E-s36207--16e03abb09dbd2de8b94f3381c4fb854.png/MD5E-s36207--16e03abb09dbd2de8b94f3381c4fb854.png