Devineni PS9

advertisement
Anita Devineni
NS248 Problem Set 9: Continuous Processes
load ps9.mat
% prob 1a
figure
plot(lfptimes(1:10000),lfpdata(1:10000))
% prob 1b,c
params = {};
params.Fs = 1500;
params.fpass = [0 150];
params.err = 0;
params.trialave = 0;
[S,f]=mtspectrumc(lfpdata(1:100000),params);
% plot power spectrum
figure
plot(f,S)
xlabel('frequency')
ylabel('power')
% make log plot of power
figure
semilogy(f,S)
% The frequency band around 10 Hz stands out.
% prob 2a
TW=3;
K=5;
params.tapers=[TW K];
[S t f] = mtspecgramc(lfpdata(1:100000), [.5 .25], params);
% plot spectrogram
figure
imagesc(t, f, log(S'));
title('log power')
xlabel('time')
ylabel('frequency')
% prob 2b
% average power of 6-10Hz over time
avg=mean(S(:,5:8),2);
figure
plot(log(avg))
% find speeds corresponding to time points in t
speeds=zeros(size(avg));
postimesnorm = postimes-postimes(1);
for i=1:length(t)
[tmp,index] = min(abs(postimesnorm-t(i)));
speeds(i) = abs(speed(index));
end
% make scatterplot of speeds vs. theta
figure
plot(speeds, log(avg), '.')
xlabel('speed')
ylabel('theta log power')
% run correlation analysis
[r,p]=corrcoeff(speeds,log(avg))
r =
1.0000
0.2210
0.2210
1.0000
1.0000
0.0003
0.0003
1.0000
p =
The p value indicates that there is a significant correlation between speed and theta power.
Problem 3:
a) The magnitudes determine how severely the other frequencies outside the desired range are
filtered out.
b) The order decreases, suggesting that a more strict filter requires a higher order.
c) The order increases, suggesting again that a more strict filter (because the transitions are
tighter) requires a higher order.
% prob 4a
load thetafilter.mat
% filter the data
A=thetafilter.tf.num;
B=thetafilter.tf.den;
Y1 = filter(A,B,lfpdata);
% plot the filtered and unfiltered data
figure
plot(lfptimes,Y1)
hold on
plot(lfptimes,lfpdata,'r')
xlabel('time')
% The filter looks like a good match because the high frequency noise
% has been filtered out, but the filtered data is out of phase.
% The filter does not seem to work well at the beginning of the trace.
% prob 4b
% filter the data twice
Y2 = filtfilt(A,B,lfpdata);
% plot the filtered and unfiltered data
figure
plot(lfptimes,Y2)
hold on
plot(lfptimes,lfpdata,'r')
xlabel('time')
% Twice filtering the data fixes the phase problem and also improves
the
% filtering at the beginning of the trace.
% prob 5a
h=hilbert(Y2);
amp=abs(h);
phase=angle(h);
figure
plot(lfptimes,Y2)
hold on
plot(lfptimes, amp,'r')
% Yes the magnitude looks right.
% prob 5b
figure
plot(lfptimes,Y2)
hold on
plot(lfptimes, phase,'r')
% Yes the phase looks right but it is hard to see, so plot phase * 200
figure
plot(lfptimes,Y2)
hold on
plot(lfptimes, phase.*200,'r')
Download