# Analysis-of-MUAe-latency ``` % COMPUTE LATENCY function written by Demetrio Ferro % Based on (Roelfsema, Tolboom, Khayat, Neuron 2007). % developed for (Ferro, van Kempen, Boyd, Panzeri, Thiele, PNAS 2021) % The function computes Latency indices base don MUAes fitted by cumulative % gaussian function with 5 (degrees of freedom) parameters (mu, sigma, alpha, c, d). % The best fit is assigned based on Least Squares (LS) of iterative estimation. % Inputs: % MuaeData [NxT] Multi-channel (N channels) MUAes in time (T points) % MuaeTimes [1xT] Timestamps of MUAe recordings (T points) % lsqTimeRes [1x1] Resolution of time series for Latency estimation % Outputs: % latTimes [1xN] Latency indices at t*:={f(t*)=1/3*max(f(t)),t in MuaeTimes} % lsqCurveTimes [1x(T*lsqTimeRes)] Timestamps of fitted curves % lsqFittedCurve [Nx(T*lsqTimeRes)] Fitted curves at LS parameters % lsqFittedParam [Nx5] LS parameters % lsqFitErr [1xN] LS error of the fit ``` [Demo with synthetic data](https://gin.g-node.org/demetrio.ferro/Analysis-of-MUAe-latency/src/029b17ab1a2ae7519f9e0f56009876ed856f66d3/demo.m) ![demo signal](https://gin.g-node.org/demetrio.ferro/Analysis-of-MUAe-latency/raw/029b17ab1a2ae7519f9e0f56009876ed856f66d3/sample-signal.png)