-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnPSD_units_figs.m
73 lines (61 loc) · 2.11 KB
/
AnPSD_units_figs.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
% A part of the old AnPSD script adapted to display and save figures of
% coherence and phase analyses for unit and population spiking rate data.
%% LOAD PRE-PROCESSED DATA
if ~exist('dataStruct','var')
load(dataFile);
end
%% INITIALISE PARAMETERS
params
lists
figsubdirname = '';
UPF = 5; % Units Per Figure
x_lim = [0.01 120];
visibility = 'on';
figType1 = 'ephysUnit';
figType2 = 'ephysGroups';
powerUnits = 'APs^2/Hz';
%% DRAW FIGURES
fnsData = fieldnames(dataStruct.seriesData);
if ~isempty(dbEntries) && dbEntries(1) == inf
dbEntriesLocal = 1:numel(fnsData);
else
dbEntriesLocal = dbEntries;
end
for dbCount = dbEntriesLocal % Loop through db entries
% Load the contents of dbStruct
[dbStruct, ~, ~, entryName, ~, ~, shankIDs,...
~, period, ~, ~, srData, ~, ~, ~,...
MUAsAll] = get_dbStruct(dataStruct, dbCount);
% Indices for truncating data
[inds, MUAsAll] = determineInds(period, srData, MUAsAll);
% Output folder
strSep = strfind(entryName,'s');
figsubdirname = entryName(strSep+1:end);
if ~exist(figsubdirname,'dir')
mkdir(figsubdirname)
end
for sh = 1:numel(shankIDs) % Loop through shanks
fprintf('%s shank %d -------------------\n', fnsData{dbCount}, sh);
% Load the contents of shankStruct
[shankStruct, shank, units, ~, ~, ~, ~, MUAs, phaseCoh] = get_shankStruct(dbStruct, sh);
if isempty(units)
continue
end
if ~isfield(shankStruct,'phaseCoh')
continue
end
if ~isempty(MUAs)
MUAs = MUAs(:,inds);
end
nUnits = numel(units);
for u = 1:nUnits % Loop through units
fprintf('Processing %s shank %d unit %d\n', fnsData{dbCount}, sh, u);
unitData = phaseCoh{u};
if isfield(unitData,'coh')
phaseCoherencePlots(sh, u, UPF, unitData, srData, units(u), nUnits, powerUnits, x_lim, figsubdirname, entryName, figType1,...
visibility, MUAsAll, shank, MUAs);
end
end % loop over units
end % loop over shanks
end % loop over db entries
clearvars -except dataFile dbEntries dbEntries_c dbEntries_ca dataStruct