how to create data structure

Christian Hesse c.hesse at FCDONDERS.RU.NL
Mon Feb 26 18:47:58 CET 2007

Hi Shantanu

> My data is  116384 datapoints long sampled at 115.34 Hz.
> I can load my data data structure not in FT list)from single
> subject in a
> single recording session( in matlab workspace and implement the
> following
> code as suggested:
> data = [];
>> data.fsample = 115.34
>> data.label = {'Fz';'Fp1'; ... 'Oz'};
>> data.trial = cell(Ntrial,1);
>>  for i=1:Ntrial
>> 	data.trial{i} = 24 x 40
>>  end
> However, at the prompt it says:
> Data structure not compatible. Error in matrix location or matrix
> dimension.

comment 1:
the data structure also needs a (local) time axis for each trial:

data.time = cell(Ntrial,1)
for i=1:Ntrial
	data.time{i} = [trial_start:dt:trial_stop];
	% trial_start could be -1.5 seconds
	% trial_stop could be 3.0 seconds
	% dt = 1./data.fsample;

> My question is, how do you create the Nchan (=24) X NTrialSamp (=
> 40 trials)
> matrix from continuous data?

comment 2:
NTrialSamp is NOT the number of trials (NTrial = 40) but instead
refers to the "Number_of_time_samples_per_trial" which is determined
by the duration of the trial in seconds (TrialDuration) and your
sampling frequency FSample:

NTrialSamp = TrialDuration*FSample;
% this can in principle be different for each trial

% so you have
data.trial = cell(Ntrial,1)
for i=1:Ntrial
	data.trial{i} = X;
	% where X is a Nchan x NTrialSamp matrix containing the data from
each trial

comment 3:
Your question essentially is: How do youI get X from what you have
read into Matlab?

To answer this, you need to tell me what sort of variable your data
are stored in once they have been read into Matlab. You can load your
data in and then type "whos" at the command prompts and email me what
is displayed on the screen after you press <ENTER>

Kind Regards,

Christian Hesse, PhD, MIEEE

F.C. Donders Centre for Cognitive Neuroimaging
P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Tel.: +31 (0)24 36 68293
Fax: +31 (0)24 36 10989

Email: c.hesse at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the fieldtrip mailing list