-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGetLinearIndex.m
More file actions
56 lines (49 loc) · 1.84 KB
/
GetLinearIndex.m
File metadata and controls
56 lines (49 loc) · 1.84 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%% Return linear indexing based on delay matrix
%
% ARGUMENTS:
% delay -- Matrix of time delays
% iters --
% maxdelayiters --
% dt -- integration time step
%
% OUTPUT:
% lidelay -- delay in the form of linear indexes to an array that
% consists of (iters + maxdelayiters) rows and N
% columns, where N is the number of nodes. Indexes are
% inverted so that they will count backward from the
% current time point.
%
% USAGE:
%{
lidelay = GetLinearIndex(delay, iters, maxdelayiters, dt);
%}
%
% MODIFICATION HISTORY:
% SAK(17-09-2009) -- Original.
% SAK(03-12-2009) -- Changed N to N1,N2 to reuse for vector of
% corticothalamic delays...
% SAK(Nov 2013) -- Move to git, future modification history is
% there...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function lidelay = GetLinearIndex(delay, iters, maxdelayiters, dt, CouplingVariables)
if nargin<5,
CouplingVariables = 1;
end
[N1 N2] = size(delay);
%Convert time delays into a integer number of integration steps...(with 0 delay counting as previous time point???)
idelay = round(delay/dt)+1;
%Calculate offset required to convert the values idelay into a linear index
NumberOfRows = iters + maxdelayiters;
OffsetMatrix = repmat((0:NumberOfRows:(NumberOfRows*(N2-1))), [N1 1]);
%Offset delays and invert them so that they count into the past
lidelay(1,:,:) = maxdelayiters - idelay + OffsetMatrix;
%
if CouplingVariables~=1,
ElementsInHistory = N2*NumberOfRows;
for cv = 2:CouplingVariables,
lidelay(cv,:,:) = lidelay(1,:,:) + (cv-1)*ElementsInHistory;
end
else
lidelay = squeeze(lidelay);
end
end %function GetLinearIndex()