[FieldTrip] How to plot ERP waveforms

Eelke Spaak eelke.spaak at donders.ru.nl
Tue Jan 7 09:47:42 CET 2014


Dear Lin Cai,

Could it be that the range of values is very different across the four
input arguments? You could check the max(tl.avg(:)) and min(tl.avg(:))
of each of the four structures to verify this. While you're at it, I
would also check for NaNs.

Best,
Eelke

On 7 January 2014 09:42, 蔡林 <bertram0611 at pku.edu.cn> wrote:
> Dear fieldtripers,
>
>     I am coming across a problem about plotting.I have four conditions in my experiment, but why did the figure have only one conditon? Please help me if you find something wrong with my codes.  My codes are as follows:
>
>
> %%preprocessing 40 subjects
> nsubjects = [1:40];
> for i=1:length (nsubjects)
>     j = nsubjects(i);
>     cfg = [];
>     cfg.dataset = sprintf('s%d-epoch-bsline.eeg', j);
>     cfg.trialdef.eventtype = 'trial';
>     cfg.trialdef.eventvalue = [14]; %markers
>     cfg = ft_definetrial(cfg);
>     cfg.channel    = {'all'};
>     data_14 = ft_preprocessing(cfg);
>
>     cfg.trialdef.eventvalue = [24]; %markers
>     cfg = ft_definetrial(cfg);
>     cfg.channel    = {'all'};
>     data_24 = ft_preprocessing(cfg);
>
>     cfg.trialdef.eventvalue = [34]; %markers
>     cfg = ft_definetrial(cfg);
>     cfg.channel    = {'all'};
>     data_34 = ft_preprocessing(cfg);
>
>     cfg.trialdef.eventvalue = [44]; %markers
>     cfg = ft_definetrial(cfg);
>     cfg.channel    = {'all'};
>     data_44 = ft_preprocessing(cfg);
>
>     outfil = strcat('/EEG/data_s', sprintf('%02d', j));
>     save(outfil, 'data_14','data_24','data_34','data_44');
>     clear data_14* data_24* data_34* data_44*;
> end
> %% calculate the ERP of each subject
> nsubject = [1:40];
>
> for i=1:length (nsubject)
>     j=nsubject(1,i);
>     load (sprintf('/EEG/data_s%02d',j));
>
>     cfg = [];
>     cfg.latency = [-0.2 1.0];
>     cfg.covariance = 'no';
>     cfg.blcovariance = 'no';
>
>     avg_14=ft_timelockanalysis(cfg,data_14);
>     avg_24=ft_timelockanalysis(cfg,data_24);
>     avg_34=ft_timelockanalysis(cfg,data_34);
>     avg_44=ft_timelockanalysis(cfg,data_44);
>
>     cfg = [];
>     cfg.baseline = [-0.2 0];
>     cfg.baselinetype = 'absolute';
>     base_14= ft_timelockbaseline(cfg, avg_14);
>     base_24= ft_timelockbaseline(cfg, avg_24);
>     base_34= ft_timelockbaseline(cfg, avg_34);
>     base_44= ft_timelockbaseline(cfg, avg_44);
>
>     outfil = strcat('/EEG/baseERP_resp_s', sprintf('%02d', j));
>     save(outfil, 'base_14', 'base_24', 'base_34', 'base_44','avg_14', 'avg_24', 'avg_34','avg_44');
>     clear avg* data*;
> end
> %% calculate the grand average of the 40 subjects
> %%grand average
> cfg = [];
> nsubject = [1:40];
>
> for i=1:length (nsubject)
>     j=nsubject(1,i);
>     load(sprintf('/EEG/baseERP_resp_s%02d',j));
>
>     sub_14(i).ERP= avg_14;
>     sub_24(i).ERP= avg_24;
>     sub_34(i).ERP= avg_34;
>     sub_44(i).ERP= avg_44;
>     clear avg*
> end
>
> grandavg_14 = ft_timelockgrandaverage(cfg, sub_14(:).ERP); %C
> grandavg_24 = ft_timelockgrandaverage(cfg, sub_24(:).ERP); %Refer
> grandavg_34 = ft_timelockgrandaverage(cfg, sub_34(:).ERP); %Semantic
> grandavg_44 = ft_timelockgrandaverage(cfg, sub_44(:).ERP); %Double
>
> outfil = strcat('/EEG/n40_grandavgERP_resp');
> save(outfil, 'grandavg_14', 'grandavg_24', 'grandavg_34', 'grandavg_44');
> %%plotting
> load /EEG/n40_grandavgERP_resp;
>
> cfg = [];
> cfg.layout = 'EEG1010.lay';
> cfg.xlim = [-0.2 1.0];
>
> cfg.baseline = 'no';
> cfg.interactive = 'no';
> cfg.showlabels = 'yes';
> cfg.colorbar = 'yes';
>
> figure;
> ft_multiplotER(cfg,grandavg_14, grandavg_24, grandavg_34, grandavg_44);
>
>
> --
> Lin Cai
> Department of Psychology, Peking University, Beijing 100871, P.R.China
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip




More information about the fieldtrip mailing list