getTimewinsPoolSpikeSeqs.m 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. function pooltwspksq = getTimewinsPoolSpikeSeqs(poolstackvars,poolstackspks)
  2. if nargin<2
  3. subjsData(1).sbdata=getSubjectData(1);
  4. subjsData(2).sbdata=getSubjectData(2);
  5. poolstackspks=getPoolStackSpks(subjsData);
  6. if nargin<1
  7. poolstackvars=getPoolStackVars(subjsData);
  8. end
  9. end
  10. Nsns=size(poolstackspks,1);
  11. Ntws=size(poolstackspks,2);
  12. Ncells=arrayfun(@(sn) poolstackvars(sn).ncells, 1:Nsns);
  13. Ntrs=arrayfun(@(sn) size(poolstackvars(sn).offer1sd,1),1:Nsns);
  14. Ntps=arrayfun(@(tw) max(arrayfun(@(sn) size(poolstackspks(sn,tw).spksq,3), 1:8)),1:8);
  15. Ntrs12=max(Ntrs);
  16. pooltwspksq(1:8)=struct();
  17. for tw=1:Ntws
  18. currcatspkseqs=[];
  19. for sn=1:Nsns
  20. currNtps=size(poolstackspks(sn,tw).spksq,3);
  21. currcatspkseqs=cat(2, currcatspkseqs, ...
  22. cat(1, cat(3,poolstackspks(sn,tw).spksq,nan(Ntrs(sn),Ncells(sn),Ntps(tw)-currNtps)), nan(Ntrs12-Ntrs(sn),Ncells(sn),Ntps(tw))));
  23. end
  24. pooltwspksq(tw).spkseqs=currcatspkseqs;
  25. tempspks=permute(currcatspkseqs,[3 1 2]);
  26. pooltwspksq(tw).covhist=sum(~isnan(tempspks(:,:)),2)./sum(Ncells.*Ntrs);
  27. end
  28. end