avgPerFrameNatMovies.m 1.3 KB

12345678910111213141516171819202122232425262728
  1. function [membranPotAVG]=avgPerFrameNatMovies ...
  2. (membranePot,ttls_ms,MovieFrames,Hz)
  3. %function [membranPotAVG]=avgPerFrameNatMovies ...
  4. % (membranePot,ttls_ms,MovieFrames,Hz)
  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. % Hz -> update rate in excel file
  10. %
  11. % OUTPUT: membranPotAVG -> average membrane potential per frames
  12. %make the average membrane potential between two stimulus frames
  13. membranPotAVG=zeros(MovieFrames,size(ttls_ms,2));
  14. for jj=1:size(ttls_ms,2) %nbr of trials
  15. for kk=1:size(ttls_ms,1) % nbr of frames
  16. if kk==size(ttls_ms,1) %for the last frame
  17. membranPotAVG(kk,jj)=mean(membranePot(ttls_ms(kk,jj) ...
  18. :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.
  19. else
  20. membranPotAVG(kk,jj)=mean(membranePot(ttls_ms(kk,jj) ...
  21. :(ttls_ms(kk+1,jj)-1))); %detail: -1ms because the next ms is already the start of the new stimulus frame
  22. end
  23. end
  24. end
  25. end