Overlapping trials

Natalia Grion grion at SISSA.IT
Tue Jul 8 16:56:47 CEST 2008


Hi Thomas and All,
well this are recordings from freely moving rats with neuralynx system.
By the way I'm defining trials, yes, they have variable length: I'm
taking 3sec before the central beam is triggered (this is indicative of
stimulus "on" = start trigger), till the trigger of the 2nd beam is
trigger (reward trigger), even if they have a regular behaviour from
trial to trial, sometimes they are faster. Start trigger is stored in a
separate file as EventTimeTrigger, this event is a TimeStamp, Reward
Trigger is stored in an external file (txt file) generated by labview
(software that commands the maze). Timestamps are generated by the
recording system(microseconds).  Every LFP sample has an associated
timestamp and this forms the time axis,  knowing the EventTimeStamp i
can take the 'n' samples before this event and/or after, in my case time
taken 'after' depends on how long the rat took to trigger the Reward
beam  (ellapsed time). This is my function (main part):

function [trl]=trialfunNG(cfg)
*% get the inter-timestamp time from the header*
hdr=read_fcdc_header(cfg.datadir);
nlfpsamplespersec=hdr.Fs;

*% read the timestamps of the events in the Neuralynx stimulus channel
(the .nev-file in cfg.datadir)*
events=read_fcdc_event(cfg.datadir);
eventlfpsamples=[events(:).sample]';

*% read the stimulus and behavioral information in the external
file....info about stimulus, correct\incorrect trials etc*
stimbehdata=dlmread(cfg.extstimbehfile,'\t',1,1);
*....*
nlfpsamplesprestimbeamcrossing=cfg.prestimbeam*nlfpsamplespersec;

if ischar(cfg.poststimbeam) && strcmp(cfg.poststimbeam,'respbeam')
*%this respbeam is taken from the txt file*
  rtinmsec=stimbehdata(selvec,6);
  triallengthinlfpsamples=(rtinmsec/1000)*nlfpsamplespersec;
else
  triallengthinlfpsamples=cfg.poststimbeam*nlfpsamplespersec;
end;

trl=zeros(nseltrials,3);
trl(:,1)=eventlfpsamples(selvec)-nlfpsamplesprestimbeamcrossing;
trl(:,2)=eventlfpsamples(selvec)+triallengthinlfpsamples;
trl(:,3)=-nlfpsamplesprestimbeamcrossing;

I don't know till this point if I'm missing sth from Nlx, or is a bug
generated by the way fieldtrip is picking up my data. One solution I
thought,  would be to write a conditional statement for skipping these
trials, but, as the error comes up from read_data. I'd like to know how
to introduce it.
Thanks again
Natalia




Thomas Dijkman wrote:
> Hi Natalia,
>
> Your error seems te originate from this line: dat = ncs.dat(begsample:endsample); Either the begsample variable or the endsample variable isn't a positive number. As you probably know, matlab starts counting with 1 for vector and matrix indices. Since you mention the error doesn't come up when you take a trial 2 sec instead of 3 sec before the prestimbeam, my guess is that he sample index of the prestimbeam is more than 2 sec * samplefreq, but less then 3 sec * samplefreq.
> Perhaps you could elaborate a bit further about your experimental setup? All your trials have a different duration?
> I hope this helps,
>
> Thomas Dijkman
>
>
> -----Oorspronkelijk bericht-----
> Van: FieldTrip discussion list namens Natalia Grion
> Verzonden: di 8-7-2008 11:50
> Aan: FIELDTRIP at NIC.SURFNET.NL
> Onderwerp: [FIELDTRIP] Overlapping trials
>
> Dear All,
> During reading and preprocessing lfps,  I find this error for some trials:
>
> ?? Subscript indices must either be real positive integers or logicals.
> *Error in ==> read_data at 576
>            dat = ncs.dat(begsample:endsample);*
> Error in ==> read_fcdc_data at 49
> [dat] = read_data(varargin{:});
> Error in ==> preprocessing at 554
>     dat = read_fcdc_data(cfg.datafile, hdr, begsample, endsample,
> rawindx, strcmp(cfg.continuous,
>     'yes'));
> Error in ==> FreqAnalysis at 51
>   datar{chanindx}=preprocessing(cfgpreproc)
>
> Trials are defined by 2 trigger beams, first trigger defines the start
> of the trial, and 2nd trigger beam: the reward time (which is variable).
> I'm taking smaples in this way: prestimbeam: 3 sec before "start
> trigger", and poststimbeam = time till trigger of reward. I pretty sure
> this error appears when prestimbeam is overlapping with the  previous
> poststimbeam (actually, taking  2sec before start trigger error doesn't
> come up).   Do you have any suggestion of how i could introduce i
> conditional statement for skipping these trials?  I guess this statement
> has to be written is "read_data" function, right?
> Thanks!
> Natalia Grion
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
>

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.



More information about the fieldtrip mailing list