buildSTA.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334
  1. function [STA_mean_normalized,STA_mean]=buildSTA ...
  2. (stim_signal,membraneP,STA_fnbr)
  3. % [STA_mean_normalized,STA_mean]=buildSTA ...
  4. % (stim_signal,membraneP,STA_fnbr)
  5. %is getting the contrast value that happen before each response
  6. %and multiplies them with the average membrane Potential per frame.
  7. % INPUT: stim_signal -> stimulus signal containing the contrast values in 2D
  8. % membraneP -> membrane potential average per frame
  9. % STA_fnbr -> nbr of frames you go back in time
  10. % OUTPUT: STA_mean_normalized -> normalized STA, relevant for
  11. % computing the NL
  12. % STA_mean -> not normalized STA
  13. %------------------------------------------------------------------------------------------
  14. %% 1. Loop over all membrane potential values
  15. STA_fnbr=STA_fnbr-1; %the first value is one frame, so to take exactly 10 frames, substract one here.
  16. for kk=1:length(membraneP)-(STA_fnbr)
  17. if kk==1
  18. signal1=membraneP(kk+(STA_fnbr))*stim_signal(:,kk:kk+(STA_fnbr)); %multiply the average values with the stimulus signal before; it start now from 1 and goes until the element kk
  19. else
  20. signal2=membraneP(kk+(STA_fnbr))*stim_signal(:,kk:kk+(STA_fnbr)); %multiply the average values with the stimulus signal before
  21. signal1=signal1+signal2; %make the sum to get the average at the end
  22. clear signal2;
  23. end
  24. end
  25. %build the average
  26. STA_mean=signal1/length(1:length(membraneP)-(STA_fnbr)); %not normalized
  27. %normalize
  28. STA_mean_normalized = STA_mean(:) / sqrt(sum(STA_mean(:).*STA_mean(:))); %relevant for computing the NL
  29. STA_mean_normalized=reshape(STA_mean_normalized,size(STA_mean));
  30. end