123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- function [behinfos] = getBehavioralInfos(subjdata,sesn)
- if nargin < 2
- if nargin< 1
- error('Provide subject data.');
- end
- sesn='all';
- end
- if strcmpi(sesn,'all')
- sesn=1:length(subjdata);
- end
- behinfos.ntrials=arrayfun(@(sn) size(subjdata{sn}.spikeseqs,1), sesn);
- behinfos.ncells=arrayfun(@(sn) size(subjdata{sn}.spikeseqs,2), sesn);
- catoffer1pr=[]; catoffer1rw=[]; catoffer1ev=[];
- catoffer2pr=[]; catoffer2rw=[]; catoffer2ev=[];
- catoffer1sd=[]; catchooseLR=[]; catchoose12=[];
- catexperrew=[];
- % #1 offer1 prob
- % #2 offer1 value (nominal units)
- % #3 offer1 EV
- % #4 offer2 prob
- % #5 offer2 value (nominal units)
- % #6 offer2 EV
- % #7 offer1 side (1=L, 2=R)
- % #8 chosen side (1=L, 2=R)
- % #9 chosen offer (1=1st, 2=2nd)
- % #10 experienced reward
- for sn=sesn
- catoffer1pr=cat(1,catoffer1pr,subjdata{sn}.behavior(:,1));
- catoffer1rw=cat(1,catoffer1rw,subjdata{sn}.behavior(:,2));
- catoffer1ev=cat(1,catoffer1ev,subjdata{sn}.behavior(:,1).*((subjdata{sn}.behavior(:,2)==1)+...
- (subjdata{sn}.behavior(:,2)==2).*2+...
- (subjdata{sn}.behavior(:,2)==3).*3));
- catoffer2pr=cat(1,catoffer2pr,subjdata{sn}.behavior(:,4));
- catoffer2rw=cat(1,catoffer2rw,subjdata{sn}.behavior(:,5));
- catoffer2ev=cat(1,catoffer2ev,subjdata{sn}.behavior(:,4).*((subjdata{sn}.behavior(:,5)==1)+...
- (subjdata{sn}.behavior(:,5)==2).*2+...
- (subjdata{sn}.behavior(:,5)==3).*3));
- catoffer1sd=cat(1,catoffer1sd,subjdata{sn}.behavior(:,7));
- catchooseLR=cat(1,catchooseLR,subjdata{sn}.behavior(:,8));
- catchoose12=cat(1,catchoose12,subjdata{sn}.behavior(:,9));
- catexperrew=cat(1,catexperrew,subjdata{sn}.behavior(:,10));
- end
- % unqexprr=unique(catexperrew);
- % catexperrew(catexperrew==unqexprr(1))=0;
- % catexperrew(catexperrew==unqexprr(2))=1;
- % catexperrew(catexperrew==unqexprr(3))=2;
- % catexperrew(catexperrew==unqexprr(4))=3;
- behinfos.offer1pr=catoffer1pr;
- behinfos.offer1rw=catoffer1rw;
- behinfos.offer1ev=catoffer1ev;
- behinfos.offer2pr=catoffer2pr;
- behinfos.offer2rw=catoffer2rw;
- behinfos.offer2ev=catoffer2ev;
- behinfos.choose12=catchoose12;
- behinfos.chooseLR=catchooseLR;
- behinfos.offer1sd=catoffer1sd; %offer1sd==1 means 1st offer is LEFT
- behinfos.experrew=catexperrew;
- behinfos.offer1var=behinfos.offer1pr.*(1-behinfos.offer1pr).*behinfos.offer1rw;
- behinfos.offer2var=behinfos.offer2pr.*(1-behinfos.offer2pr).*behinfos.offer2rw;
- behinfos.offerLev=behinfos.offer1ev.*(behinfos.offer1sd==1)+behinfos.offer2ev.*(behinfos.offer1sd==2);
- behinfos.offerRev=behinfos.offer2ev.*(behinfos.offer1sd==1)+behinfos.offer1ev.*(behinfos.offer1sd==2);
- behinfos.offerLvar=behinfos.offer1var.*(behinfos.offer1sd==1)+behinfos.offer2var.*(behinfos.offer1sd==2);
- behinfos.offerRvar=behinfos.offer2var.*(behinfos.offer1sd==1)+behinfos.offer1var.*(behinfos.offer1sd==2);
- % retrieve indices of trials first left, second right and first right second left
- behinfos.i1L1R=(behinfos.offer1rw==1 & behinfos.offer2rw==1 & behinfos.offer1sd==1);
- behinfos.i1L2R=(behinfos.offer1rw==1 & behinfos.offer2rw==2 & behinfos.offer1sd==1);
- behinfos.i1L3R=(behinfos.offer1rw==1 & behinfos.offer2rw==3 & behinfos.offer1sd==1);
- behinfos.i2L1R=(behinfos.offer1rw==2 & behinfos.offer2rw==1 & behinfos.offer1sd==1);
- behinfos.i2L2R=(behinfos.offer1rw==2 & behinfos.offer2rw==2 & behinfos.offer1sd==1);
- behinfos.i2L3R=(behinfos.offer1rw==2 & behinfos.offer2rw==3 & behinfos.offer1sd==1);
- behinfos.i3L1R=(behinfos.offer1rw==3 & behinfos.offer2rw==1 & behinfos.offer1sd==1);
- behinfos.i3L2R=(behinfos.offer1rw==3 & behinfos.offer2rw==2 & behinfos.offer1sd==1);
- behinfos.i3L3R=(behinfos.offer1rw==3 & behinfos.offer2rw==3 & behinfos.offer1sd==1);
- behinfos.i1R1L=(behinfos.offer1rw==1 & behinfos.offer2rw==1 & behinfos.offer1sd==2);
- behinfos.i1R2L=(behinfos.offer1rw==1 & behinfos.offer2rw==2 & behinfos.offer1sd==2);
- behinfos.i1R3L=(behinfos.offer1rw==1 & behinfos.offer2rw==3 & behinfos.offer1sd==2);
- behinfos.i2R1L=(behinfos.offer1rw==2 & behinfos.offer2rw==1 & behinfos.offer1sd==2);
- behinfos.i2R2L=(behinfos.offer1rw==2 & behinfos.offer2rw==2 & behinfos.offer1sd==2);
- behinfos.i2R3L=(behinfos.offer1rw==2 & behinfos.offer2rw==3 & behinfos.offer1sd==2);
- behinfos.i3R1L=(behinfos.offer1rw==3 & behinfos.offer2rw==1 & behinfos.offer1sd==2);
- behinfos.i3R2L=(behinfos.offer1rw==3 & behinfos.offer2rw==2 & behinfos.offer1sd==2);
- behinfos.i3R3L=(behinfos.offer1rw==3 & behinfos.offer2rw==3 & behinfos.offer1sd==2);
- behinfos.ifLsR=[find(behinfos.i1L1R); find(behinfos.i1L2R); find(behinfos.i1L3R);...
- find(behinfos.i2L1R); find(behinfos.i2L2R); find(behinfos.i2L3R);...
- find(behinfos.i3L1R); find(behinfos.i3L2R); find(behinfos.i3L3R)];
- behinfos.ifRsL=[find(behinfos.i1R1L); find(behinfos.i1R2L); find(behinfos.i1R3L);...
- find(behinfos.i2R1L); find(behinfos.i2R2L); find(behinfos.i2R3L);...
- find(behinfos.i3R1L); find(behinfos.i3R2L); find(behinfos.i3R3L)];
-
- % retrieve indices of trials with chosen offer (1=safe, 2=medium, 3=large)
- i1L23R=[find(behinfos.i1L2R); find(behinfos.i1L3R)];
- i23L1R=[find(behinfos.i2L1R); find(behinfos.i3L1R)];
- i1R23L=[find(behinfos.i1R2L); find(behinfos.i1R3L)];
- i23R1L=[find(behinfos.i2R1L); find(behinfos.i3R1L)];
- behinfos.ioff1L=[find(behinfos.i1L1R); i1L23R];
- behinfos.ioff1R=[find(behinfos.i1R1L); i1R23L];
- i1L23R(behinfos.choose12(i1L23R)==2)=[];
- i23L1R(behinfos.choose12(i23L1R)==1)=[];
- i1R23L(behinfos.choose12(i1R23L)==2)=[];
- i23R1L(behinfos.choose12(i23R1L)==1)=[];
- behinfos.ichn1L=[find(behinfos.i1L1R); i1L23R; i23R1L];
- behinfos.ichn1R=[find(behinfos.i1R1L); i1R23L; i23L1R];
- i2L13R=[find(behinfos.i2L1R); find(behinfos.i2L3R)];
- i13L2R=[find(behinfos.i1L2R); find(behinfos.i3L2R)];
- i2R13L=[find(behinfos.i2R1L); find(behinfos.i2R3L)];
- i13R2L=[find(behinfos.i1R2L); find(behinfos.i3R2L)];
- behinfos.ioff2L=[i2L13R; find(behinfos.i2L2R); i13R2L];
- behinfos.ioff2R=[i2R13L; find(behinfos.i2R2L); i13L2R];
- i2L13R(behinfos.choose12(i2L13R)==2)=[];
- i13L2R(behinfos.choose12(i13L2R)==1)=[];
- i2R13L(behinfos.choose12(i2R13L)==2)=[];
- i13R2L(behinfos.choose12(i13R2L)==1)=[];
- behinfos.ichn2L=[i2L13R; find(behinfos.i2L2R); i13R2L];
- behinfos.ichn2R=[i2R13L; find(behinfos.i2R2L); i13L2R];
- i3L12R=[find(behinfos.i3L1R); find(behinfos.i3L2R)];
- i12L3R=[find(behinfos.i1L3R); find(behinfos.i2L3R)];
- i3R12L=[find(behinfos.i3R1L); find(behinfos.i3R2L)];
- i12R3L=[find(behinfos.i1R3L); find(behinfos.i2R3L)];
- behinfos.ioff3L=[i3L12R; i12R3L; find(behinfos.i3L3R)];
- behinfos.ioff3R=[i3R12L; i12L3R; find(behinfos.i3R3L)];
- i3L12R(behinfos.choose12(i3L12R)==2)=[];
- i12L3R(behinfos.choose12(i12L3R)==1)=[];
- i3R12L(behinfos.choose12(i3R12L)==2)=[];
- i12R3L(behinfos.choose12(i12R3L)==1)=[];
- behinfos.ichn3L=[i3L12R; i12R3L; find(behinfos.i3L3R)];
- behinfos.ichn3R=[i3R12L; i12L3R; find(behinfos.i3R3L)];
- % this last check was for temp debugging but ok
- if ~ (length(behinfos.choose12) == (length([behinfos.ichn1L; behinfos.ichn1R; behinfos.ichn2L; behinfos.ichn2R; behinfos.ichn3L; behinfos.ichn3R])))
- error('behavioral data show incongruencies in accessing the actual chosen magnitudes');
- end
- end
|