BC_NL.m 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. function [NL_output]=BC_NL(STA_output)
  2. %[NL_output]=BC_NL(STA_output)
  3. %this function computes the output nonlinearity (NL) from the linear-nonlinear model (LN-model)
  4. %for continous voltage signals of bipolar cells (BC).
  5. %Inputs:
  6. % STA_output = output of the BC_STA function; containing the
  7. % STA and stimulus signal
  8. %
  9. %Outpus: NL_output = structure containing the output nonlinearity
  10. %
  11. %
  12. % Note: the function is built only for cells recorded without frozen frames.
  13. % But additional comments are made for cells with frozen frames.
  14. % code by HS, last modified March 2021
  15. %-------------------------------------------------------------------------------
  16. %% 1. convolve zoom STA with stimulus (to get the generator signal)
  17. %get the linear filter (normalized, see Methods of Schreyer&Gollisch,2021)
  18. linearFiler=normSTA(STA_output.STA2D_zoom);
  19. %get stimulus signal
  20. stimulus=STA_output.stimulus2D_zoom;
  21. %%if you have frozen frames, only the stimulus signal of the running frames
  22. %%is used for the convolution. Also the stimulus signal has to be convolved
  23. %%for each trial of the running noise separately (because it is not a
  24. %%continous signal -> it was interupted by the frozen noise).
  25. %do the convolution with the stimulus signal
  26. generator_signal=filter2(linearFiler,stimulus,'valid');
  27. %%IMPORTANT: if you have a best spatial and temporal component as described in Point 7
  28. %in the function BC_STA.m (see Method of Manuscript), this part hast to be done in two lines, e.g.:
  29. %NL_PredXaxis2=filter2(sp_bestnorm,stimulus,'valid'); %first
  30. %convolve the spatial dimension
  31. %generator_signal=filter2(temp_bestnorm,NL_PredXaxis2,'valid'); %then the
  32. %temporal dimension
  33. %%Also note, to avoid noise contributions from pixels outside the receptive
  34. %%field,it is important to cut the STA into a smaller region around the maximum pixel, this
  35. %%gives a much cleaner NL-> see BC_STA.m and Methods in Schreyer&Gollisch (2021).
  36. %-------------------------------------------------------------------------------
  37. %% 2. get the y axis of the NL
  38. %get the voltage responses
  39. y_axisNL_unsorted=STA_output.membranPotAVG(STA_output.STA_fnbr:end); %sthe first value is at the length of the filter
  40. %-------------------------------------------------------------------------------
  41. %% 3. sort the axis and do the binning
  42. %sort the x axis
  43. [NL_xAxis,indx]=sort(generator_signal);
  44. %sort the corresponding y axis
  45. NL_yAxis=y_axisNL_unsorted(indx);
  46. %do a binning with percentile to have same amount of data in each bin
  47. %make 40 bins
  48. nbrbins=40;
  49. bins= doBin(NL_xAxis,NL_yAxis,nbrbins);
  50. %-------------------------------------------------------------------------------
  51. %% 4. plot the nonlinearity
  52. figure;
  53. plot(NL_xAxis,NL_yAxis,'.','color','k') %plot non-binned signal
  54. hold on;
  55. plot(bins.NL_xbin,bins.NL_ybin,'o','markerfacecolor','r','markeredgecolor','r') %plot binned signal
  56. title(['NL: filename: ' STA_output.filename])
  57. axis tight
  58. xlabel('generator signal')
  59. ylabel('voltage (mV)')
  60. %-------------------------------------------------------------------------------
  61. %% 5. add variables into the output
  62. NL_output.NL_xAxis=NL_xAxis;
  63. % STA_output.STA=STA; %not normalized
  64. NL_output.NL_yAxis=NL_yAxis;
  65. NL_output.bins=bins; %for reshapeing to 3D structure if needed
  66. end