|
@@ -0,0 +1,413 @@
|
|
|
+
|
|
|
+currentFile = mfilename('fullpath');
|
|
|
+[pathstr,~,~] = fileparts(currentFile);
|
|
|
+cd(fullfile(pathstr,'..'))
|
|
|
+rootpath = pwd;
|
|
|
+
|
|
|
+pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
|
|
|
+pn.data_erp = fullfile(rootpath, 'data', 'erp');
|
|
|
+pn.data_erf = fullfile(rootpath, 'data', 'erf');
|
|
|
+pn.tools = fullfile(rootpath, 'tools');
|
|
|
+ addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
|
|
|
+ addpath(fullfile(pn.tools, 'BrewerMap'));
|
|
|
+ addpath(fullfile(pn.tools, 'shadedErrorBar'));
|
|
|
+
|
|
|
+%% load event info
|
|
|
+
|
|
|
+load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
|
|
|
+
|
|
|
+parameter = {'scene_category'; 'old'; 'behavior'; 'subsequent_memory'};
|
|
|
+for ind_param = 1:numel(parameter)
|
|
|
+ conds.(parameter{ind_param}) = unique(events.(parameter{ind_param}));
|
|
|
+end
|
|
|
+
|
|
|
+%% load erp_bl
|
|
|
+
|
|
|
+for ind_id = 1:33
|
|
|
+ id = sprintf('sub-%03d', ind_id);
|
|
|
+ load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
|
|
|
+ for ind_option = 1:numel(conds.scene_category)
|
|
|
+ if ind_id == 1
|
|
|
+ erpgroup.scene_category.(conds.scene_category{ind_option}) = erp_bl.scene_category{ind_option};
|
|
|
+ erpgroup.scene_category.(conds.scene_category{ind_option}) = ...
|
|
|
+ rmfield(erpgroup.scene_category.(conds.scene_category{ind_option}), {'avg', 'var', 'dof'});
|
|
|
+ erpgroup.scene_category.(conds.scene_category{ind_option}).dimord = 'sub_chan_time';
|
|
|
+ end
|
|
|
+ erpgroup.scene_category.(conds.scene_category{ind_option}).avg(ind_id,:,:) = erp_bl.scene_category{ind_option}.avg;
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+time = erpgroup.scene_category.manmade.time;
|
|
|
+elec = erpgroup.scene_category.manmade.elec;
|
|
|
+channels = erpgroup.scene_category.manmade.label;
|
|
|
+
|
|
|
+%idx_chans = find(ismember(channels, {'O1', 'Oz', 'O2'}));
|
|
|
+%idx_chans = find(ismember(channels, {'PO7', 'PO8'}));
|
|
|
+%idx_chans = find(ismember(channels, {'Pz', 'CPz', 'P1'}));
|
|
|
+
|
|
|
+mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
|
|
|
+ erpgroup.scene_category.natural.avg);
|
|
|
+
|
|
|
+%% plot topography of visual N1
|
|
|
+
|
|
|
+% 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')
|
|
|
+
|
|
|
+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(nanmin(mergeddata(:,:,time>0.05 & time <0.07,1:2),[],3),1),4))';
|
|
|
+[~, 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 = [-2 2];%[-8 8]*10^-4;
|
|
|
+cfg.figure = h;
|
|
|
+ft_topoplotER(cfg,plotData);
|
|
|
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
|
|
|
+
|
|
|
+%% 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);
|
|
|
+% ax = gca; ax.YDir = 'reverse';
|
|
|
+xlabel('Time (s) from stim onset')
|
|
|
+xlim([-.05 .3]); %ylim([-.03 .18])
|
|
|
+ylabel({'ERP';'(microVolts)'});
|
|
|
+xlabel({'Time (s)'});
|
|
|
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
|
|
|
+
|
|
|
+%% 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([-.025 .16]); %ylim([-.03 .18])
|
|
|
+ylabel({'ERP';'(microVolts)'});
|
|
|
+xlabel({'Time (s)'});
|
|
|
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
|
|
|
+
|
|
|
+%% align individual subjects N1 to first negative peak
|
|
|
+
|
|
|
+% find individual minimum (condition-specific) between 40 and 150 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));
|
|
|
+
|
|
|
+% for indID = 1:size(condAvg,1)
|
|
|
+% %[peaks, locs] = findpeaks(condAvg1(indID,:));
|
|
|
+% tmp = find(islocalmin(condAvg(indID,time2search), ...
|
|
|
+% 'FlatSelection', 'center', ...
|
|
|
+% 'MinSeparation', 15));
|
|
|
+% minVal1(indID) = condAvg1(indID,time2search(tmp(1)));
|
|
|
+% minLoc1(indID) = tmp(1);
|
|
|
+% curmin = time2search(tmp(1));
|
|
|
+% alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
|
|
|
+%
|
|
|
+% tmp = find(islocalmin(condAvg(indID,time2search), ...
|
|
|
+% 'FlatSelection', 'center', ...
|
|
|
+% 'MinSeparation', 15));
|
|
|
+% minVal2(indID) = condAvg2(indID,time2search(tmp(1)));
|
|
|
+% minLoc2(indID) = tmp(1);
|
|
|
+% curmin = time2search(tmp(1));
|
|
|
+% alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
|
|
|
+% 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));
|
|
|
+
|
|
|
+% plot aligned signals
|
|
|
+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';
|
|
|
+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)
|
|
|
+
|
|
|
+%% plot topography of frontal N1
|
|
|
+
|
|
|
+% 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')
|
|
|
+
|
|
|
+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(nanmin(mergeddata(:,:,time>0.08 & time <0.12,1:2),[],3),1),4))';
|
|
|
+%plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.05 & time <0.1,1:2),3),1),4))';
|
|
|
+%plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.1 & time <0.15,1:2),3),1),4))';
|
|
|
+[~, sortidx] = sort(plotData.powspctrm, 'ascend');
|
|
|
+idx_chans = sortidx(1:6);
|
|
|
+idx_chans_frontal = 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 = [-6 6];%[-8 8]*10^-4;
|
|
|
+cfg.figure = h;
|
|
|
+ft_topoplotER(cfg,plotData);
|
|
|
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
|
|
|
+
|
|
|
+%% 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);
|
|
|
+% ax = gca; ax.YDir = 'reverse';
|
|
|
+xlabel('Time (s) from stim onset')
|
|
|
+xlim([-.05 .3]); %ylim([-.03 .18])
|
|
|
+ylabel({'ERP';'(microVolts)'});
|
|
|
+xlabel({'Time (s)'});
|
|
|
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
|
|
|
+
|
|
|
+%% plot both trajectories into same plot
|
|
|
+
|
|
|
+h = figure('units','centimeters','position',[0 0 10 8]);
|
|
|
+cla; hold on;
|
|
|
+% new value = old value ? subject average + grand average
|
|
|
+curData = squeeze(nanmean(nanmean(mergeddata(:,idx_chans_visual,:,1:2),2),4));
|
|
|
+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(nanmean(mergeddata(:,idx_chans_frontal,:,1:2),2),4));
|
|
|
+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([-.025 .15]); %ylim([-.03 .18])
|
|
|
+ylabel({'ERP';'(microVolts)'});
|
|
|
+xlabel({'Time (s)'});
|
|
|
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
|
|
|
+
|
|
|
+%% plot difference between conditions
|
|
|
+
|
|
|
+h = figure('units','centimeters','position',[0 0 10 10]);
|
|
|
+set(gcf,'renderer','Painters')
|
|
|
+
|
|
|
+cfg = [];
|
|
|
+cfg.layout = 'biosemi64.lay';
|
|
|
+cfg.parameter = 'powspctrm';
|
|
|
+cfg.comment = 'no';
|
|
|
+cfg.colormap = cBrew;
|
|
|
+cfg.colorbar = 'EastOutside';
|
|
|
+
|
|
|
+plotData = [];
|
|
|
+plotData.label = elec.label(1:66); % {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))';
|
|
|
+[~, 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 = [-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));
|
|
|
+
|
|
|
+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)
|
|
|
+
|
|
|
+%% visualize for all channels
|
|
|
+
|
|
|
+idx_chans = [1:66];
|
|
|
+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)
|
|
|
+
|
|
|
+%% plot the ERPs
|
|
|
+
|
|
|
+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 = 'biosemi64.lay';
|
|
|
+cfg.interactive = 'yes';
|
|
|
+cfg.showoutline = 'yes';
|
|
|
+cfg.xlim = [-.2 .3];
|
|
|
+ft_multiplotER(cfg, natural, manmade)
|