-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_basedOnCoh35_Looper.m
160 lines (121 loc) · 3.89 KB
/
sim_basedOnCoh35_Looper.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
%% Test 1:
if ispc
dirComp = 'Z:/adeeti/';
elseif isunix
dirComp = '/synology/adeeti/';
end
USE_TWO_TRACES =1;
dirIn = [dirComp, 'ecog/iso_awake_VEPs/goodMice/'];
dirOut = [dirComp, 'ConnorCollab/LooperAn/'];
mkdir(dirOut)
cd(dirIn);
mouseID = 'GL13';
useTime = [950:1150];
shiftUnit = 1;
flashOn = 1000;
before = 50;
analyzeTime= 200;
shiftTime = [useTime(1):useTime(end)+analyzeTime];
noiseCo = 2*10^-3;
numTr = 18;
cd([dirIn, mouseID]);
load('dataMatrixFlashes.mat')
[expIDNum] = findExpIDNum(mouseID)
[isoHighExp, isoLowExp, emergExp, awaExp1, awaLastExp, ketExp] = ...
findAnesArchatypeExp(dataMatrixFlashes, expIDNum);
MFE = [isoHighExp, isoLowExp, awaLastExp, ketExp];
useExp = awaLastExp;
cd([dirIn, mouseID, '/FiltData/']);
load([dataMatrixFlashes(awaLastExp).expName(1:end-4), 'wave.mat'], 'filtSig35', 'info')
goodChan = [1:64];
goodChan(info.noiseChannels) = [];
data35 = permute(filtSig35, [2,1,3]);
noNanData35 = data35(goodChan,useTime,:);
sig2shift_tr1 = squeeze(data35(info.lowLat,shiftTime,1));
sig2shift_tr2 = squeeze(data35(info.lowLat,shiftTime,2));
%to make one wave out of V1 wave shifted
tr1Ind = randsample(numTr, numTr/2);
%%
% Run looper on one wave
allDelTime = [2 5 7];
allDelCount = [1 2 5 7];
allNN = [6 8 10];
sim35WaveR2 = [];
sim35WaveNumLoops = [];
sim35WaveMapLoopsNum = [];
sim35WaveMapLoops =[];
for h = 1:2
if h==1
USE_TWO_TRACES =0;
elseif h == 2
USE_TWO_TRACES =1;
end
useBuffV1_noise = [];
useBuffV1 = [];
for tr = 1:numTr
if ismember(tr,tr1Ind)
useShiftData = sig2shift_tr1;
else
if USE_TWO_TRACES ==1
useShiftData = sig2shift_tr2;
else
useShiftData = sig2shift_tr1;
end
end
buffV1 = buffer(useShiftData, analyzeTime, analyzeTime-shiftUnit);
buffV1 = buffV1(:, analyzeTime:end);
useBuffV1(tr,:,:)= buffV1(1:64,:);
useBuffV1_noise(tr,:,:) = buffV1(1:64,:) + normrnd(0,noiseCo,size(buffV1(1:64,:)));
end
% figure
% plot(squeeze(useBuffV1_noise(:,1,:))')
% hold on
% plot(squeeze(useBuffV1(:,1,:))')
%%
for dT = 1:length(allDelTime)
delTime = allDelTime(dT);
for dC = 1:length(allDelCount)
delCount = allDelCount(dC);
for nn = 1:length(allNN)
NN= allNN(nn);
saveData = [];
[params] = makeLooperParams(delTime, delCount, NN);
LOOPER(saveData, true, useBuffV1_noise, [], [], params);
%results
sim35WaveR2(h,dT,dC,nn) = saveData.Ouputs.RSquared;
sim35WaveNumLoops(h,dT,dC,nn) = saveData.BestLoopCount;
sim35WaveMapLoopsNum(h,dT,dC,nn) = numel(unique(saveData.BestStateMap(:,1)));
sim35WaveMapLoops{h,dT,dC,nn} = saveData.BestStateMap(:,1);
end
end
end
end
save([dirOut, 'sim_35Coh_LOOPer.mat'], 'sim35WaveR2', 'sim35WaveNumLoops', ...
'sim35WaveMapLoopsNum', 'sim35WaveMapLoops')
% figure
% plot(sim35WaveMapLoops)
%%
function [params] = makeLooperParams(DelayTime, DelayCount,NearestNeighbors)
params = [];
if nargin<3||isempty(NearestNeighbors)
params.NearestNeighbors = NearestNeighbors;
else
params.NearestNeighbors = [6];
end
if nargin<2||isempty(DelayCount)
params.PreprocessData.DelayCount = [2]; %, 3, 5, 10];
else
params.PreprocessData.DelayCount =DelayCount;
end
if nargin<1||isempty(DelayTime)
params.PreprocessData.DelayTime = [5]; %, 5, 10, 15, 20, 30];
else
params.PreprocessData.DelayTime = DelayTime;
end
params.PreprocessData.ZScore = 1; %or 0
params.PreprocessData.Smoothing = 0; %or 0 - this is in sigma
params.UseLocalDimensions =1; %will want this as 1
params.PutativeLoopCounts = [5,4,3,2,1];
params.UseTerminalState = 1;
params.TotalStates = 40;
end