-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeProcessedDatatable.m
More file actions
58 lines (49 loc) · 2.02 KB
/
Copy pathmakeProcessedDatatable.m
File metadata and controls
58 lines (49 loc) · 2.02 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
function [ProcessedDatatable] = makeProcessedDatatable(varargin)
masterdirs = varargin;
if isempty(varargin)
error('You gotta add some directories to process!')
end
for i = 1:length(masterdirs)
cd(masterdirs{i});
MasterDir = masterdirs{i};
EphysPath = masterdirs{i};
temp_string = strsplit(EphysPath, '\');
LocalDataRoot = strcat(temp_string{1}, '\', temp_string{2}, '\', temp_string{3}, '\');
temp_str = strsplit(EphysPath, '-');
mouseID = temp_str{end};
try
load(fullfile(MasterDir,'RecLengths.mat'))
catch
% load rez, which contains number of samples of each recording 1=1, 2=1+2,
% 3=1+2+3, etc
load(fullfile(MasterDir,'rez.mat'))
L = (rez.ops.recLength)/sp.sample_rate;
save(fullfile(MasterDir,'RecLengths.mat'),'L')
end
load(fullfile(MasterDir, 'dirs.mat'));
for i = 1:length(dirs)
[SortedUnitsFile] = ProcessSpikes(dirs{i}, LocalDataRoot);
load(SortedUnitsFile);
if i == 1
AllSortedUnits = SortedUnits;
end
for j = 1:length(SortedUnits)
if i >= 2
start = L(i - 1);
SortedUnits(j).spiketimes = SortedUnits(j).spiketimes + start;
AllSortedUnits(j).spiketimes = [AllSortedUnits(j).spiketimes SortedUnits(j).spiketimes];
end
end
clear SortedUnitsFile
end
for j = 1:length(AllSortedUnits)
SortedUnits(j).spiketimes = AllSortedUnits(j).spiketimes;
SortedUnits(j).dir_indx = AllSortedUnits(j).dir_indx;
SortedUnits(j).Bdir = AllSortedUnits(j).Bdir;
SortedUnits(j).dir = AllSortedUnits(j).dir;
end
savename = strcat('SortedUnits-', mouseID);
save(fullfile(MasterDir, savename), 'SortedUnits', 'L');
ProcessAllEvents(MasterDir);
end
end