12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- function [spkdata] = getSpikeSequences(subjdata,sesn,timeStartAlgn,timeEndAlgn)
- if nargin < 4
- if nargin < 3
- if nargin < 2
- if nargin< 1
- error('Provide subject data.');
- end
- sesn='all';
- end
- timeStartAlgn='offer1';
- end
- timeEndAlgn='choicemade';
- end
- if strcmpi(sesn,'all')
- sesn=1:length(subjdata);
- end
- spkdata_str{sesn}.spikeseqs=[];
- for sn=sesn
- for tr=1:size(subjdata{sn}.spikeseqs,1)
- curroff1ref=round(subjdata{sn}.timings(tr).appearOffer1Time);
-
- if strcmpi(timeStartAlgn,'offer1')
- timeStartBin=0;
- elseif strcmpi(timeStartAlgn,'delay1')
- timeStartBin=round(subjdata{sn}.timings(tr).disappearOffer1Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'offer2')
- timeStartBin=round(subjdata{sn}.timings(tr).appearOffer2Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'delay2')
- timeStartBin=round(subjdata{sn}.timings(tr).disappearOffer2Time)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'fixdot')
- timeStartBin=round(subjdata{sn}.timings(tr).appearFixDotTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicego')
- timeStartBin=round(subjdata{sn}.timings(tr).choiceGoTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'feedback')
- timeStartBin=round(subjdata{sn}.timings(tr).feedbackTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'startfix')
- timeStartBin=round(subjdata{sn}.timings(tr).fixStartFixnDotTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicemade')
- timeStartBin=round(subjdata{sn}.timings(tr).choiceMadeTime)-curroff1ref;
- elseif strcmpi(timeStartAlgn,'choicesacc')
- timeStartBin=round(min([subjdata{sn}.timings(tr).fixStartRightOfferTime subjdata{sn}.timings(tr).fixStartLeftOfferTime]))-curroff1ref;
- elseif strcmpi(timeStartAlgn,'preoffer1')
- timeStartBin=-3000;
- end
-
-
- if strcmpi(timeEndAlgn,'offer1')
- timeEndBin=0;
- elseif strcmpi(timeEndAlgn,'delay1')
- timeEndBin=round(subjdata{sn}.timings(tr).disappearOffer1Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'offer2')
- timeEndBin=round(subjdata{sn}.timings(tr).appearOffer2Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'delay2')
- timeEndBin=round(subjdata{sn}.timings(tr).disappearOffer2Time)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'fixdot')
- timeEndBin=round(subjdata{sn}.timings(tr).appearFixDotTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicego')
- timeEndBin=round(subjdata{sn}.timings(tr).choiceGoTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'feedback')
- timeEndBin=round(subjdata{sn}.timings(tr).feedbackTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'startfix')
- timeEndBin=round(subjdata{sn}.timings(tr).fixStartFixnDotTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicemade')
- timeEndBin=round(subjdata{sn}.timings(tr).choiceMadeTime)-curroff1ref;
- elseif strcmpi(timeEndAlgn,'choicesacc')
- timeEndBin=round(min([subjdata{sn}.timings(tr).fixStartRightOfferTime subjdata{sn}.timings(tr).fixStartLeftOfferTime]))-curroff1ref;
- elseif strcmpi(timeEndAlgn,'trialend')
- timeEndBin=7000;
- end
-
- currsnspksq{tr}.currtrspksq(:,1:(timeEndBin-timeStartBin))=subjdata{sn}.spikeseqs(tr,:,(timeStartBin+1:timeEndBin)+3000);
- end
- maxntp=max(arrayfun(@(tr) size(currsnspksq{tr}.currtrspksq,2),1:size(currsnspksq,2)));
- spkdata_str{sn}.spikeseqs=nan(size(subjdata{sn}.spikeseqs,1),size(subjdata{sn}.spikeseqs,2),maxntp);
- for tr=1:size(subjdata{sn}.spikeseqs,1)
- spkdata_str{sn}.spikeseqs(tr,:,1:size(currsnspksq{tr}.currtrspksq,2))=currsnspksq{tr}.currtrspksq;
- end
- clearvars currsnspksq
- end
- maxntp=max(arrayfun(@(xx) size(spkdata_str{xx}.spikeseqs,3),sesn));
- spkdata.spikeseqs=[];
- for sn=sesn
- spkdata.spikeseqs=cat(1,spkdata.spikeseqs,cat(3,spkdata_str{sn}.spikeseqs,...
- nan([size(spkdata_str{sn}.spikeseqs,1:2), maxntp-size(spkdata_str{sn}.spikeseqs,3)])));
- end
- spkdata.starttime=timeStartAlgn;
- spkdata.endtime=timeEndAlgn;
- end
|