avgPerFrameNatMovies.m 1.2 KB

123456789101112131415161718192021222324252627
  1. function [membranPotAVG]=avgPerFrameNatMovies ...
  2. (membranePot,ttls_ms,MovieFrames,Hz)
  3. %function [membranPotAVG]=avgPerFrameNatMovies ...
  4. % (membranePot,ttls_ms_correctedPulse)
  5. %builds the average membrane potential between frames for the natural movie
  6. % INPUT: membranePos -> membrane Potential
  7. % ttls_ms -> pulses in ms
  8. % MovieFrames -> number of frames per movie
  9. %
  10. % OUTPUT: membranPotAVG -> average membrane potential per frames
  11. %make the average membrane potential between two stimulus frames
  12. membranPotAVG=zeros(MovieFrames,size(ttls_ms,2));
  13. for jj=1:size(ttls_ms,2) %nbr of trials
  14. for kk=1:size(ttls_ms,1) % nbr of frames
  15. if kk==size(ttls_ms,1) %for the last frame
  16. membranPotAVG(kk,jj)=mean(membranePot(ttls_ms(kk,jj) ...
  17. :ttls_ms(kk,jj)+floor(1000/Hz)-1)); %because you dont have the pulse for when the frame ends, take the 40ms after the last frame to include the response to that frame.
  18. else
  19. membranPotAVG(kk,jj)=mean(membranePot(ttls_ms(kk,jj) ...
  20. :(ttls_ms(kk+1,jj)-1))); %detail: -1ms because the next ms is already the start of the new stimulus frame
  21. end
  22. end
  23. end
  24. end