[FieldTrip] Grand Average on time lock data

Eelke Spaak eelke.spaak at donders.ru.nl
Mon Sep 1 09:28:21 CEST 2014


Dear Emilie,

If you assign the return value of MATLAB's load() to a variable, that
variable will become a struct with the variables in the specified
mat-file as its fields. In your case avgs{k} will probably (have not
read your script very thoroughly) be a struct, so avgs{k}.avgFC is the
actual timelock structure. You should replace

avgs{iFile} = load(datafiles{iFile});

with

tmp = load(datafiles{iFile});
avgs{iFile} = tmp.avgFC;

and then I think it should work.

Best,
Eelke

On 1 September 2014 09:02, Caspar, Emilie <e.caspar at ucl.ac.uk> wrote:
> Dear all,
>
>
> I would like to perform the grand average in a separate script than the
> preprocessing one, to avoid a crash, because of the number of participants.
> In the preprocessing script, I performed a timelockanalysis for each
> participants : avgFC = ft_timelockanalysis(cfg, cleandata);
> and then save this file :
> finfname  = [subjID{s} '_RP'];
> mkdir(subjID{s})
> save([subjPath filesep finfname '.mat'], 'avgFC');
>
>
> So, in my grand average script, I wrote the following :
>
> cfg = [];
> homePath    = '/Users/emilie/Desktop/EEG_RP/Grandaverage/';
> eegPath = homePath;
>
>
>
> %% Subjects
> datafiles      =
> {'S83_RP','S84_RP','S85_RP','S87_RP','S88_RP','S89_RP','S90_RP','S91_RP','S92_RP','S93_RP','S94_RP','S97_RP','S98_RP','S99_RP','S100_RP',
> 'S101_RP'};
> nFiles      = length(datafiles);
> avgs = cell(1,nFiles);
>
>
>
> cfg.channel   = 'all';
> cfg.latency   = 'all';
> %cfg.parameter = 'avg';
>
>
>
> for iFile = 1:nFiles
>     thisfile = datafiles{iFile};
>     subjPath = [eegPath  thisfile];
>     file = dir([subjPath  '*.mat']);
>     avgs{iFile} = ft_checkdata(avgs{iFile}, 'datatype', 'timelock',
> 'feedback', 'no');
>     avgs{iFile} = load(datafiles{iFile});
> end
>
>
>
> GA = ft_timelockgrandaverage(cfg, avgs{:});
>
> But I'm not pretty sure to understand the error message :
> Error using ft_checkdata (line 366)
> This function requires timelock data as input.
>
> Error in Averaging (line 33)
>     avgs{iFile} = ft_checkdata(avgs{iFile}, 'datatype', 'timelock',
> 'feedback', 'no');
>
> Because If I'm right, the files in 'datafiles' are the time locked data from
> the preprocessing script.
>
> Thank you,
>
> Emilie
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip



More information about the fieldtrip mailing list