-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_activeW_units.m
executable file
·100 lines (76 loc) · 3.7 KB
/
save_activeW_units.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
datadir_superlin = '/opt/data13/kkay/Superlin_data/';
savedir = '/opt/data13/kkay/__WG';
runcollect = 1;
if runcollect
placestate = 2; % superlin timefilter # for place state
ratethresh_field = [0.5 1 2 5];
animals_torun = {'Government','Egypt','Chapati','Dave','Higgs','Frank','Bond','Corriander'};
animals_order = {'Government','Egypt','Chapati','Dave','Higgs','Frank','Bond','Corriander'};
end
if runcollect
st = placestate;
numthresh = length(ratethresh_field);
adtc = [];
actmatrix = {};
% load one animal at a time, so divide up target_adtc into blocks
for an = 1:length(animals_torun)
animalname = animals_torun{an};
animalnum = find(strcmp(animalname,animals_order));
animalinfo = animaldef(animalname);
disp(animalname)
% load superlin file
filename = dir(sprintf('%sSuperlin_%s*',datadir_superlin,animalname(1:3)));
load([datadir_superlin filename(end).name],'superlin')
% load cellinfo file
spikes = loaddatastruct(animalinfo{2},animalinfo{3},'spikes');
for reg = 1:5 % holdover from superlin, each hippocampal region (CA1, CA2, CA3, DG, Septal)
if isempty(superlin.data{reg}.dtc_output)
continue
end
for c = 1:length(superlin.data{reg}.dtc_output)
adtc = [adtc ; animalnum superlin.data{reg}.dtc_output(c).index];
detc = superlin.data{reg}.dtc_output(c).indices;
eps = superlin.data{reg}.dtc_output(c).indices(:,2)';
numeps = length(eps);
outmat = nan(numeps,1 + numthresh) ;
outmat(:,1) = eps'; % first column is the epoch #
% find traj data for this epoch
for ee = 1:numeps
ep = eps(ee);
% Verify that this unit was clustered in spikes data
if isempty(spikes{detc(1,1)}{ep}{detc(1,3)}{detc(1,4)})
keyboard
end
% Search for entry and look at each trajectory
for zz = 1:length(superlin.data{reg}.detc_output{st})
entryindex = superlin.data{reg}.detc_output{st}(zz).index;
if all ( detc(ee,:) == entryindex )
data = superlin.data{reg}.detc_output{st}(zz).trajdata;
for th = 1:length(ratethresh_field)
thresh = ratethresh_field(th);
active = 0;
for traj = 1:length(data)
if ~isempty(data{traj})
if any(data{traj}(:,5) > thresh)
active = 1;
end
end
end
outmat(ee,th + 1) = active;
end
break
end
end
end
actmatrix = [actmatrix ; {outmat} ];
end
end
end
ACT.animals_order = animals_order;
ACT.ratethresh_field = ratethresh_field;
ACT.adtc = adtc;
ACT.actmatrix = actmatrix;
ACT.descript = 'list of units + corresponding W-track epochs + different place rate thresholds';
cd(savedir)
save('ACTIVEMATRIX','ACT','-v7.3')
end