Matlab Assignment Help l Homework Problem Solution l Project in Matlab
For the best Matlab assignment help you can possibly find, the work is guaranteed to be plagiarism free since it is done from a clean slate each time.
Matlab is a propiertary programming language that is expicitly designed to enable mathematical programming using matrices.
Matlab MA 568 – Statistical Analysis of Point Process Data
Cells in the brain communicate and perform computations using electrical impulses, called spikes. Point process models are often used to propose an explicit relationship between spikes recorded from the brain and other measured signals including sensory stimuli and motor behavior. For many neuroscience experiments, an important first task is to characterize the ‘baseline’ spiking activity that is observed in the absence of interesting stimuli. A common assumption about this baseline activity is that it can be described as a simple Poisson process.
In this problem, we will attempt to characterize the firing properties of the maintained discharges of retinal ganglion cells of the goldfish under constant light and environmental conditions. This data is described in more detail in Iyengar & Liao, Biological Cybernetics, 1997.
1. Please download the Retinal_ISIs.mat file from the course website. This file contains the interspike intervals (ISIs) of a single retinal ganglion cell over a couple of minutes. Open this file and plot the spiking activity as a histogram of the distribution of the times between spiking events and as a spike train time series. Describe the spiking properties of this neuron based on your visualizations.
From the histogram, it is obviously that the ISIs data has the distribution decaying from small values to large values. Most of the values are within 0 ~ 20.
2. Compute a 5-number summary (minimum, .25 quantile, median, .75 quantile, and maximum) and a box plot for the interspike interval (ISI) distribution. What do these statistics tell you about the structure of the data?
Table 1: Minimum, 25% quantile, median, 75% median and maximum of ISIs
|Minimum||25% quantile||Median||75% quantile||Maximum|
From the table and plot, we can see that the data of ISIs is not symmetric distributed, and most of the data concentrate around small values.
3. Another common approach to analyzing spiking data is to discretize time into bins of fixed width and count the number of events that occur in each time bin. Bin the spiketrain data from Retinal_ISIs.mat into time bins of width 1 ms., 10 ms., and 100 ms.. Plot both the time series of spike counts and the distribution of spike counts as a histogram for each bin width.
4. In class, we showed that the log likelihood for a homogeneous Poisson process with rate parameter λ is given by:
Where N(T) is the number of spikes in the observation interval. Plot the likelihood as a function of λ for values of λ between 0 Hz to 60 Hz. Find the value of λˆML that maximizes the likelihood. Provide an approximate 95% confidence interval for λˆML.
There are 972 events in 29,968 ms, so let T = 29968 and N(T) = 972. The plot is:
λˆML = 0.0701$ will maximize the log-likelihood function.
To archive a 95% confidence interval, we sample from the raw data by 100 times and repeating maximization procedure 100 times to get 100 λˆML. The 2.5% and 97.5% quantiles compose a 95% confidence interval of. Note that, the since 100 × 2.5% = 2.5 and 100 × 97.5% = 97.5 are not integer, so 2.5% quantile is the average of 2% quantile and 3% quantile. Similarly, 97.5% quantile is
average of 97% quantile and 98% quantile.
5. Plot an empirical CDF of the interspike intervals for the data. For a Poisson process, the theoretical interspike intervals should be independent exponentially distributed with parameter λˆML. Plot this exponential CDF on the same plot as your empirical CDF. Compute the KS statistic, defined as max|FEMP(x)-Fmodel(x)|. Construct a KS plot of the empirical CDF on the x-axis against the model CDF on the y-axis, including 95% confidence bounds, given approximately by ±1.36√n, where n is the number of observed ISIs.
KS = max|FEMP(x)-Fmodel(x)| = 0.2051.
6. Construct a QQ plot of the empirical vs. model quantiles. For which ISI values does the QQ plot most deviate from expected?
ISIs = 158 will cause the largest deviation from expected.
7. Compute the sample Fano Factor for the increments process binned at 1 ms, 10 ms, and 100 ms resolutions. The sample Fano Factor for a Poisson process is distributed as a Γ(n/2, 2/n) random variable. Do these statistics fall into the 95% confidence interval for a Poisson process at each of these bin lengths?
Table 2: Fano Factor
|Bin width||Fano Factor||95% CI||In the CI?|
8. Compute the rescaled random variables
Zi = F-1Gaus(0,j)(FExp(λˆML)(Xi)),
where Xi are the observed interspike intervals. Plot a histogram of the values of Zi. How well is this fit by a Gaussian model? Plot the autocorrelation function of Zi with 95% confidence bounds. The 95% confidence interval for the correlation coefficient of independent Gaussian random variables is ±1.96√n. What does this suggest about the assumption that the ISIs are independent?
Using nonparametric Kolmogorov-Smirnov test, the p-value is 5.7958e-037, so there is no evidence to show that Zi follow the Gaussian distribution.
9. What conclusions can you draw about the spontaneous firing properties of these retinal ganglion neurons? Given that environmental conditions for this experiment are constant, what other variables could be added to our baseline neural model to improve goodness-of-fit?
From the above analysis and calculation, the time interval for interspike is not exponential distributed statistically. This is maybe due to that the Poisson process is not homogeneous. One may add the experiment data such as the time that each experiment lasts to build a non-homogeneous Poisson process.
load('E:\\Assignment\\2014-09-27\\5425bd5ae8ed0-Retinal_ISIs (1).mat') %1. plot the spiking activity as a histogram of the distribution of the times between spiking events and as a spike train time series hist(ISIs); cumsum(ISIs); %2. Compute a 5-number summary (minimum, .25 quantile, median, .75 quantile, and maximum) and a box plot for the interspike interval (ISI) distribution. ISIs2=sort(ISIs); N=length(ISIs); q0=min(ISIs2); q25=ISIs2(0.25*N); q50=ISIs2(0.5*N); q75=ISIs2(0.75*N); q100=max(ISIs2); boxplot(ISIs); title('Box plot for ISIs'); %3. Bin the spike train data into time bins of width 1 ms., 10 ms., and 100 ms.. %Plot both the time series of spike counts and the distribution of spike counts as a histogram for each bin width. bins = [1,10,100]; for i = 1 : 3 bin=bins(i); bin_ISIs=floor(ISIs/bin)*bin; subplot(3,2,(i-1)*2+1); plot(bin_ISIs); tit1 = ['Time Series Plot for bin = ',num2str(bin)]; title(tit1); subplot(3,2,(i-1)*2+2); hist(bin_ISIs); tit2 = ['Histogram Plot for bin = ', num2str(bin)]; title(tit2); end %4. Plot the likelihood as a function of lambda for values of lambda between 0 Hz to 60 Hz. Find lambda which maximize the log-likelihood %function %Calculate the total minutes by all spikes spikes = cumsum(ISIs); N = length(spikes); T = spikes(N); LogLikelihood=@(lambda)(N*log(lambda)-lambda*T); y =; n=1000; lambda = linspace(0.01,60,n); for i = 1:n; x = lambda(i); y=[y,LogLikelihood(x)]; end plot(lambda,y); max_index = find(y==max(y)); lambda_opt = lambda(max_index); %Construct 95% confidence interval for lambda using Mote Carlo M = 100; lambdas=; for i = 1 : M y =; Sample_Index = randsample(101:N,1); ISIs_2 = ISIs((Sample_Index-100+1):Sample_Index); spikes2 = cumsum(ISIs_2); n = length(spikes2); t = spikes2(n); LogLikelihood=@(lambda)(n*log(lambda)-lambda*t); l = linspace(0.01,60,1000); for i = 1:1000; x = l(i); y=[y,LogLikelihood(x)]; end max_index = find(y==max(y)); lambda_opt = l(max_index); lambdas=[lambdas,lambda_opt]; end lambdas = sort(lambdas); lambda_lower = (lambdas(M*0.02)+lambdas(M*0.03))/2; lambda_upper = (lambdas(M*0.97)+lambdas(M*0.98))/2; %5. Plot an empirical CDF of the interspike intervals for the data. %Empirical distribution of ISIs CDF_ISIs = @(t)(length(find(ISIs<=t))/length(ISIs)); Emp_ISIs = ; for t = 1:1:200 y = CDF_ISIs(t); Emp_ISIs = [Emp_ISIs,y]; end %Exponential distribution of ISIs with lambda = lambda_opt t = 1:1:200; Exp_ISIs = cdf('exp',t,1/lambda_opt); plot(t,Emp_ISIs,t,Exp_ISIs); legend('Empirical CDF','Exponential CDF'); title('Empirical CDF and Exponential CDF for ISIs'); KS = max(abs(Emp_ISIs-Exp_ISIs)); Exp_ISIs_upper = Exp_ISIs+1.36/sqrt(N); Exp_ISIs_upper = min(Exp_ISIs_upper,1); Exp_ISIs_lower = Exp_ISIs-1.36/sqrt(N); Exp_ISIs_lower = max(Exp_ISIs_lower,0); plot(Emp_ISIs,Exp_ISIs,Emp_ISIs,Exp_ISIs_lower,':',Emp_ISIs,Exp_ISIs_upper,':'); legend('Exponential','Lower Bound','Upper Bound'); title('Empirical CDF vs Exponential CDF with Confidence Interval'); %6. Construct a QQ plot of the empirical vs. model quantiles. t=1:1:N; t=t/N; ExpInv = expinv(t,1/lambda_opt); plot(ISIs2,ExpInv); title('QQ plot for ISIs against Exponential distribution'); deviation = abs(ISIs2-ExpInv'); deviation2 = deviation(find(~isinf(deviation))); largest_deviation = max(deviation2); largest_deviation_ISIs = ISIs2(find(deviation==largest_deviation)); %7. Compute the sample Fano Factor for the increments process binned at 1 ms, 10 ms and 100 ms resolutions bin=1; bin_ISIs=floor(ISIs/bin)*bin; var_ISIs = var(bin_ISIs); mu_ISIs = mean(bin_ISIs); Fano_Factor=var_ISIs/mu_ISIs; lower_CI = gaminv(0.025,N/2,2/N); upper_CI = gaminv(0.975,N/2,2/N); bin=10; bin_ISIs=floor(ISIs/bin)*bin; var_ISIs = var(bin_ISIs); mu_ISIs = mean(bin_ISIs); Fano_Factor=var_ISIs/mu_ISIs; bin=100; bin_ISIs=floor(ISIs/bin)*bin; var_ISIs = var(bin_ISIs); mu_ISIs = mean(bin_ISIs); Fano_Factor=var_ISIs/mu_ISIs; %8. Compute the rescaled random variables Z z= norminv(cdf('exp',ISIs,1/lambda_opt)); hist(z); title('Histogram of Z value'); [h,p] = kstest(z); autocorr(z);
Don’t rely on your friends to provide you with your Matlab project help as copying from them may lead to you both getting in trouble.