-
Notifications
You must be signed in to change notification settings - Fork 0
/
coh_resp.m
71 lines (55 loc) · 1.74 KB
/
coh_resp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% Compute coherence between respiratory rhythm and rhythms in single cell
% recordings
tic
% load data
cellname = 'cella270319';
recording = strcat(cellname,'.mat');
load(recording)
stimulation = strcat(cellname,'stim.mat');
load(stimulation)
volt = Ch3.values(1:end-1); % in mV
t = Ch3.times(1:end-1); % in s
sampleint = Ch3.interval;
samplefreq = 1/sampleint; % in Hz
resp = Ch7.values; % in mV
% parameters
odor_dur = 5; % in s
call_dur = 1; % in s
f = 1:10; % frequencies for which to compute coherence
win_size = 5; % window in which to compute coherence
overlap = 4; % 80 % overlap = moves 1 s per computation
window = floor(win_size*samplefreq);
noverlap = floor(overlap*samplefreq);
% Look for coherence during odor presentations, calls and baseline
Odor = cat(1,LemOd,MomOd,NonMomOd,NonSibOd,SibOd);
Call = cat(1,MomCall,NonMomCall,NonSibCall,SibCall);
t_od = []; t_call = [];
for i=1:size(Odor,1)
temp = t(t>Odor(i) & t<(Odor(i)+odor_dur));
t_od = [t_od; temp];
end
for i=1:size(Call,1)
temp = t(t>Call(i) & t<(Call(i)+call_dur));
t_call = [t_call; temp];
end
t_rem = cat(1,t_od,t_call);
t_base = setdiff(t,t_rem);
% convert times to indices
odor = round(t_od*samplefreq);
call = round(t_call*samplefreq);
base = round(t_base*samplefreq); base = base(2:end);
% receive averaged coherences
[cxy_odor,f] = mscohere(resp(odor),volt(odor),window,noverlap,f,samplefreq);
[cxy_call,f] = mscohere(resp(call),volt(call),window,noverlap,f,samplefreq);
[cxy_base,f] = mscohere(resp(base),volt(base),window,noverlap,f,samplefreq);
% plot
figure
plot(f,cxy_odor)
hold on
plot(f,cxy_call)
plot(f,cxy_base)
legend('Odors','Calls','Baseline')
title('Respiration - single cell recording coherence')
ylabel('Coherence')
xlabel('Frequency (Hz)')
toc