Question
Matlab question This is what we are given: fr=0.2:0.1:20;%in Hz Instead of using a lambda as we did before, %we will call this a firing
Matlab question
This is what we are given:
fr=0.2:0.1:20;%in Hz Instead of using a lambda as we did before,
%we will call this a firing rate vector or fr
T=5000;
dt=1/1000;% Before we assumed that the time stamps were
%in milliseconds, instead of that assumption, we will
%have time in seconds and adjust the firing
%rate to milliseconds through this dt
RandomNos=rand(T/dt,1);%Create 1 long time vector
%of random numbers, for 500 seconds, at the resolution of 1ms.
%Now we are going to write a loop, this is going to use,
%one by one, the
%different values in fr, and calculate Spikes
%and inter spike intervals.
for i=1:length(fr)
clear Spikes %I am clearing the variable Spikes, so that in each looping of firing rate, we start creates 1's and 0's afresh
CurrentLambda=fr(i)*dt;%
Spikes=RandomNos
FRfound(i)=sum(Spikes)/T;% As a sanity check, we find
%how many spikes happened in 500 seconds
ISI=diff(find(Spikes==1))*dt;%We find the difference in time
%between 2 spikes, and adjust it to seconds by multiplying
%by "dt"
binEdges=0:0.001:5;%We create edges for the bins which the histogram should use.
counts(i,:)=hist(ISI,binEdges);% We create a histogram of these ISI values, and
%store the count and bin centers in the 2 variables as above, for each
%firing rate
countNorm(i,:)=counts(i,:)/length(ISI); % Based on the number of spikes, which will
%increase with firing rate, the size or length of the ISI vector will
%change too. We want the histogram to give us normalized or percentage
%spikes in each bin, so we divide by length(ISI) which is the total number
%of ISI values for the current firing rate.
mISI(i)=mean(ISI);%we find the mean and standard deviation
%and variance of these Inter spike intervals
sISI(i)=std(ISI);
vISI(i)=var(ISI);
CV(i)=std(ISI)/mean(ISI);% We find the ratio of mean and
%standard deviation for a Poisson process CV does not
%depends on lambda or fr*dt in our case
end
figure;
plot(binEdges,countNorm(49,:),'r')% We will plot only the 3 histograms, for sake
% of clarity, that correspond to the firing rates of 5 10 20Hz,in our fr vector
hold on
plot(binEdges,countNorm(99,:),'k');% Each histogram is being plotted here with different colors, red(r) black(k) and blue(b)
plot(binEdges,countNorm(199,:),'b');
set(gca,'Xscale','log')% Instead of a linear scale, we set the scale to be log
legend('5Hz','10Hz','20Hz')%Using legend, we can label each color in our plot
ylabel('Fraction of spikes')
xlabel('ISI interval in sec')
figure;plot(fr,FRfound,'.')% THis is a sanity check, we expect a straight line like behavior
figure;plot(fr,CV)% We expect a flat type curve
xlabel('Firing Rate')
ylabel('CV')
figure;plot(mISI,sISI,'.')% Since the CV is flat, mean and standard deviation of ISI will be proportional to each other
%Next we are going to find the autocorrelation between the spike train
%above, refer function "xcorr" for documentation on how to compute
%autocorrelation
[cor,lags]=xcorrC186(Spikes,'coeff');%The cor is where we store the correlation and lags is the shift we bring about in the spike train, to find the corresonponding correlation
% We want to only look at the time +-2 seconds around the center. So we
% find the index corresponding to zero lag, and go +-2000 around it
middleInd=find(lags==0);
cor(middleInd)=mean(cor(~middleInd));%We replace the correlation %at zero lag, which is 1, but a smaller number for plotting
%purposes
figure;plot(lags(middleInd-2000:middleInd+2000),cor(middleInd-2000:middleInd+2000));
now question:
-
we created ISI histograms for a neuron with a firing rate of 5Hz. Combine this idea with using forloops, to create a single figure with ISI histogram plots for 5 neurons(use hold on), with firing rates of 1 2 4 8 and 16Hz firing rate, over a time of 100 seconds, and a temporal resolution of 1ms. Label the axes and put appropriate title. Explore the legend command in MATLAB to label different plots to indicate their respective mean firing rates.
-
Summarize in 4 lines, what you observe in your figure from Q1 regarding the nature of histogram curves for increasing firing rates.
-
Simulate a neuron over a duration of 100 seconds with a temporal resolution of 1ms such that, it fires in integral multiples of 100ms time (ie at 100ms, 200ms 300ms and so on) as well as in integral multiples of 140ms (ie 140ms 280ms 420ms and so on). These time intervals would overlap, for instance at 700ms interval; consider only 1 spike at instances like this. For this neuron plot the autocorrelation of spike train. Label the axes appropriately, with units.
-
Summarize in 4 lines, what you observe in the autocorrelation plot for Q3, in terms of periodicity, number of peaks, decay interval between peaks etc.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started