123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- function [mdat nevt tim evt] = getevents(actname)
- %tmp=load([actname '.mat']);
- %mdat=tmp.mdat;
- load([actname '.mat']);
- tmp=mdat.evt;
- evt=zeros(length(tmp),1);
- for i=1:length(tmp)
- if isempty(str2num(tmp{i}))
- evt(i)=NaN;
- else
- evt(i)=str2num(tmp{i});
- end
- end
- tim=mdat.evT;
-
- nevt=zeros(length(tmp),3);
- ori1=NaN; ori2=NaN; cori=NaN; cued=NaN; ncued=NaN; task=NaN; pos1=NaN; pos2=NaN; cpos=NaN; ncpos=NaN;
- stim1=NaN; stim2=NaN; cstim=NaN; ncstim=NaN; pos3=NaN; ori3=NaN;
- pingcount=0; tricount=0; fix=1;
- for i=1:length(evt)
- if ismember(evt(i),[20:76]) % first stim
- tricount=tricount+1;
- ori1=rem(evt(i),20); % first stim ori
- if ismember(evt(i),[21:36])
- stim1=1;
- elseif ismember(evt(i),[41:56])
- stim1=2;
- elseif ismember(evt(i),[61:76])
- stim1=3;
- end
- if i<length(evt) & ismember(evt(i+1),91:106)
- pos1=rem(evt(i+1)-10,20);
- end
- end
- if ismember(evt(i),[120:176]) % second stim
- ori2=rem(evt(i),20); % second stim ori
- if ismember(evt(i),[121:136])
- stim2=1;
- elseif ismember(evt(i),[141:156])
- stim2=2;
- elseif ismember(evt(i),[161:176])
- stim2=3;
- end
- if i<length(evt) & ismember(evt(i+1),91:106)
- pos2=rem(evt(i+1)-10,20);
- end
- end
- if evt(i)==1
- cued=1;
- cori=ori1;
- ncori=ori2;
- cstim=stim1;
- ncstim=stim2;
- cpos=pos1;
- ncpos=pos2;
- elseif evt(i)==2
- cued=2;
- cori=ori2;
- ncori=ori1;
- cstim=stim2;
- ncstim=stim1;
- cpos=pos2;
- ncpos=pos1;
- end
- if evt(i)==3;
- task=1;
- elseif evt(i)==4;
- task=2;
- end
- if ismember(evt(i),[232]) % off-fixation [100 200 232]
- fix=1;
- end
- if ismember(evt(i),[230 231])
- pingcount=pingcount+1;
- end
-
- if ismember(evt(i),[201:216])
- ori3=rem(evt(i),20);
- if ismember(evt(i-1),91:106)
- pos3=rem(evt(i-1)-10,20);
- end
- end
-
- if fix==1 & ~isnan(ori1) & ~isnan(ori2) % & ~isnan(ori3) %& ~isnan(stim1) & ~isnan(stim2)% & cued==2
-
-
- % if ismember(evt(i),[230 231]) % & pingcount<3 % & ismember(evt(i-4),[3 4]);
- % % if ismember(evt(i),[201:221]);
- % nevt(i,1)=1000+cpos;
- %
- % % nevt(i,1)=1000+cori;
- % % nevt(i,2)=1000+ncori;
- % % nevt(i,3)=1000+ncori;
- %
- % end
- %use this also for simple within/between
- if ismember(evt(i),[1]) % & cued==1
- nevt(i,ncstim)=1000+ncori;
- end
- % if ismember(evt(i),[1 2])% & cued==2% for X2
- % nevt(i,stim1)=1000+ori1;
- % nevt(i,stim2)=2000+ori2;
- % end
-
- % if ismember(evt(i),[1 2]) % & task==2% for X2
- % nevt(i,cstim)=1000+cori;
- % nevt(i,ncstim)=2000+ncori;
- % end
-
- % if ismember(evt(i),[20:76])%
- % %if ismember(evt(i),[201:221]);
- % nevt(i,stim1)=1000+ori1;
- % end
- % if ismember(evt(i),[120:176])%
- % %if ismember(evt(i),[201:221]);
- % nevt(i,stim2)=1000+ori2;
- % end
- % if ismember(evt(i),[1 2]) % & cued==2
- % %if ismember(evt(i),[201:221]);
- % % nevt(i,1)=1000+pos1;
- % % nevt(i,2)=1000+pos2;
- % % nevt(i,3)=1000+pos2;
- % nevt(i,1)=1000+ori1;
- % nevt(i,2)=1000+ori2;
- % nevt(i,3)=1000+ori2;
- % end
- %
- % if ismember(evt(i),[1 2]) %& task==1%
- % % nevt(i,cstim)=1000+cori;
- % nevt(i,1)=1000+cori;
- % nevt(i,2)=1000+ncori;
- % nevt(i,3)=1000+ncori;
- % end
- % if ismember(evt(i),[120:176]) % for 16 x16
- % nevt(i,1)=1000+ceil([ori2]./2);
- % nevt(i,2)=1000+ceil([ori1]./2);
- % nevt(i,3)=1000+ceil([ori1]./2);
- % end
- if ismember(evt(i),[201:221])
- % nevt(i,cstim)=1000+cori;
- fix=1;
- pingcount=0;
- ori1=NaN; ori2=NaN; cori=NaN; cued=NaN; ncued=NaN; task=NaN; pos1=NaN; pos2=NaN; cpos=NaN; ncpos=NaN;
- stim1=NaN; stim2=NaN; cstim=NaN; ncstim=NaN; pos3=NaN; ori3=NaN;
- end
-
- % if tricount==576
- % break
- % end
- end
-
- end
-
- end
|