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 erp for ind_id = 1:33 id = sprintf('sub-%03d', ind_id); disp(id) load(fullfile(pn.data_erp, [id,'_erp_bl.mat'])); for ind_option = 2:3 if ind_id == 1 erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = erp_bl.subsequent_memory{ind_option}; erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = ... rmfield(erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}), {'avg', 'var', 'dof'}); erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).dimord = 'sub_chan_time'; end erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).avg(ind_id,:,:) = erp_bl.subsequent_memory{ind_option}.avg; end end time = erpgroup.subsequent_memory.subsequent_remembered.time; elec = erpgroup.subsequent_memory.subsequent_remembered.elec; channels = erpgroup.subsequent_memory.subsequent_remembered.label; mergeddata = cat(4, erpgroup.subsequent_memory.subsequent_forgotten.avg, ... erpgroup.subsequent_memory.subsequent_remembered.avg); smoothdur = 10; % 5 = 10 ms %% visualize differences idx_chans = [44,14,9,15]; % 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,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),... '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,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),... 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1); % ax = gca; ax.YDir = 'reverse'; legend([l1.mainLine, l2.mainLine],{'forgotten', 'remembered'}, ... 'location', 'southwest'); legend('boxoff') xlabel('Time (s) from stim onset') xlim([-.25 1.9]); %ylim(YLim) ylabel({'ERP';'(microVolts)'}); xlabel({'Time (s)'}); set(findall(gcf,'-property','FontSize'),'FontSize',14)