-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstantFR.m
More file actions
33 lines (29 loc) · 1 KB
/
InstantFR.m
File metadata and controls
33 lines (29 loc) · 1 KB
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
function [IFR, SpikeBin] = InstantFR(cfg)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
spkinds = cfg.spkinds;
Nsamples = cfg.Nsamples;
stdg = cfg.filtSD; % this standard deviation is in samples
fs = cfg.fs; % sampling frequency
starts = cfg.starts;
ends = cfg.ends;
%% Generate IFR
%t = (1:round(spkSampRate*S.RecDuration))/spkSampRate; %timeseries
SpikeBin = zeros(Nsamples, 1);
spkinds(spkinds < 1) = 1;
SpikeBin(spkinds) = 1; %binary spike vector
%sets up the gaussian filter for spike density estimation
%standard deviation of the gaussian smoothing
filtx = -4*stdg:1:4*stdg;
filty = normpdf(filtx,0,stdg);
filty = filty/sum(filty);
%20ms gaussian smoothing
IFR = conv2(SpikeBin(:), filty(:), 'same');
%normalize to the number of spikes in the trial as in Gabbiani et al. 1999
IFR = IFR/(sum(IFR)/fs);
IFR = IFR .* sum(SpikeBin);
IFR(1:(round(fs*starts)-1)) = NaN;
IFR((round(fs*ends)+1):end) = NaN;
SpikeBin(1:(round(fs*starts)-1)) = NaN;
SpikeBin((round(fs*ends)+1):end) = NaN;
end