forked from pillowlab/neuroGLM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial_exampleData.m
35 lines (26 loc) · 1.22 KB
/
tutorial_exampleData.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
%% Generate example (raw) dataset for the tutorial
% REQUIRES stat toolbox for poissnrnd
nTrials = 100; % total number of trials
% preallocate structure in memory
trial = struct();
trial(nTrials).duration = 0; % preallocate
lambda = 0.1; % firing rate per bin
for kTrial = 1:nTrials
duration = 150 + ceil(rand * 200);
trial(kTrial).duration = duration;
trial(kTrial).LFP = cumsum(randn(duration, 1));
trial(kTrial).eyepos = cumsum(randn(duration, 2));
trial(kTrial).dotson = ceil(rand * (duration - 100));
trial(kTrial).dotsoff = trial(kTrial).dotson + ceil(rand * 10);
trial(kTrial).saccade = 100 + ceil(rand * (duration - 100));
trial(kTrial).coh = sign(rand - 0.5) * 2^ceil(rand*8);
trial(kTrial).choice = round(rand);
trial(kTrial).sptrain = sort(rand(poissrnd(lambda * 0.9 * duration), 1) * duration);
trial(kTrial).sptrain2 = sort(rand(poissrnd(0.1 * lambda * duration), 1) * duration);
trial(kTrial).sptrain = sort([trial(kTrial).sptrain; trial(kTrial).sptrain2 + 2]);
trial(kTrial).sptrain(trial(kTrial).sptrain > trial(kTrial).duration) = [];
trial(kTrial).meta = rand;
end
param.samplingFreq = 1; % kHz
param.monkey = 'F99';
save('exampleData.mat', 'nTrials', 'trial', 'param')