-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_fr.m
96 lines (70 loc) · 2.59 KB
/
compute_fr.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%function compute_fr
%function compute_fr
% Compute firing rate from laminar data
%
%
% Corentin Massot
% Cognition and Sensorimotor Integration Lab, Neeraj J. Gandhi
% University of Pittsburgh
% created 03/08/2017 last modified 03/08/2017
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%set paths
[root_path data_path save_path]=set_paths;
%screen size
scrsz = get(groot,'ScreenSize');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%parameters
%print figures and save data
savedata=0;
savefigs=0;
figtype='epsc2';%'png';%'epsc2';
%alignement
%alignlist={'no' 'targ' 'go' 'sacc'};
alignlist={'no'};
%gaussian filtering
sigma_FR=6;
filt=['gauss_' num2str(sigma_FR)];
%epsp filtering
param2=20;%6; %20ms drecrease rate is the right value (See Thompson et al. Schall 1996)
filt=['epsp_' num2str(param2)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%get data
datalist=load_data_gandhilab(data_path);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%analyzing data
dlist=get_dlist
for d=dlist%1:numel(datalist)
data=[];
%get data and info
info.datafile=datalist{d};
load ([data_path info.datafile]);
display(info.datafile)
%getting channel mapping and discard selected bad channels
[info.chmap info.nchannels info.depths]=get_chmap(data(1).info.electrode{2},[]);
info.align=alignlist{1};
%get all trials
for t=[1:numel(data)]
%get spiketimes for the whole trial
size_trial=size(data(t).lfp,2);
trialsize=size_trial+20;
trial=zeros(info.nchannels,trialsize);
for ch=1:info.nchannels
trial_spkt=zeros(1,trialsize);
spiketimes=round(1000*data(t).spikeTimestamps{ch});
spiketimes_sel=spiketimes(find(spiketimes~=0 & spiketimes<=size_trial));
trial_spkt(spiketimes_sel)=1;
%compute firing rate of spiking activity
%gaussian filtering
%trial(ch,:) = filter_FR(trial_spkt(:),'gauss',1000,sigma_FR);
%epsp filtering
trial(ch,:) = filter_FR(trial_spkt(:),'epsp',1000,1,param2);
%Chronux toolbox
%[V,t,Err] = evoked(data,Fs,win,width,plt,err)
end
%Update data
eval(['data(t).offline.fr_' filt '=trial;']);
end
%save updated data
update_data(1,0,0,data,data_path,info.datafile,[],[]);
end